use of co.rsk.test.World in project rskj by rsksmart.
the class WorldDslProcessorTest method processAccountNewCommandWithBalanceAndCode.
@Test
public void processAccountNewCommandWithBalanceAndCode() throws DslProcessorException {
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
DslParser parser = new DslParser("account_new acc1 1000000 01020304");
processor.processCommands(parser);
Account account = world.getAccountByName("acc1");
Assert.assertNotNull(account);
RepositorySnapshot repository = world.getRepositoryLocator().snapshotAt(world.getBlockChain().getBestBlock().getHeader());
Assert.assertEquals(new BigInteger("1000000"), repository.getBalance(account.getAddress()).asBigInteger());
byte[] code = repository.getCode(account.getAddress());
Assert.assertNotNull(code);
Assert.assertArrayEquals(new byte[] { 0x01, 0x02, 0x03, 0x04 }, code);
}
use of co.rsk.test.World in project rskj by rsksmart.
the class BlocksBloomServiceTest method processFirstAndSecondRangeUsingEmitter.
@Test
public void processFirstAndSecondRangeUsingEmitter() {
World world = new World();
Blockchain blockchain = world.getBlockChain();
BlockChainBuilder.extend(blockchain, 10, false, false);
CompositeEthereumListener emitter = new CompositeEthereumListener();
KeyValueDataSource dataSource = new HashMapDB();
BlocksBloomStore blocksBloomStore = new BlocksBloomStore(4, 2, dataSource);
BlocksBloomService blocksBloomService = new BlocksBloomService(emitter, blocksBloomStore, world.getBlockStore());
blocksBloomService.start();
emitter.onBlock(blockchain.getBlockByNumber(4), null);
emitter.onBlock(blockchain.getBlockByNumber(6), null);
emitter.onBlock(blockchain.getBlockByNumber(9), null);
blocksBloomService.stop();
Assert.assertFalse(dataSource.keys().isEmpty());
Assert.assertEquals(2, dataSource.keys().size());
Assert.assertNotNull(dataSource.get(longToKey(0)));
Assert.assertNotNull(dataSource.get(longToKey(4)));
}
use of co.rsk.test.World in project rskj by rsksmart.
the class BlocksBloomServiceTest method processFirstRange.
@Test
public void processFirstRange() {
World world = new World();
Blockchain blockchain = world.getBlockChain();
BlockChainBuilder.extend(blockchain, 8, false, false);
CompositeEthereumListener emitter = new CompositeEthereumListener();
KeyValueDataSource dataSource = new HashMapDB();
BlocksBloomStore blocksBloomStore = new BlocksBloomStore(4, 2, dataSource);
BlocksBloomService blocksBloomService = new BlocksBloomService(emitter, blocksBloomStore, world.getBlockStore());
blocksBloomService.processNewBlock(4);
blocksBloomService.processNewBlock(6);
Assert.assertFalse(dataSource.keys().isEmpty());
Assert.assertEquals(1, dataSource.keys().size());
Assert.assertNotNull(dataSource.get(longToKey(0)));
}
use of co.rsk.test.World in project rskj by rsksmart.
the class BlocksBloomProcessorTest method processBlocksInSecondRangeOnly.
@Test
public void processBlocksInSecondRangeOnly() {
World world = new World();
Blockchain blockchain = world.getBlockChain();
BlockChainBuilder.extend(blockchain, 8, false, false);
KeyValueDataSource dataSource = new HashMapDB();
BlocksBloomStore blocksBloomStore = new BlocksBloomStore(4, 2, dataSource);
BlocksBloomProcessor blocksBloomProcessor = new BlocksBloomProcessor(blocksBloomStore, world.getBlockStore());
blocksBloomProcessor.processNewBlockNumber(6);
blocksBloomProcessor.processNewBlockNumber(4);
BlocksBloom result = blocksBloomProcessor.getBlocksBloomInProcess();
Assert.assertNotNull(result);
Assert.assertEquals(4, result.fromBlock());
Assert.assertEquals(4, result.toBlock());
Assert.assertTrue(dataSource.keys().isEmpty());
}
use of co.rsk.test.World in project rskj by rsksmart.
the class BlocksBloomProcessorTest method processNewBlockTwice.
@Test
public void processNewBlockTwice() {
World world = new World();
Blockchain blockchain = world.getBlockChain();
BlockChainBuilder.extend(blockchain, 8, false, false);
KeyValueDataSource dataSource = new HashMapDB();
BlocksBloomStore blocksBloomStore = new BlocksBloomStore(4, 2, dataSource);
BlocksBloomProcessor blocksBloomProcessor = new BlocksBloomProcessor(blocksBloomStore, world.getBlockStore());
blocksBloomProcessor.processNewBlockNumber(4);
blocksBloomProcessor.processNewBlockNumber(4);
BlocksBloom result = blocksBloomProcessor.getBlocksBloomInProcess();
Assert.assertNotNull(result);
Assert.assertEquals(0, result.fromBlock());
Assert.assertEquals(2, result.toBlock());
Assert.assertTrue(dataSource.keys().isEmpty());
}
Aggregations