use of org.hyperledger.besu.ethereum.core.MessageFrameTestFixture in project besu by hyperledger.
the class SStoreOperationTest method createMessageFrame.
private MessageFrame createMessageFrame(final Address address, final Gas initialGas, final Gas remainingGas) {
final Blockchain blockchain = mock(Blockchain.class);
final WorldStateArchive worldStateArchive = createInMemoryWorldStateArchive();
final WorldUpdater worldStateUpdater = worldStateArchive.getMutable().updater();
final BlockHeader blockHeader = new BlockHeaderTestFixture().buildHeader();
final MessageFrame frame = new MessageFrameTestFixture().address(address).worldUpdater(worldStateUpdater).blockHeader(blockHeader).blockchain(blockchain).initialGas(initialGas).build();
worldStateUpdater.getOrCreate(address).getMutable().setBalance(Wei.of(1));
worldStateUpdater.commit();
frame.setGasRemaining(remainingGas);
return frame;
}
use of org.hyperledger.besu.ethereum.core.MessageFrameTestFixture in project besu by hyperledger.
the class MainnetContractCreationProcessorTest method shouldNotThrowAnExceptionWhenCodeSizeRuleNotAdded.
@Test
public void shouldNotThrowAnExceptionWhenCodeSizeRuleNotAdded() {
processor = new ContractCreationProcessor(gasCalculator, evm, true, Collections.emptyList(), 1, Collections.emptyList());
final Bytes contractCode = Bytes.fromHexString("00".repeat(24 * 1024 + 1));
final MessageFrame messageFrame = new MessageFrameTestFixture().build();
messageFrame.setOutputData(contractCode);
messageFrame.setGasRemaining(100L);
when(gasCalculator.codeDepositGasCost(contractCode.size())).thenReturn(10L);
processor.codeSuccess(messageFrame, OperationTracer.NO_TRACING);
assertThat(messageFrame.getState()).isEqualTo(COMPLETED_SUCCESS);
}
use of org.hyperledger.besu.ethereum.core.MessageFrameTestFixture in project besu by hyperledger.
the class OperationBenchmarkHelper method create.
public static OperationBenchmarkHelper create() throws IOException {
final Path storageDirectory = Files.createTempDirectory("benchmark");
final KeyValueStorage keyValueStorage = new RocksDBKeyValueStorage(new RocksDBConfigurationBuilder().databaseDir(storageDirectory).build(), new NoOpMetricsSystem(), RocksDBMetricsFactory.PUBLIC_ROCKS_DB_METRICS);
final ExecutionContextTestFixture executionContext = ExecutionContextTestFixture.builder().keyValueStorage(keyValueStorage).build();
final MutableBlockchain blockchain = executionContext.getBlockchain();
for (int i = 1; i < 256; i++) {
blockchain.appendBlock(new Block(new BlockHeaderTestFixture().parentHash(blockchain.getChainHeadHash()).number(i).difficulty(Difficulty.ONE).buildHeader(), new BlockBody(emptyList(), emptyList())), emptyList());
}
final MessageFrame messageFrame = new MessageFrameTestFixture().executionContextTestFixture(executionContext).blockHeader(new BlockHeaderTestFixture().parentHash(blockchain.getChainHeadHash()).number(blockchain.getChainHeadBlockNumber() + 1).difficulty(Difficulty.ONE).buildHeader()).build();
return new OperationBenchmarkHelper(storageDirectory, keyValueStorage, messageFrame, blockchain);
}
use of org.hyperledger.besu.ethereum.core.MessageFrameTestFixture in project besu by hyperledger.
the class DebugOperationTracerTest method validMessageFrameBuilder.
private MessageFrameTestFixture validMessageFrameBuilder() {
final BlockHeader blockHeader = new BlockHeaderTestFixture().number(1).buildHeader();
final ReferenceTestBlockchain blockchain = new ReferenceTestBlockchain(blockHeader.getNumber());
return new MessageFrameTestFixture().initialGas(INITIAL_GAS).worldUpdater(worldUpdater).gasPrice(Wei.of(25)).blockHeader(blockHeader).blockchain(blockchain).depth(DEPTH);
}
use of org.hyperledger.besu.ethereum.core.MessageFrameTestFixture in project besu by hyperledger.
the class EstimateGasOperationTracerTest method setUp.
@Before
public void setUp() {
operationTracer = new EstimateGasOperationTracer();
messageFrameTestFixture = new MessageFrameTestFixture();
}
Aggregations