Skip to content

Commit 97bf95f

Browse files
committed
itest: fix assertAssetBalance
`assertAssetBalance` would not return an error in the edge case where the requested `assetID` had no balance but the `expectedBalance` was non-zero. This commit fixes the behavior in that specific edge case.
1 parent 0b45880 commit 97bf95f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

itest/assets_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,17 +1309,23 @@ func assertAssetBalance(t *testing.T, client *tapClient, assetID []byte,
13091309
return err
13101310
}
13111311

1312+
assetIDFound := false
13121313
for _, balance := range assetIDBalances.AssetBalances {
13131314
if !bytes.Equal(balance.AssetGenesis.AssetId, assetID) {
13141315
continue
13151316
}
13161317

1318+
assetIDFound = true
13171319
if expectedBalance != balance.Balance {
13181320
return fmt.Errorf("expected balance %d, got %d",
13191321
expectedBalance, balance.Balance)
13201322
}
13211323
}
13221324

1325+
if expectedBalance > 0 && !assetIDFound {
1326+
return fmt.Errorf("expected balance %d, got 0",
1327+
expectedBalance)
1328+
}
13231329
return nil
13241330
}, shortTimeout)
13251331
if err != nil {

0 commit comments

Comments
 (0)