Skip to content

Commit cd7c49b

Browse files
committed
avoid division by zero.
1 parent 3ac481e commit cd7c49b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ledger/accountdb_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func randomFullAccountData(rewardsLevel, lastCreatableID uint64) (basics.Account
9797
data.AssetParams[basics.AssetIndex(lastCreatableID)] = ap
9898
}
9999
}
100-
if 1 == (crypto.RandUint64() % 2) {
100+
if 1 == (crypto.RandUint64()%2) && lastCreatableID > 0 {
101101
// if account owns assets
102102
data.Assets = make(map[basics.AssetIndex]basics.AssetHolding)
103103
ownedAssetsCount := crypto.RandUint64()%20 + 1
@@ -113,7 +113,7 @@ func randomFullAccountData(rewardsLevel, lastCreatableID uint64) (basics.Account
113113
crypto.RandBytes(data.AuthAddr[:])
114114
}
115115

116-
if 1 == (crypto.RandUint64() % 3) {
116+
if 1 == (crypto.RandUint64()%3) && lastCreatableID > 0 {
117117
data.AppLocalStates = make(map[basics.AppIndex]basics.AppLocalState)
118118
appStatesCount := crypto.RandUint64()%20 + 1
119119
for i := uint64(0); i < appStatesCount; i++ {

0 commit comments

Comments
 (0)