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);
}
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());
}
Aggregations