Skip to content

Commit 2cae80f

Browse files
committed
itest: incl. ListAssets in AssertAssetBalances
Since we now have the same flags for the `ListAssets` and `ListBalances` calls, we add a check that makes sure the sum of all assets returned by `ListAssets` matches the sum returned in `ListBalances`.
1 parent d9fb682 commit 2cae80f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

itest/assertions.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,9 @@ func AssertAssetBalances(t *testing.T, client taprpc.TaprootAssetsClient,
19131913

19141914
require.Equal(t, len(allAssets), len(assetIDBalances.AssetBalances))
19151915

1916+
var totalBalance uint64
19161917
for _, balance := range assetIDBalances.AssetBalances {
1918+
totalBalance += balance.Balance
19171919
for _, rpcAsset := range allAssets {
19181920
balanceGen := balance.AssetGenesis
19191921
targetGen := rpcAsset.AssetGenesis
@@ -1932,6 +1934,20 @@ func AssertAssetBalances(t *testing.T, client taprpc.TaprootAssetsClient,
19321934
}
19331935
}
19341936

1937+
// We should also ensure that the total balance returned by
1938+
// `ListBalances` matches the total balance returned by `ListAssets`.
1939+
assetList, err := client.ListAssets(ctxt, &taprpc.ListAssetRequest{
1940+
IncludeLeased: includeLeased,
1941+
})
1942+
require.NoError(t, err)
1943+
1944+
var totalAssetListBalance uint64
1945+
for _, asset := range assetList.Assets {
1946+
totalAssetListBalance += asset.Amount
1947+
}
1948+
1949+
require.Equal(t, totalBalance, totalAssetListBalance)
1950+
19351951
// We'll also ensure that we're able to get the balance by key group
19361952
// for all the assets that have one specified.
19371953
groupBalanceReq := &taprpc.ListBalancesRequest_GroupKey{

0 commit comments

Comments
 (0)