use of co.rsk.core.bc.BlockChainStatus in project rskj by rsksmart.
the class SnapshotManagerTest method revertToSnapshot.
@Test
public void revertToSnapshot() {
Blockchain blockchain = createBlockchain();
addBlocks(blockchain, 10);
BlockChainStatus status = blockchain.getStatus();
SnapshotManager manager = new SnapshotManager();
int snapshotId = manager.takeSnapshot(blockchain);
addBlocks(blockchain, 20);
Assert.assertEquals(30, blockchain.getStatus().getBestBlockNumber());
Assert.assertTrue(manager.revertToSnapshot(blockchain, snapshotId));
BlockChainStatus newStatus = blockchain.getStatus();
Assert.assertEquals(status.getBestBlockNumber(), newStatus.getBestBlockNumber());
Assert.assertEquals(status.getTotalDifficulty(), newStatus.getTotalDifficulty());
Assert.assertEquals(status.getBestBlock().getHash(), newStatus.getBestBlock().getHash());
for (int k = 11; k <= 30; k++) Assert.assertTrue(blockchain.getBlocksByNumber(k).isEmpty());
}
use of co.rsk.core.bc.BlockChainStatus in project rskj by rsksmart.
the class Web3ImplSnapshotTest method revertToSnapshot.
@Test
public void revertToSnapshot() {
World world = new World();
Web3Impl web3 = createWeb3(world);
Blockchain blockchain = world.getBlockChain();
addBlocks(blockchain, 10);
Assert.assertEquals(10, blockchain.getBestBlock().getNumber());
BlockChainStatus status = blockchain.getStatus();
String snapshotId = web3.evm_snapshot();
addBlocks(blockchain, 10);
Assert.assertEquals(20, blockchain.getBestBlock().getNumber());
Assert.assertTrue(web3.evm_revert(snapshotId));
Assert.assertEquals(10, blockchain.getBestBlock().getNumber());
BlockChainStatus newStatus = blockchain.getStatus();
Assert.assertEquals(status.getBestBlock().getHash(), newStatus.getBestBlock().getHash());
Assert.assertEquals(status.getTotalDifficulty(), newStatus.getTotalDifficulty());
}
use of co.rsk.core.bc.BlockChainStatus in project rskj by rsksmart.
the class Web3ImplSnapshotTest method resetSnapshots.
@Test
public void resetSnapshots() {
World world = new World();
Web3Impl web3 = createWeb3(world);
Blockchain blockchain = world.getBlockChain();
BlockChainStatus status = blockchain.getStatus();
addBlocks(blockchain, 10);
Assert.assertEquals(10, blockchain.getBestBlock().getNumber());
web3.evm_reset();
Assert.assertEquals(0, blockchain.getBestBlock().getNumber());
BlockChainStatus newStatus = blockchain.getStatus();
Assert.assertEquals(status.getBestBlock().getHash(), newStatus.getBestBlock().getHash());
Assert.assertEquals(status.getTotalDifficulty(), newStatus.getTotalDifficulty());
}
Aggregations