diff --git a/manticore/ethereum/manticore.py b/manticore/ethereum/manticore.py index f2e71f91e..f3d410bc1 100644 --- a/manticore/ethereum/manticore.py +++ b/manticore/ethereum/manticore.py @@ -1425,16 +1425,13 @@ def _terminate_state_callback(self, state, e): # generate a testcase. FIXME This should be configurable as REVERT and # THROW; it actually changes the balance and nonce? of some accounts - if tx.result in {"SELFDESTRUCT", "REVERT", "THROW", "TXERROR"}: + if tx.return_value == 0: pass - elif tx.result in {"RETURN", "STOP"}: + else: # if not a revert, we save the state for further transactions with self.locked_context("ethereum.saved_states", list) as saved_states: saved_states.append(state.id) - else: - logger.debug("Exception in state. Discarding it") - # Callbacks def _did_evm_execute_instruction_callback(self, state, instruction, arguments, result): """ INTERNAL USE """ diff --git a/tests/ethereum/test_general.py b/tests/ethereum/test_general.py index f77c5a58a..ae04a9908 100644 --- a/tests/ethereum/test_general.py +++ b/tests/ethereum/test_general.py @@ -1686,6 +1686,23 @@ def test_gas_check(self): result = str(e) self.assertEqual(result, "SELFDESTRUCT") + def test_selfdestruct(self): + with disposable_mevm() as m: + asm_acc = """ PUSH1 0x0 + SELFDESTRUCT + """ + m.create_account( + address=0x111111111111111111111111111111111111111, code=EVMAsm.assemble(asm_acc) + ) + m.create_account(address=0x222222222222222222222222222222222222222) + symbolic_data = m.make_symbolic_buffer(320) + m.transaction( + caller=0x222222222222222222222222222222222222222, + address=0x111111111111111111111111111111111111111, + data=symbolic_data, + value=0, + ) + self.assertEqual(m.count_ready_states(), 1) class EthPluginTests(unittest.TestCase): def test_FilterFunctions_fallback_function_matching(self):