use of org.hyperledger.besu.evm.frame.MessageFrame in project besu by hyperledger.
the class EstimateGasOperationTracerTest method shouldDetectChangeInDepthDuringExecution.
@Test
public void shouldDetectChangeInDepthDuringExecution() {
final ExecuteOperation noExecutionOperation = mock(ExecuteOperation.class);
assertThat(operationTracer.getMaxDepth()).isEqualTo(0);
final MessageFrame firstFrame = messageFrameTestFixture.depth(0).build();
operationTracer.traceExecution(firstFrame, noExecutionOperation);
assertThat(operationTracer.getMaxDepth()).isEqualTo(0);
final MessageFrame secondFrame = messageFrameTestFixture.depth(1).build();
operationTracer.traceExecution(secondFrame, noExecutionOperation);
assertThat(operationTracer.getMaxDepth()).isEqualTo(1);
final MessageFrame thirdFrame = messageFrameTestFixture.depth(1).build();
operationTracer.traceExecution(thirdFrame, noExecutionOperation);
assertThat(operationTracer.getMaxDepth()).isEqualTo(1);
final MessageFrame fourthFrame = messageFrameTestFixture.depth(2).build();
operationTracer.traceExecution(fourthFrame, noExecutionOperation);
assertThat(operationTracer.getMaxDepth()).isEqualTo(2);
final MessageFrame fifthFrame = messageFrameTestFixture.depth(0).build();
operationTracer.traceExecution(fifthFrame, noExecutionOperation);
assertThat(operationTracer.getMaxDepth()).isEqualTo(2);
}
use of org.hyperledger.besu.evm.frame.MessageFrame 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.frame.MessageFrame in project besu by hyperledger.
the class BaseFeeOperationTest method createMessageFrame.
private MessageFrame createMessageFrame(final long initialGas, final Optional<Wei> baseFee) {
final MessageFrame frame = mock(MessageFrame.class);
when(frame.getRemainingGas()).thenReturn(initialGas);
final BlockHeader blockHeader = mock(BlockHeader.class);
when(blockHeader.getBaseFee()).thenReturn(baseFee);
when(frame.getBlockValues()).thenReturn(blockHeader);
return frame;
}
use of org.hyperledger.besu.evm.frame.MessageFrame 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.frame.MessageFrame in project besu by hyperledger.
the class ConstantinopleSStoreOperationGasCostTest method shouldCalculateGasAccordingToEip1283.
@Test
public void shouldCalculateGasAccordingToEip1283() {
final long gasLimit = 1_000_000;
final MessageFrame frame = codeExecutor.executeCode(code, gasLimit, account -> account.setStorageValue(UInt256.ZERO, UInt256.valueOf(originalValue)));
assertThat(frame.getState()).isEqualTo(State.COMPLETED_SUCCESS);
assertThat(frame.getRemainingGas()).isEqualTo(gasLimit - expectedGasUsed);
assertThat(frame.getGasRefund()).isEqualTo(expectedGasRefund);
}
Aggregations