diff --git a/protocol/testutil/app/app.go b/protocol/testutil/app/app.go index 114b8250a6..2fdc41610d 100644 --- a/protocol/testutil/app/app.go +++ b/protocol/testutil/app/app.go @@ -399,12 +399,6 @@ func (tApp *TestApp) AdvanceToBlock( return tApp.App.NewContext(true, tApp.header) } - // First advance to the prior block using the current block time. This ensures that we only update the time on - // the requested block. - if int64(block)-tApp.header.Height > 1 && options.BlockTime != tApp.header.Time { - tApp.AdvanceToBlock(block-1, options) - } - // Ensure that we grab the lock so that we can read and write passingCheckTxs correctly. tApp.passingCheckTxsMtx.Lock() defer tApp.passingCheckTxsMtx.Unlock() @@ -413,7 +407,10 @@ func (tApp *TestApp) AdvanceToBlock( for tApp.App.LastBlockHeight() < int64(block) { tApp.panicIfChainIsHalted() tApp.header.Height = tApp.App.LastBlockHeight() + 1 - tApp.header.Time = options.BlockTime + // By default, only update block time at the requested block. + if tApp.header.Height == int64(block) { + tApp.header.Time = options.BlockTime + } tApp.header.LastCommitHash = tApp.App.LastCommitID().Hash tApp.header.NextValidatorsHash = tApp.App.LastCommitID().Hash diff --git a/protocol/x/bridge/app_test.go b/protocol/x/bridge/app_test.go index ece225dedc..61251b0a98 100644 --- a/protocol/x/bridge/app_test.go +++ b/protocol/x/bridge/app_test.go @@ -142,6 +142,7 @@ func TestBridge_Success(t *testing.T) { genesisState.SafetyParams = tc.safetyParams }, ) + genesis.GenesisTime = tc.blockTime return genesis }).Build() ctx := tApp.InitChain() @@ -178,9 +179,7 @@ func TestBridge_Success(t *testing.T) { // Advance to block right before bridge completion, if necessary. if blockHeightOfBridgeCompletion-1 > uint32(ctx.BlockHeight()) { - ctx = tApp.AdvanceToBlock(blockHeightOfBridgeCompletion-1, testapp.AdvanceToBlockOptions{ - BlockTime: tc.blockTime.Add(-time.Second * 1), - }) + ctx = tApp.AdvanceToBlock(blockHeightOfBridgeCompletion-1, testapp.AdvanceToBlockOptions{}) } // Verify that balances have not changed yet. for _, event := range tc.bridgeEvents { @@ -194,9 +193,7 @@ func TestBridge_Success(t *testing.T) { // Verify that balances are updated, if bridge events were proposed, at the block of // bridge completion. - ctx = tApp.AdvanceToBlock(blockHeightOfBridgeCompletion, testapp.AdvanceToBlockOptions{ - BlockTime: tc.blockTime, - }) + ctx = tApp.AdvanceToBlock(blockHeightOfBridgeCompletion, testapp.AdvanceToBlockOptions{}) for _, event := range tc.bridgeEvents { balance := tApp.App.BankKeeper.GetBalance( ctx, diff --git a/protocol/x/stats/keeper/keeper_test.go b/protocol/x/stats/keeper/keeper_test.go index 75e9d370aa..51d97277f2 100644 --- a/protocol/x/stats/keeper/keeper_test.go +++ b/protocol/x/stats/keeper/keeper_test.go @@ -197,12 +197,13 @@ func TestExpireOldStats(t *testing.T) { }) windowDuration := tApp.App.StatsKeeper.GetWindowDuration(ctx) // 5 epochs are out of the window - ctx = tApp.AdvanceToBlock(100, testapp.AdvanceToBlockOptions{ + tApp.AdvanceToBlock(3, testapp.AdvanceToBlockOptions{ BlockTime: time.Unix(0, 0). Add(windowDuration). Add((time.Duration(5*epochstypes.StatsEpochDuration) + 1) * time.Second). UTC(), }) + ctx = tApp.AdvanceToBlock(100, testapp.AdvanceToBlockOptions{}) k := tApp.App.StatsKeeper // Create a bunch of EpochStats.