Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'include_leased' flag to ListBalances #1119

Merged
merged 8 commits into from
Sep 23, 2024
16 changes: 16 additions & 0 deletions itest/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1913,7 +1913,9 @@ func AssertAssetBalances(t *testing.T, client taprpc.TaprootAssetsClient,

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

var totalBalance uint64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: shouldn't this commit precede the previous itest: test balances with an without leased flag

for _, balance := range assetIDBalances.AssetBalances {
totalBalance += balance.Balance
for _, rpcAsset := range allAssets {
balanceGen := balance.AssetGenesis
targetGen := rpcAsset.AssetGenesis
Expand All @@ -1932,6 +1934,20 @@ func AssertAssetBalances(t *testing.T, client taprpc.TaprootAssetsClient,
}
}

// We should also ensure that the total balance returned by
// `ListBalances` matches the total balance returned by `ListAssets`.
assetList, err := client.ListAssets(ctxt, &taprpc.ListAssetRequest{
IncludeLeased: includeLeased,
})
require.NoError(t, err)

var totalAssetListBalance uint64
for _, asset := range assetList.Assets {
totalAssetListBalance += asset.Amount
}

require.Equal(t, totalBalance, totalAssetListBalance)

// We'll also ensure that we're able to get the balance by key group
// for all the assets that have one specified.
groupBalanceReq := &taprpc.ListBalancesRequest_GroupKey{
Expand Down