Skip to content

Commit

Permalink
test: Run unmodified IAVL tree test on legacy statedb
Browse files Browse the repository at this point in the history
  • Loading branch information
drklee3 committed Mar 13, 2024
1 parent 3613d63 commit 9b2d90a
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions x/evm/keeper/state_transition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -897,10 +897,11 @@ func (suite *KeeperTestSuite) TestAccountNumberOrder() {
accNum1 := accounts[i].GetAccountNumber()
accNum2 := accounts[i+1].GetAccountNumber()

suite.Require().Less(
suite.Require().Lessf(
accNum1,
accNum2,
"account numbers should be ascending order",
"account numbers should be ascending order, %v",
accounts,
)
suite.Require().Equalf(
accNum1+1,
Expand Down Expand Up @@ -1086,7 +1087,40 @@ func (suite *KeeperTestSuite) TestNoopStateChange_UnmodifiedIAVLTree() {
common.Bytes2Hex(commitID2.Hash),
"evm store should be unchanged",
)
})

suite.Run(tt.name+"_legacy", func() {
// reset
suite.SetupTest()

db := legacystatedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig)
tt.initializeState(db)

suite.Require().NoError(db.Commit())
suite.Commit()

store := suite.App.CommitMultiStore().GetStore(suite.App.GetKey(types.StoreKey))
iavlStore := store.(*iavl.Store)
commitID1 := iavlStore.LastCommitID()

// New statedb that should not modify the underlying store
db = legacystatedb.New(suite.Ctx, suite.App.EvmKeeper, emptyTxConfig)
tt.maleate(db)

suite.Require().NoError(db.Commit())
suite.Commit()

commitID2 := iavlStore.LastCommitID()

// We can compare the commitIDs since this is *only* the x/evm store which
// doesn't change between blocks without state changes. Any version change,
// e.g. no-op change that was written when it shouldn't, will modify the
// hash.
suite.Require().Equal(
common.Bytes2Hex(commitID1.Hash),
common.Bytes2Hex(commitID2.Hash),
"evm store should be unchanged",
)
})
}
}
Expand Down

0 comments on commit 9b2d90a

Please sign in to comment.