Skip to content

Commit

Permalink
fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
KonradStaniec committed Jan 24, 2025
1 parent 2b8c528 commit 8d25635
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions x/btcstaking/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func FuzzCreateBTCDelegationWithParamsFromBtcHeight(f *testing.F) {
r := rand.New(rand.NewSource(time.Now().Unix()))
ctrl := gomock.NewController(t)
defer ctrl.Finish()

btcTipHeight := uint32(30)
// mock BTC light client and BTC checkpoint modules
btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl)
btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl)
Expand All @@ -281,14 +281,16 @@ func FuzzCreateBTCDelegationWithParamsFromBtcHeight(f *testing.F) {
currentParams := versionedParams.Params

maxGapBlocksBetweenParams := datagen.RandomUInt32(r, 100) + 100
expectedParamsBlockHeight := datagen.RandomUInt32(r, maxGapBlocksBetweenParams) + currentParams.BtcActivationHeight + 1
// we are adding btcTipHeight so that delegation will always be included
// after the initial tip height
expectedParamsBlockHeight := btcTipHeight + datagen.RandomUInt32(r, maxGapBlocksBetweenParams) + currentParams.BtcActivationHeight + 1
expectedParamsVersion := versionedParams.Version + 1

currentParams.BtcActivationHeight = expectedParamsBlockHeight
err := k.SetParams(ctx, currentParams)
require.NoError(t, err)

nextBtcActivationHeight := datagen.RandomUInt32(r, maxGapBlocksBetweenParams) + currentParams.BtcActivationHeight + 1
nextBtcActivationHeight := btcTipHeight + datagen.RandomUInt32(r, maxGapBlocksBetweenParams) + currentParams.BtcActivationHeight + 1
currentParams.BtcActivationHeight = nextBtcActivationHeight
err = k.SetParams(ctx, currentParams)
require.NoError(t, err)
Expand Down Expand Up @@ -319,7 +321,7 @@ func FuzzCreateBTCDelegationWithParamsFromBtcHeight(f *testing.F) {
false,
false,
btcBlockHeight,
30,
btcTipHeight,
)
h.NoError(err)
require.NotNil(t, btcDel.ParamsVersion, expectedParamsVersion)
Expand Down

0 comments on commit 8d25635

Please sign in to comment.