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);
}
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);
}
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);
}
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);
}
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();
}
Aggregations