`get_asset_balance` still return 0 after `setup_custom_assets_coins`

I set up two assets for my wallet. but the when i get the balance, it shows 0.

setup_contract_test!(Wallets("wallet1"));
let coins = setup_custom_assets_coins(wallet1.address(), &assest_configs);

// balance is zero
let balance = wallet1.get_asset_balance(&coins[0].asset_id).await.unwrap();

I printed out the coins[0]. it actually has amount.

Coin { amount: 1000000000, block_created: 0, asset_id: 0202020202020202020202020202020202020202020202020202020202020202, utxo_id: UtxoId { tx_id: a745059a83773aa152285b2d5c8b4a0a822217ba8ae75908f78b744b75f05e2d, output_index: 0 }, maturity: 0, owner: Bech32Address { hrp: "fuel", hash: 09c0b2d1a486c439a87bcba6b46a7a1a23f3897cc83a94521a96da5c23bc58db }, status: Unspent }

why does the get_asset_balance returns 0?

Can you share the full file? It would make it easier to debug here

1 Like

this the code.

#[tokio::test]
async fn test_balances() {
    setup_contract_test!(Wallets("wallet"));
    let asset1: AssetId = AssetId::new([1; 32]);
    let asset2: AssetId = AssetId::new([2; 32]);

    let assest_configs = [asset1, asset2].map(|asset| AssetConfig {
        id: asset, 
        num_coins: 1,
        coin_amount: 1_000_000_000
    });

    let coins = setup_custom_assets_coins(wallet.address(), &assest_configs);

    println!("{:?}", coins[0]);
    println!("{:?}", coins[1]);

    let balance0 = wallet.get_asset_balance(&coins[0].asset_id).await.unwrap();
    println!("balance0: {}", balance0); // the result is 0
}