Search in sources :

Example 1 with BlockchainImporter

use of org.hyperledger.besu.ethereum.api.jsonrpc.BlockchainImporter in project besu by hyperledger.

the class EthGetBlockByNumberLatestDesyncIntegrationTest method setUpOnce.

@BeforeAll
public static void setUpOnce() throws Exception {
    final String genesisJson = Resources.toString(BlockTestUtil.getTestGenesisUrl(), Charsets.UTF_8);
    BlockchainImporter importer = new BlockchainImporter(BlockTestUtil.getTestBlockchainUrl(), genesisJson);
    MutableBlockchain chain = InMemoryKeyValueStorageProvider.createInMemoryBlockchain(importer.getGenesisBlock());
    WorldStateArchive state = InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive();
    importer.getGenesisState().writeStateTo(state.getMutable());
    ProtocolContext context = new ProtocolContext(chain, state, null);
    for (final Block block : importer.getBlocks()) {
        final ProtocolSchedule protocolSchedule = importer.getProtocolSchedule();
        final ProtocolSpec protocolSpec = protocolSchedule.getByBlockNumber(block.getHeader().getNumber());
        final BlockImporter blockImporter = protocolSpec.getBlockImporter();
        blockImporter.importBlock(context, block, HeaderValidationMode.FULL);
    }
    methodsFactorySynced = new JsonRpcTestMethodsFactory(importer, chain, state, context);
    WorldStateArchive unsynced = mock(WorldStateArchive.class);
    when(unsynced.isWorldStateAvailable(any(Hash.class), any(Hash.class))).thenReturn(false);
    methodsFactoryDesynced = new JsonRpcTestMethodsFactory(importer, chain, unsynced, context);
    WorldStateArchive midSync = mock(WorldStateArchive.class);
    when(midSync.isWorldStateAvailable(any(Hash.class), any(Hash.class))).thenReturn(true);
    Synchronizer synchronizer = mock(Synchronizer.class);
    SyncStatus status = mock(SyncStatus.class);
    when(status.getCurrentBlock()).thenReturn(// random choice for current sync state.
    ARBITRARY_SYNC_BLOCK);
    when(synchronizer.getSyncStatus()).thenReturn(Optional.of(status));
    methodsFactoryMidDownload = new JsonRpcTestMethodsFactory(importer, chain, midSync, context, synchronizer);
}
Also used : Synchronizer(org.hyperledger.besu.ethereum.core.Synchronizer) BlockchainImporter(org.hyperledger.besu.ethereum.api.jsonrpc.BlockchainImporter) SyncStatus(org.hyperledger.besu.plugin.data.SyncStatus) ProtocolSchedule(org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule) Hash(org.hyperledger.besu.datatypes.Hash) BlockImporter(org.hyperledger.besu.ethereum.core.BlockImporter) JsonRpcTestMethodsFactory(org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcTestMethodsFactory) WorldStateArchive(org.hyperledger.besu.ethereum.worldstate.WorldStateArchive) ProtocolSpec(org.hyperledger.besu.ethereum.mainnet.ProtocolSpec) ProtocolContext(org.hyperledger.besu.ethereum.ProtocolContext) Block(org.hyperledger.besu.ethereum.core.Block) MutableBlockchain(org.hyperledger.besu.ethereum.chain.MutableBlockchain) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with BlockchainImporter

use of org.hyperledger.besu.ethereum.api.jsonrpc.BlockchainImporter in project besu by hyperledger.

the class EthCallIntegrationTest method setUpOnce.

@BeforeAll
public static void setUpOnce() throws Exception {
    final String genesisJson = Resources.toString(BlockTestUtil.getTestGenesisUrl(), Charsets.UTF_8);
    BLOCKCHAIN = new JsonRpcTestMethodsFactory(new BlockchainImporter(BlockTestUtil.getTestBlockchainUrl(), genesisJson));
}
Also used : JsonRpcTestMethodsFactory(org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcTestMethodsFactory) BlockchainImporter(org.hyperledger.besu.ethereum.api.jsonrpc.BlockchainImporter) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 3 with BlockchainImporter

use of org.hyperledger.besu.ethereum.api.jsonrpc.BlockchainImporter in project besu by hyperledger.

the class EthGetBlockByNumberIntegrationTest method setUpOnce.

@BeforeAll
public static void setUpOnce() throws Exception {
    final String genesisJson = Resources.toString(BlockTestUtil.getTestGenesisUrl(), Charsets.UTF_8);
    BLOCKCHAIN = new JsonRpcTestMethodsFactory(new BlockchainImporter(BlockTestUtil.getTestBlockchainUrl(), genesisJson));
}
Also used : JsonRpcTestMethodsFactory(org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcTestMethodsFactory) BlockchainImporter(org.hyperledger.besu.ethereum.api.jsonrpc.BlockchainImporter) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 4 with BlockchainImporter

use of org.hyperledger.besu.ethereum.api.jsonrpc.BlockchainImporter in project besu by hyperledger.

the class EthGetUncleByBlockNumberAndIndexIntegrationTest method setUpOnce.

@BeforeAll
public static void setUpOnce() throws Exception {
    final String genesisJson = Resources.toString(BlockTestUtil.getTestGenesisUrl(), Charsets.UTF_8);
    BLOCKCHAIN = new JsonRpcTestMethodsFactory(new BlockchainImporter(BlockTestUtil.getTestBlockchainUrl(), genesisJson));
}
Also used : JsonRpcTestMethodsFactory(org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcTestMethodsFactory) BlockchainImporter(org.hyperledger.besu.ethereum.api.jsonrpc.BlockchainImporter) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 5 with BlockchainImporter

use of org.hyperledger.besu.ethereum.api.jsonrpc.BlockchainImporter in project besu by hyperledger.

the class EthCallIntegrationTest method setUpOnce.

@BeforeAll
public static void setUpOnce() throws Exception {
    final String genesisJson = Resources.toString(BlockTestUtil.getTestLondonGenesisUrl(), Charsets.UTF_8);
    BLOCKCHAIN = new JsonRpcTestMethodsFactory(new BlockchainImporter(BlockTestUtil.getTestLondonBlockchainUrl(), genesisJson));
}
Also used : JsonRpcTestMethodsFactory(org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcTestMethodsFactory) BlockchainImporter(org.hyperledger.besu.ethereum.api.jsonrpc.BlockchainImporter) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

BlockchainImporter (org.hyperledger.besu.ethereum.api.jsonrpc.BlockchainImporter)9 JsonRpcTestMethodsFactory (org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcTestMethodsFactory)9 BeforeAll (org.junit.jupiter.api.BeforeAll)9 Hash (org.hyperledger.besu.datatypes.Hash)1 ProtocolContext (org.hyperledger.besu.ethereum.ProtocolContext)1 MutableBlockchain (org.hyperledger.besu.ethereum.chain.MutableBlockchain)1 Block (org.hyperledger.besu.ethereum.core.Block)1 BlockImporter (org.hyperledger.besu.ethereum.core.BlockImporter)1 Synchronizer (org.hyperledger.besu.ethereum.core.Synchronizer)1 ProtocolSchedule (org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule)1 ProtocolSpec (org.hyperledger.besu.ethereum.mainnet.ProtocolSpec)1 WorldStateArchive (org.hyperledger.besu.ethereum.worldstate.WorldStateArchive)1 SyncStatus (org.hyperledger.besu.plugin.data.SyncStatus)1