Skip to content

[Bug] AccountHandle::token_balance() returns 0 for freshly minted MockToken balances #776

Description

@ekelemepraise-code

Summary

After minting tokens to an account using MockToken::mint(), calling account.token_balance(&token) returns 0 instead of the minted amount. The balance is only visible through token.balance(&account.address()).

Steps to Reproduce

let env = MockEnv::builder()
    .with_account("alice", Stroops::xlm(1_000))
    .build();

let usdc = MockToken::new(&env, "USDC", 6);
let alice = env.account("alice");

usdc.mint(&alice.address(), 5_000_000);

// Bug: returns 0
let balance = alice.token_balance(&usdc);
assert_eq!(balance, 5_000_000); // FAILS

// Workaround: query directly on token
let balance2 = usdc.balance(&alice.address());
assert_eq!(balance2, 5_000_000); // passes

Root Cause (Hypothesis)

AccountHandle::token_balance may hold a stale reference or query the wrong storage key. Needs investigation in builders.rs.

Acceptance Criteria

  • AccountHandle::token_balance(&token) returns live balance
  • Regression test added
  • Docs updated to clarify the difference between the two query paths

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions