Search in sources :

Example 1 with SnapshotManager

use of co.rsk.core.SnapshotManager in project rskj by rsksmart.

the class Web3ImplSnapshotTest method createWeb3.

private Web3Impl createWeb3(SimpleEthereum ethereum) {
    MinerClock minerClock = new MinerClock(true, Clock.systemUTC());
    MinerServer minerServer = getMinerServerForTest(ethereum, minerClock);
    MinerClientImpl minerClient = new MinerClientImpl(null, minerServer, config.minerClientDelayBetweenBlocks(), config.minerClientDelayBetweenRefreshes());
    EvmModule evmModule = new EvmModuleImpl(minerServer, minerClient, minerClock, new SnapshotManager(blockchain, factory.getBlockStore(), factory.getTransactionPool(), minerServer));
    PersonalModule pm = new PersonalModuleWalletDisabled();
    TxPoolModule tpm = new TxPoolModuleImpl(Web3Mocks.getMockTransactionPool());
    DebugModule dm = new DebugModuleImpl(null, null, Web3Mocks.getMockMessageHandler(), null);
    ethereum.blockchain = blockchain;
    return new Web3Impl(ethereum, blockchain, factory.getBlockStore(), factory.getReceiptStore(), Web3Mocks.getMockProperties(), minerClient, minerServer, pm, null, evmModule, tpm, null, dm, null, null, Web3Mocks.getMockChannelManager(), null, null, null, null, null, null, null, null, null);
}
Also used : EvmModuleImpl(co.rsk.rpc.modules.evm.EvmModuleImpl) TxPoolModuleImpl(co.rsk.rpc.modules.txpool.TxPoolModuleImpl) DebugModuleImpl(co.rsk.rpc.modules.debug.DebugModuleImpl) PersonalModuleWalletDisabled(co.rsk.rpc.modules.personal.PersonalModuleWalletDisabled) PersonalModule(co.rsk.rpc.modules.personal.PersonalModule) DebugModule(co.rsk.rpc.modules.debug.DebugModule) EvmModule(co.rsk.rpc.modules.evm.EvmModule) TxPoolModule(co.rsk.rpc.modules.txpool.TxPoolModule) SnapshotManager(co.rsk.core.SnapshotManager)

Example 2 with SnapshotManager

use of co.rsk.core.SnapshotManager in project rskj by rsksmart.

the class MinerManagerTest method mineBlock.

@Test
public void mineBlock() {
    Assert.assertEquals(0, blockchain.getBestBlock().getNumber());
    MinerManager manager = new MinerManager();
    MinerServerImpl minerServer = getMinerServer();
    MinerClientImpl minerClient = getMinerClient(minerServer);
    manager.mineBlock(minerClient, minerServer);
    Assert.assertEquals(1, blockchain.getBestBlock().getNumber());
    Assert.assertFalse(blockchain.getBestBlock().getTransactionsList().isEmpty());
    SnapshotManager snapshotManager = new SnapshotManager(blockchain, blockStore, transactionPool, minerServer);
    snapshotManager.resetSnapshots();
    Assert.assertEquals(0, blockchain.getBestBlock().getNumber());
    manager.mineBlock(minerClient, minerServer);
    // miningMainchainView new best block update is done by a listener on miner server.
    // This test does not have that listener so add the new best block manually.
    miningMainchainView.addBest(blockchain.getBestBlock().getHeader());
    manager.mineBlock(minerClient, minerServer);
    Assert.assertEquals(2, blockchain.getBestBlock().getNumber());
    snapshotManager.resetSnapshots();
    Assert.assertTrue(transactionPool.getPendingTransactions().isEmpty());
    manager.mineBlock(minerClient, minerServer);
    Assert.assertTrue(transactionPool.getPendingTransactions().isEmpty());
}
Also used : SnapshotManager(co.rsk.core.SnapshotManager) Test(org.junit.Test)

Aggregations

SnapshotManager (co.rsk.core.SnapshotManager)2 DebugModule (co.rsk.rpc.modules.debug.DebugModule)1 DebugModuleImpl (co.rsk.rpc.modules.debug.DebugModuleImpl)1 EvmModule (co.rsk.rpc.modules.evm.EvmModule)1 EvmModuleImpl (co.rsk.rpc.modules.evm.EvmModuleImpl)1 PersonalModule (co.rsk.rpc.modules.personal.PersonalModule)1 PersonalModuleWalletDisabled (co.rsk.rpc.modules.personal.PersonalModuleWalletDisabled)1 TxPoolModule (co.rsk.rpc.modules.txpool.TxPoolModule)1 TxPoolModuleImpl (co.rsk.rpc.modules.txpool.TxPoolModuleImpl)1 Test (org.junit.Test)1