From 29a4996a4f84ff98c10f18420c8dc2b2b0d2df55 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Thu, 22 Feb 2024 12:19:07 -0800 Subject: [PATCH] test: Add case for non-empty noop state change --- x/evm/statedb/statedb_test.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/x/evm/statedb/statedb_test.go b/x/evm/statedb/statedb_test.go index 655d2ffb59..3cbedae2bb 100644 --- a/x/evm/statedb/statedb_test.go +++ b/x/evm/statedb/statedb_test.go @@ -229,11 +229,23 @@ func (suite *StateDBTestSuite) TestState() { db.SetState(address, key1, common.Hash{}) }, map[common.Hash]common.Hash{}}, - {"noop state change", func(db *statedb.StateDB) { + {"noop state change - empty", func(db *statedb.StateDB) { db.SetState(address, key1, value1) db.SetState(address, key1, common.Hash{}) }, map[common.Hash]common.Hash{}}, + {"noop state change - non-empty", func(db *statedb.StateDB) { + // Start with non-empty committed state + db.SetState(address, key1, value1) + suite.Require().NoError(db.Commit()) + + db.SetState(address, key1, common.Hash{}) + db.SetState(address, key1, value1) + }, map[common.Hash]common.Hash{ + // Shouldn't be modified - Commit() may still write it again though + key1: value1, + }}, + {"set state", func(db *statedb.StateDB) { // check empty initial state suite.Require().Equal(common.Hash{}, db.GetState(address, key1))