Problem
tests/integration_test.rs contains hardcoded Stellar testnet addresses in test fixtures. These addresses are testnet-specific and will fail on mainnet or if the test environment changes.
Hardcoded addresses like "GABC...XYZ" (sender), "GDEF...UVW" (recipient), and contract IDs are embedded in the test file. These addresses:
- May be test accounts that get cleaned up or run out of testnet XLM
- Create a dependency on external testnet state (account must exist and be funded)
- Cannot be reused in unit tests without a live Stellar testnet connection
- Make the test suite non-deterministic (fails if testnet is down or accounts are unfunded)
Root Cause
Integration tests were written using real Stellar testnet addresses without parameterization or mock infrastructure.
Impact
- CI may fail intermittently when testnet is unavailable or accounts are unfunded
- Tests cannot run in offline/unit mode — every test requires a live network connection
- Hardcoded addresses become outdated as test accounts are rotated or funded differently
- A contributor changing the mock adapter cannot easily test without a live testnet connection
Fix
Step 1 — Define test constants in a separate module:
// tests/helpers/fixtures.rs
//
// These are Stellar-format test addresses used in unit tests.
// They are NOT real accounts — they use the correct G.../S... format
// for format validation but are NOT expected to exist on-chain.
pub const TEST_SENDER: &str = "GAHJJJKMOKYE4RVPZEWZTKH5FVI4PA3VL7GK2LFNUBSGBV3UXBOMQKF";
pub const TEST_RECIPIENT: &str = "GBPJPPNLQS2LO27WLMQXMFKTKTOMKQZXLRXDPXAJMKHG2GNIEBDBWGJ";
pub const TEST_TOKEN: &str = "XLM";
pub const TEST_AMOUNT: u64 = 100_0000000; // 100 XLM in stroops
// Stellar key format validation constants
pub const VALID_G_PREFIX: &str = "GAHJJJKMOKYE4RVPZEWZTKH5FVI4PA3VL7GK2LFNUBSGBV3UXBOMQKF";
pub const INVALID_ADDRESS: &str = "not_a_stellar_address";
pub const SHORT_ADDRESS: &str = "GSHORT";
Step 2 — Use mock adapter for unit tests:
The src/adapters/mock module already exists (pub mod mock in src/adapters/mod.rs). Use it in integration tests:
// tests/integration_test.rs
mod helpers;
use helpers::fixtures::*;
use nodus_core_engine::adapters::mock::MockAdapter;
use nodus_core_engine::engine::Engine;
use nodus_core_engine::retry::RetryConfig;
#[tokio::test]
async fn test_payment_initiation_success() {
// Uses mock adapter — no network needed
let adapter = Arc::new(MockAdapter::success("mock_tx_hash_abc123".into()));
let engine = Engine::new(vec![adapter], RetryConfig::new(3, 10));
let result = engine.initiate(
TEST_SENDER.into(),
TEST_RECIPIENT.into(),
TEST_AMOUNT,
TEST_TOKEN.into(),
Urgency::Standard,
).await;
assert!(result.is_ok());
let payment = result.unwrap();
assert_eq!(payment.tx_hash, Some("mock_tx_hash_abc123".into()));
assert_eq!(payment.status, PaymentStatus::Confirmed);
}
Step 3 — Separate integration tests (need live Stellar) from unit tests:
// tests/integration_stellar_test.rs — ONLY runs in CI with real Stellar testnet
//go:build integration (Rust equivalent: cfg(feature = "integration"))
#[cfg(feature = "integration")]
mod stellar_integration {
const STELLAR_SENDER: &str = std::env!("TEST_STELLAR_SENDER",
"Set TEST_STELLAR_SENDER env var for integration tests");
// ...
}
# Cargo.toml
[features]
integration = [] # Run with: cargo test --features integration
Steps to Verify
cargo test runs without any network — mock adapter handles all interactions
cargo test --features integration requires TEST_STELLAR_SENDER env var, fails without it
- Remove hardcoded
"GABC..." strings from tests/integration_test.rs — zero results in grep "GA[A-Z0-9]\{55\}" tests/
- CI
cargo test step passes without Stellar testnet credentials
Problem
tests/integration_test.rscontains hardcoded Stellar testnet addresses in test fixtures. These addresses are testnet-specific and will fail on mainnet or if the test environment changes.Hardcoded addresses like
"GABC...XYZ"(sender),"GDEF...UVW"(recipient), and contract IDs are embedded in the test file. These addresses:Root Cause
Integration tests were written using real Stellar testnet addresses without parameterization or mock infrastructure.
Impact
Fix
Step 1 — Define test constants in a separate module:
Step 2 — Use mock adapter for unit tests:
The
src/adapters/mockmodule already exists (pub mod mockinsrc/adapters/mod.rs). Use it in integration tests:Step 3 — Separate integration tests (need live Stellar) from unit tests:
Steps to Verify
cargo testruns without any network — mock adapter handles all interactionscargo test --features integrationrequiresTEST_STELLAR_SENDERenv var, fails without it"GABC..."strings fromtests/integration_test.rs— zero results ingrep "GA[A-Z0-9]\{55\}" tests/cargo teststep passes without Stellar testnet credentials