def test_get_gas_refund_with_revert(computation): # Trigger an out of gas error causing get gas refund to be 0 computation._gas_meter.refund_gas(100) with computation: raise Revert('Triggered VMError for tests') assert computation.is_error assert computation.get_gas_refund() == 0
def test_get_log_entries_with_revert(computation): # Trigger an out of gas error causing get log entries to be () computation.add_log_entry(CANONICAL_ADDRESS_A, [1, 2, 3], b'') with computation: raise Revert('Triggered VMError for tests') assert computation.is_error assert computation.get_log_entries() == ()
def revert(computation: BaseComputation) -> None: start_position, size = computation.stack_pop_ints(2) computation.extend_memory(start_position, size) computation.output = computation.memory_read_bytes(start_position, size) raise Revert(computation.output)
def revert(computation: BaseComputation) -> None: start_position, size = computation.stack_pop(num_items=2, type_hint=constants.UINT256) computation.extend_memory(start_position, size) computation.output = computation.memory_read_bytes(start_position, size) raise Revert(computation.output)
def test_should_erase_return_data_with_revert(computation): assert computation.get_gas_remaining() == 100 computation.return_data = b'\x1337' # Trigger a Revert which should not erase return data with computation: raise Revert('Triggered VMError for tests') assert not computation.should_erase_return_data assert computation.return_data == b'\x1337'
def test_should_burn_gas_with_revert(computation): assert computation.get_gas_remaining() == 100 # Trigger a Revert which should not burn gas with computation: raise Revert('Triggered VMError for tests') assert not computation.should_burn_gas assert computation.get_gas_used() == 0 assert computation.get_gas_remaining() == 100
def test_get_gas_used_with_revert(computation): # Trigger an out of gas error causing get gas used to be 150 computation.consume_gas(3, reason='testing') computation.consume_gas(2, reason='testing') with computation: raise Revert('Triggered VMError for tests') assert computation.is_error assert computation.get_gas_used() == 5
def test_should_erase_return_data_with_revert(computation): assert computation.get_gas_remaining() == 100 # Trigger an out of gas error causing get gas remaining to be 0 with computation: raise Revert('Triggered VMError for tests') assert not computation.should_erase_return_data