Search in sources :

Example 1 with OperationResult

use of org.hyperledger.besu.evm.operation.Operation.OperationResult in project besu by hyperledger.

the class BaseFeeOperationTest method shouldReturnGasCost.

@Test
public void shouldReturnGasCost() {
    final MessageFrame frame = createMessageFrame(100, Optional.of(Wei.of(5L)));
    final Operation operation = new BaseFeeOperation(gasCalculator);
    final OperationResult result = operation.execute(frame, null);
    assertThat(result.getGasCost().isPresent()).isTrue();
    assertThat(result.getGasCost().getAsLong()).isEqualTo(gasCalculator.getBaseTierGasCost());
    assertSuccessResult(result);
}
Also used : MessageFrame(org.hyperledger.besu.evm.frame.MessageFrame) BaseFeeOperation(org.hyperledger.besu.evm.operation.BaseFeeOperation) OperationResult(org.hyperledger.besu.evm.operation.Operation.OperationResult) Operation(org.hyperledger.besu.evm.operation.Operation) BaseFeeOperation(org.hyperledger.besu.evm.operation.BaseFeeOperation) Test(org.junit.Test)

Example 2 with OperationResult

use of org.hyperledger.besu.evm.operation.Operation.OperationResult in project besu by hyperledger.

the class BaseFeeOperationTest method shouldHaltIfNoBaseFeeInBlockHeader.

@Test
public void shouldHaltIfNoBaseFeeInBlockHeader() {
    final MessageFrame frame = createMessageFrame(100, Optional.empty());
    final Operation operation = new BaseFeeOperation(gasCalculator);
    final OperationResult result = operation.execute(frame, null);
    assertExceptionalHalt(result, ExceptionalHaltReason.INVALID_OPERATION);
}
Also used : MessageFrame(org.hyperledger.besu.evm.frame.MessageFrame) BaseFeeOperation(org.hyperledger.besu.evm.operation.BaseFeeOperation) OperationResult(org.hyperledger.besu.evm.operation.Operation.OperationResult) Operation(org.hyperledger.besu.evm.operation.Operation) BaseFeeOperation(org.hyperledger.besu.evm.operation.BaseFeeOperation) Test(org.junit.Test)

Example 3 with OperationResult

use of org.hyperledger.besu.evm.operation.Operation.OperationResult in project besu by hyperledger.

the class Create2OperationTest method shouldCalculateGasPrice.

@Test
public void shouldCalculateGasPrice() {
    final OperationResult result = operation.execute(messageFrame, evm);
    assertThat(result.getHaltReason()).isEmpty();
    assertThat(result.getGasCost().isPresent()).isTrue();
    assertThat(result.getGasCost().getAsLong()).isEqualTo(expectedGas);
}
Also used : OperationResult(org.hyperledger.besu.evm.operation.Operation.OperationResult) Test(org.junit.Test)

Example 4 with OperationResult

use of org.hyperledger.besu.evm.operation.Operation.OperationResult in project besu by hyperledger.

the class ExtCodeHashOperationTest method istanbulShouldCharge700Gas.

@Test
public void istanbulShouldCharge700Gas() {
    final OperationResult result = operationIstanbul.execute(createMessageFrame(REQUESTED_ADDRESS), null);
    assertThat(result.getGasCost().isPresent()).isTrue();
    assertThat(result.getGasCost().getAsLong()).isEqualTo(700L);
}
Also used : OperationResult(org.hyperledger.besu.evm.operation.Operation.OperationResult) Test(org.junit.Test)

Example 5 with OperationResult

use of org.hyperledger.besu.evm.operation.Operation.OperationResult in project besu by hyperledger.

the class JumpOperationTest method longContractsValidate.

@Test
public void longContractsValidate() {
    final JumpOperation operation = new JumpOperation(gasCalculator);
    final Bytes longCode = Bytes.fromHexString("0x60006000351461001157600050610018565b6101016020525b60016000351461002a5760005061002f565b326020525b60026000351461004157600050610046565b336020525b6003600035146100585760005061005d565b306020525b60046000351461006f57600050610075565b60016020525b60005160005260006020351461008d576000506100b6565b5a600052602051315060165a60005103036000555a600052602051315060165a60005103036001555b6001602035146100c8576000506100f1565b5a6000526020513b5060165a60005103036000555a6000526020513b5060165a60005103036001555b6002602035146101035760005061012c565b5a6000526020513f5060165a60005103036000555a6000526020513f5060165a60005103036001555b60036020351461013e5760005061017a565b6106a5610100525a600052602060006101006020513c60205a60005103036000555a600052602060006101006020513c60205a60005103036001555b00");
    final MessageFrame longContract = createMessageFrameBuilder(100L).pushStackItem(UInt256.fromHexString("0x12c")).code(Code.createLegacyCode(longCode, Hash.hash(longCode))).build();
    longContract.setPC(255);
    final OperationResult result = operation.execute(longContract, evm);
    assertThat(result.getHaltReason()).isEmpty();
}
Also used : Bytes(org.apache.tuweni.bytes.Bytes) JumpOperation(org.hyperledger.besu.evm.operation.JumpOperation) MessageFrame(org.hyperledger.besu.evm.frame.MessageFrame) OperationResult(org.hyperledger.besu.evm.operation.Operation.OperationResult) Test(org.junit.Test)

Aggregations

OperationResult (org.hyperledger.besu.evm.operation.Operation.OperationResult)15 Test (org.junit.Test)14 MessageFrame (org.hyperledger.besu.evm.frame.MessageFrame)10 Bytes (org.apache.tuweni.bytes.Bytes)5 JumpOperation (org.hyperledger.besu.evm.operation.JumpOperation)5 Operation (org.hyperledger.besu.evm.operation.Operation)4 BaseFeeOperation (org.hyperledger.besu.evm.operation.BaseFeeOperation)3 UInt256 (org.apache.tuweni.units.bigints.UInt256)1 TraceFrame (org.hyperledger.besu.ethereum.debug.TraceFrame)1 TraceOptions (org.hyperledger.besu.ethereum.debug.TraceOptions)1 Code (org.hyperledger.besu.evm.Code)1 ExceptionalHaltReason (org.hyperledger.besu.evm.frame.ExceptionalHaltReason)1 OverflowException (org.hyperledger.besu.evm.internal.FixedStack.OverflowException)1 UnderflowException (org.hyperledger.besu.evm.internal.FixedStack.UnderflowException)1 InvalidOperation (org.hyperledger.besu.evm.operation.InvalidOperation)1 SStoreOperation (org.hyperledger.besu.evm.operation.SStoreOperation)1 StopOperation (org.hyperledger.besu.evm.operation.StopOperation)1 VirtualOperation (org.hyperledger.besu.evm.operation.VirtualOperation)1