Search in sources :

Example 1 with MessageFrameTestFixture

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;
}
Also used : BlockHeaderTestFixture(org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture) InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive(org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive) WorldStateArchive(org.hyperledger.besu.ethereum.worldstate.WorldStateArchive) Blockchain(org.hyperledger.besu.ethereum.chain.Blockchain) WorldUpdater(org.hyperledger.besu.evm.worldstate.WorldUpdater) MessageFrame(org.hyperledger.besu.evm.frame.MessageFrame) MessageFrameTestFixture(org.hyperledger.besu.ethereum.core.MessageFrameTestFixture) BlockHeader(org.hyperledger.besu.ethereum.core.BlockHeader)

Example 2 with MessageFrameTestFixture

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);
}
Also used : ContractCreationProcessor(org.hyperledger.besu.evm.processor.ContractCreationProcessor) Bytes(org.apache.tuweni.bytes.Bytes) MessageFrame(org.hyperledger.besu.evm.frame.MessageFrame) MessageFrameTestFixture(org.hyperledger.besu.ethereum.core.MessageFrameTestFixture) Test(org.junit.Test)

Example 3 with MessageFrameTestFixture

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);
}
Also used : Path(java.nio.file.Path) BlockBody(org.hyperledger.besu.ethereum.core.BlockBody) RocksDBKeyValueStorage(org.hyperledger.besu.plugin.services.storage.rocksdb.unsegmented.RocksDBKeyValueStorage) KeyValueStorage(org.hyperledger.besu.plugin.services.storage.KeyValueStorage) MessageFrame(org.hyperledger.besu.evm.frame.MessageFrame) MessageFrameTestFixture(org.hyperledger.besu.ethereum.core.MessageFrameTestFixture) BlockHeaderTestFixture(org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) RocksDBKeyValueStorage(org.hyperledger.besu.plugin.services.storage.rocksdb.unsegmented.RocksDBKeyValueStorage) RocksDBConfigurationBuilder(org.hyperledger.besu.plugin.services.storage.rocksdb.configuration.RocksDBConfigurationBuilder) ExecutionContextTestFixture(org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture) Block(org.hyperledger.besu.ethereum.core.Block) MutableBlockchain(org.hyperledger.besu.ethereum.chain.MutableBlockchain)

Example 4 with MessageFrameTestFixture

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);
}
Also used : BlockHeaderTestFixture(org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture) MessageFrameTestFixture(org.hyperledger.besu.ethereum.core.MessageFrameTestFixture) BlockHeader(org.hyperledger.besu.ethereum.core.BlockHeader) ReferenceTestBlockchain(org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain)

Example 5 with MessageFrameTestFixture

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();
}
Also used : EstimateGasOperationTracer(org.hyperledger.besu.evm.tracing.EstimateGasOperationTracer) MessageFrameTestFixture(org.hyperledger.besu.ethereum.core.MessageFrameTestFixture) Before(org.junit.Before)

Aggregations

MessageFrameTestFixture (org.hyperledger.besu.ethereum.core.MessageFrameTestFixture)13 MessageFrame (org.hyperledger.besu.evm.frame.MessageFrame)11 Bytes (org.apache.tuweni.bytes.Bytes)7 BlockHeaderTestFixture (org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture)6 ContractCreationProcessor (org.hyperledger.besu.evm.processor.ContractCreationProcessor)6 Test (org.junit.Test)6 BlockHeader (org.hyperledger.besu.ethereum.core.BlockHeader)4 Blockchain (org.hyperledger.besu.ethereum.chain.Blockchain)2 InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive (org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive)2 WorldStateArchive (org.hyperledger.besu.ethereum.worldstate.WorldStateArchive)2 WorldUpdater (org.hyperledger.besu.evm.worldstate.WorldUpdater)2 Path (java.nio.file.Path)1 MutableBlockchain (org.hyperledger.besu.ethereum.chain.MutableBlockchain)1 Block (org.hyperledger.besu.ethereum.core.Block)1 BlockBody (org.hyperledger.besu.ethereum.core.BlockBody)1 ExecutionContextTestFixture (org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture)1 ReferenceTestBlockchain (org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain)1 EstimateGasOperationTracer (org.hyperledger.besu.evm.tracing.EstimateGasOperationTracer)1 NoOpMetricsSystem (org.hyperledger.besu.metrics.noop.NoOpMetricsSystem)1 KeyValueStorage (org.hyperledger.besu.plugin.services.storage.KeyValueStorage)1