Skip to content

Soroban test suite fails due to removed Address::random API in soroban-sdk v22 #26

@samjay8

Description

@samjay8

Title: fix: Soroban test suite fails due to removed Address::random API in soroban-sdk v22

Labels: bug, backend, testing, priority-high

Description:
The vaultlink-invoice-registry contract test suite fails to
compile because the test file uses Address::random(&env),
which no longer exists in soroban-sdk v22.0.11.

This causes the contract tests to fail during compilation before
any test execution occurs.

Error:

error[E0599]: no function or associated item named `random`
found for struct `soroban_sdk::Address` in the current scope

--> test.rs:15:31

15 | let originator = Address::random(&env);
|                               ^^^^^^

The SDK upgrade introduced breaking API changes and removed
Address::random, but the tests still rely on the old API.

Additional warnings were also emitted:

  • unused imports (Invoice, Symbol)
  • deprecated Env::register_contract usage

This is a critical issue because contract tests are currently
unable to compile or run, leaving invoice registry functionality
untested.

What Needs to Be Done:

Option A — Replace Address::random with generated test accounts (preferred):

  • Open test.rs

  • Replace:

    let originator = Address::random(&env);
  • With a valid Soroban SDK v22-compatible address generation
    approach, such as:

    let originator = env.accounts().generate();

    or another officially supported testing utility

  • Verify all tests using random addresses are updated

  • Ensure generated addresses are properly authorized in tests

Option B — Downgrade soroban-sdk to a compatible version:

  • If the project intentionally depends on older APIs,
    downgrade soroban-sdk to a version where
    Address::random still exists
  • Ensure all Soroban-related dependencies remain version-aligned
  • Rebuild and rerun tests after downgrade

Additional Cleanup:

  • Replace deprecated:
    env.register_contract(None, InvoiceRegistryContract);
    with:
    env.register(...)
  • Remove unused imports:
    Invoice
    Symbol

Whichever option is chosen must keep all Soroban dependencies
consistent across the workspace to avoid SDK compatibility issues.

Key Files:

  • test.rs
  • Cargo.toml
  • Workspace Cargo.toml (if using workspace dependencies)
  • Any shared Soroban contract testing utilities

Acceptance Criteria:

  • cargo test runs without compilation errors
  • All invoice registry contract tests execute successfully
  • No deprecated Soroban SDK APIs remain in test files
  • No unused import warnings remain
  • Soroban SDK versions are consistent across the workspace
  • Existing passing tests continue to pass

Branch: fix/soroban-address-random-sdk-v22

Commit:

fix(test): replace removed Address::random API and update Soroban v22 test compatibility

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions