use of co.rsk.test.World in project rskj by rsksmart.
the class WorldDslProcessorTest method processAssertConnectWithBlockWithoutParent.
@Test
public void processAssertConnectWithBlockWithoutParent() throws DslProcessorException {
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
DslParser parser = new DslParser("block_chain g00 b01 b02\nblock_connect b02\nassert_connect no_parent");
processor.processCommands(parser);
Block block = world.getBlockChain().getStatus().getBestBlock();
Assert.assertNotNull(block);
Assert.assertEquals(0, block.getNumber());
}
use of co.rsk.test.World in project rskj by rsksmart.
the class WorldDslProcessorTest method processBlockBuildCommandWithUncles.
@Test
public void processBlockBuildCommandWithUncles() throws DslProcessorException {
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
DslParser parser = new DslParser("block_chain g00 b01\nblock_chain g00 u01\nblock_chain g00 u02\nblock_build b02\nparent b01\nuncles u01 u02\nbuild");
processor.processCommands(parser);
Block block = world.getBlockByName("b02");
Assert.assertNotNull(block);
Assert.assertEquals(2, block.getNumber());
Assert.assertNotNull(block.getUncleList());
Assert.assertFalse(block.getUncleList().isEmpty());
Assert.assertEquals(2, block.getUncleList().size());
Assert.assertEquals(world.getBlockByName("u01").getHash(), block.getUncleList().get(0).getHash());
Assert.assertEquals(world.getBlockByName("u02").getHash(), block.getUncleList().get(1).getHash());
}
use of co.rsk.test.World in project rskj by rsksmart.
the class WorldDslProcessorTest method processAssertBalance.
@Test
public void processAssertBalance() throws DslProcessorException {
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
DslParser parser = new DslParser("account_new acc1 1000\nassert_balance acc1 1000\n");
processor.processCommands(parser);
Account account = world.getAccountByName("acc1");
Assert.assertNotNull(account);
}
use of co.rsk.test.World in project rskj by rsksmart.
the class WorldDslProcessorTest method processAccountNewCommand.
@Test
public void processAccountNewCommand() throws DslProcessorException {
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
DslParser parser = new DslParser("account_new acc1");
processor.processCommands(parser);
Account account = world.getAccountByName("acc1");
Assert.assertNotNull(account);
Assert.assertEquals(BigInteger.ZERO, world.getRepository().getBalance(account.getAddress()).asBigInteger());
}
use of co.rsk.test.World in project rskj by rsksmart.
the class WorldDslProcessorTest method processBlockChainCommandWithTwoChildBlocksSkippingMultilineComments.
@Test
public void processBlockChainCommandWithTwoChildBlocksSkippingMultilineComments() throws DslProcessorException {
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
DslParser parser = new DslParser("comment\nthis is a comment\nend\nblock_chain g00 b01 b02\ncomment\nthis is another comment\nwith two lines\n end \n");
processor.processCommands(parser);
Block genesis = world.getBlockByName("g00");
Block block1 = world.getBlockByName("b01");
Assert.assertNotNull(block1);
Assert.assertEquals(1, block1.getNumber());
Assert.assertEquals(genesis.getHash(), block1.getParentHash());
Block block2 = world.getBlockByName("b02");
Assert.assertNotNull(block2);
Assert.assertEquals(2, block2.getNumber());
Assert.assertEquals(block1.getHash(), block2.getParentHash());
}
Aggregations