mpt: allow to remove non-existent keys in batch

This bug was here before batch were intoduced.
`Delete` is allowed to be called on missing keys with
HALT result, MPT needs to take this into account.
This commit is contained in:
Evgeniy Stratonikov 2021-02-17 12:26:32 +03:00
parent 4d0681d898
commit 0cb6ec7345
6 changed files with 37 additions and 15 deletions

View file

@ -1591,3 +1591,15 @@ func TestInvalidNotification(t *testing.T) {
require.Nil(t, aer.Stack[0])
require.Equal(t, stackitem.InteropT, aer.Stack[1].Type())
}
// Test that deletion of non-existent doesn't result in error in tx or block addition.
func TestMPTDeleteNoKey(t *testing.T) {
bc := newTestChain(t)
defer bc.Close()
cs, _ := getTestContractState(bc)
require.NoError(t, bc.contracts.Management.PutContractState(bc.dao, cs))
aer, err := invokeContractMethod(bc, 1_00000000, cs.Hash, "delValue", "non-existent-key")
require.NoError(t, err)
require.Equal(t, vm.HaltState, aer.VMState)
}