use of co.rsk.test.dsl.WorldDslProcessor 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.dsl.WorldDslProcessor in project rskj by rsksmart.
the class WorldDslProcessorTest method failedAssertBestCommand.
@Test
public void failedAssertBestCommand() {
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
DslParser parser = new DslParser("block_chain g00 b01 b02\nblock_connect b01 b02\nassert_best b01");
try {
processor.processCommands(parser);
Assert.fail();
} catch (DslProcessorException ex) {
Assert.assertEquals("Expected best block 'b01'", ex.getMessage());
}
}
use of co.rsk.test.dsl.WorldDslProcessor in project rskj by rsksmart.
the class RevertOpCodeTest method runAndRevertThenRunFullContract.
@Test
public void runAndRevertThenRunFullContract() throws FileNotFoundException, DslProcessorException {
DslParser parser = DslParser.fromResource("dsl/opcode_revert2.txt");
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
processor.processCommands(parser);
Assert.assertNotNull(world.getAccountByName("acc1"));
Assert.assertTrue(world.getTransactionByName("contract_with_revert").isContractCreation());
Assert.assertTrue(!world.getTransactionByName("tx02").isContractCreation());
Assert.assertTrue(!world.getTransactionByName("tx03").isContractCreation());
}
use of co.rsk.test.dsl.WorldDslProcessor in project rskj by rsksmart.
the class DslFilesTest method runBlocks03Resource.
@Test
public void runBlocks03Resource() throws FileNotFoundException, DslProcessorException {
DslParser parser = DslParser.fromResource("dsl/blocks03.txt");
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
processor.processCommands(parser);
Assert.assertNotNull(world.getBlockByName("b01"));
Assert.assertNotNull(world.getBlockByName("b02"));
Assert.assertEquals(2, world.getBlockChain().getStatus().getBestBlock().getNumber());
}
use of co.rsk.test.dsl.WorldDslProcessor in project rskj by rsksmart.
the class DslFilesTest method runUncles01Resource.
@Test
public void runUncles01Resource() throws FileNotFoundException, DslProcessorException {
DslParser parser = DslParser.fromResource("dsl/uncles01.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("b02"));
Assert.assertEquals(2, world.getBlockChain().getStatus().getBestBlock().getNumber());
}
Aggregations