Skip to content

Commit

Permalink
test: protect tests from bad random height (#763)
Browse files Browse the repository at this point in the history
Co-authored-by: Amir Babazadeh <[email protected]>
  • Loading branch information
b00f and amirvalhalla authored Oct 20, 2023
1 parent 11299c6 commit 1fc2f15
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion execution/executor/transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (td *testData) checkTotalCoin(t *testing.T, fee int64) {
}

func (td *testData) randomAmountAndFee(min int64, max int64) (int64, int64) {
amt := td.RandInt64NonZero(max)
amt := td.RandInt64NonZero(max - 1) // To make sure amt+fee is less than max
for amt < min {
amt = td.RandInt64NonZero(max)
}
Expand Down
4 changes: 2 additions & 2 deletions util/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ func (ts *TestSuite) RandIntNonZero(max int) int {
return ts.RandInt(max) + 1
}

// RandHeight returns a random number between [1, 1,000,000] for block height.
// RandHeight returns a random number between [1000, 1000000] for block height.
func (ts *TestSuite) RandHeight() uint32 {
return ts.RandUint32NonZero(1e6)
return ts.RandUint32NonZero(1e6-1000) + 1000
}

// RandRound returns a random number between [0, 10) for block round.
Expand Down

0 comments on commit 1fc2f15

Please sign in to comment.