use of co.rsk.test.dsl.WorldDslProcessor in project rskj by rsksmart.
the class DslFilesTest method runUncles05Resource.
@Test
public void runUncles05Resource() throws FileNotFoundException, DslProcessorException {
DslParser parser = DslParser.fromResource("dsl/uncles05.txt");
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
processor.processCommands(parser);
Assert.assertNotNull(world.getBlockByName("b01"));
Assert.assertNotNull(world.getBlockByName("u01"));
Assert.assertNotNull(world.getBlockByName("u02"));
Assert.assertNotNull(world.getBlockByName("u03"));
Assert.assertNotNull(world.getBlockByName("u04"));
Assert.assertNotNull(world.getBlockByName("b02"));
Assert.assertNotNull(world.getBlockByName("c02"));
Assert.assertNotNull(world.getBlockByName("c03"));
Assert.assertEquals(3, world.getBlockChain().getStatus().getBestBlock().getNumber());
}
use of co.rsk.test.dsl.WorldDslProcessor in project rskj by rsksmart.
the class WorldDslProcessorTest method processBlockChainCommandWithTwoChildBlocks.
@Test
public void processBlockChainCommandWithTwoChildBlocks() throws DslProcessorException {
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
DslParser parser = new DslParser("block_chain g00 b01 b02");
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());
}
use of co.rsk.test.dsl.WorldDslProcessor in project rskj by rsksmart.
the class WorldDslProcessorTest method processAccountNewCommandWithBalance.
@Test
public void processAccountNewCommandWithBalance() throws DslProcessorException {
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
DslParser parser = new DslParser("account_new acc1 1000000");
processor.processCommands(parser);
Account account = world.getAccountByName("acc1");
Assert.assertNotNull(account);
Assert.assertEquals(new BigInteger("1000000"), world.getRepository().getBalance(account.getAddress()).asBigInteger());
}
use of co.rsk.test.dsl.WorldDslProcessor in project rskj by rsksmart.
the class WorldDslProcessorTest method raiseIfUnknownCommand.
@Test
public void raiseIfUnknownCommand() {
WorldDslProcessor processor = new WorldDslProcessor(new World());
try {
processor.processCommands(new DslParser("foo"));
Assert.fail();
} catch (DslProcessorException ex) {
Assert.assertEquals("Unknown command 'foo'", ex.getMessage());
}
}
use of co.rsk.test.dsl.WorldDslProcessor in project rskj by rsksmart.
the class WorldDslProcessorTest method processAssertConnectWithImportedBestBlock.
@Test
public void processAssertConnectWithImportedBestBlock() throws DslProcessorException {
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
DslParser parser = new DslParser("block_chain g00 b01 b02\nblock_connect b01 b02\nassert_connect best");
processor.processCommands(parser);
Block block = world.getBlockChain().getStatus().getBestBlock();
Assert.assertNotNull(block);
Assert.assertEquals(2, block.getNumber());
}
Aggregations