Esempio n. 1
0
def test_get_gas_remaining_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 computation.is_error
    assert computation.get_gas_remaining() == 100
Esempio n. 2
0
def test_output_with_revert(computation):
    # Trigger an out of gas error causing output to be b''
    computation.output = b'1'
    with computation:
        raise Revert('Triggered VMError for tests')
    assert computation.is_error
    assert computation.output == b'1'
Esempio n. 3
0
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
Esempio n. 4
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() == ()
Esempio n. 5
0
def revert(computation):
    start_position, size = computation.stack_pop(num_items=2, type_hint=constants.UINT256)

    computation.extend_memory(start_position, size)

    output = computation.memory_read(start_position, size)
    computation.output = bytes(output)
    raise Revert(computation.output)
Esempio n. 6
0
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
Esempio n. 7
0
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