Search in sources :

Example 11 with DslParser

use of co.rsk.test.dsl.DslParser in project rskj by rsksmart.

the class DslFilesTest method runUncles04Resource.

@Test
public void runUncles04Resource() throws FileNotFoundException, DslProcessorException {
    DslParser parser = DslParser.fromResource("dsl/uncles04.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.assertNotNull(world.getBlockByName("c02"));
    Assert.assertEquals(2, world.getBlockChain().getStatus().getBestBlock().getNumber());
}
Also used : WorldDslProcessor(co.rsk.test.dsl.WorldDslProcessor) DslParser(co.rsk.test.dsl.DslParser) Test(org.junit.Test)

Example 12 with DslParser

use of co.rsk.test.dsl.DslParser in project rskj by rsksmart.

the class DslParserTest method parseTwoSimpleCommands.

@Test
public void parseTwoSimpleCommands() {
    DslParser parser = new DslParser("do1 arg11 arg12\ndo2 arg21 arg22");
    DslCommand cmd = parser.nextCommand();
    Assert.assertNotNull(cmd);
    Assert.assertTrue(cmd.isCommand("do1"));
    Assert.assertEquals(2, cmd.getArity());
    Assert.assertEquals("arg11", cmd.getArgument(0));
    Assert.assertEquals("arg12", cmd.getArgument(1));
    cmd = parser.nextCommand();
    Assert.assertNotNull(cmd);
    Assert.assertTrue(cmd.isCommand("do2"));
    Assert.assertEquals(2, cmd.getArity());
    Assert.assertEquals("arg21", cmd.getArgument(0));
    Assert.assertEquals("arg22", cmd.getArgument(1));
    Assert.assertNull(parser.nextCommand());
}
Also used : DslCommand(co.rsk.test.dsl.DslCommand) DslParser(co.rsk.test.dsl.DslParser) Test(org.junit.Test)

Example 13 with DslParser

use of co.rsk.test.dsl.DslParser in project rskj by rsksmart.

the class DslParserTest method parseSimpleCommand.

@Test
public void parseSimpleCommand() {
    DslParser parser = new DslParser("do arg1 arg2");
    DslCommand cmd = parser.nextCommand();
    Assert.assertNotNull(cmd);
    Assert.assertTrue(cmd.isCommand("do"));
    Assert.assertEquals(2, cmd.getArity());
    Assert.assertEquals("arg1", cmd.getArgument(0));
    Assert.assertEquals("arg2", cmd.getArgument(1));
    Assert.assertNull(parser.nextCommand());
}
Also used : DslCommand(co.rsk.test.dsl.DslCommand) DslParser(co.rsk.test.dsl.DslParser) Test(org.junit.Test)

Example 14 with DslParser

use of co.rsk.test.dsl.DslParser in project rskj by rsksmart.

the class DslParserTest method parseSimpleCommandSkippingComment.

@Test
public void parseSimpleCommandSkippingComment() {
    DslParser parser = new DslParser("do arg1 arg2 # this is a comment");
    DslCommand cmd = parser.nextCommand();
    Assert.assertNotNull(cmd);
    Assert.assertTrue(cmd.isCommand("do"));
    Assert.assertEquals(2, cmd.getArity());
    Assert.assertEquals("arg1", cmd.getArgument(0));
    Assert.assertEquals("arg2", cmd.getArgument(1));
    Assert.assertNull(parser.nextCommand());
}
Also used : DslCommand(co.rsk.test.dsl.DslCommand) DslParser(co.rsk.test.dsl.DslParser) Test(org.junit.Test)

Example 15 with DslParser

use of co.rsk.test.dsl.DslParser in project rskj by rsksmart.

the class DslParserTest method getNoCommandFromEmptyString.

@Test
public void getNoCommandFromEmptyString() {
    DslParser parser = new DslParser("");
    Assert.assertNull(parser.nextCommand());
}
Also used : DslParser(co.rsk.test.dsl.DslParser) Test(org.junit.Test)

Aggregations

DslParser (co.rsk.test.dsl.DslParser)50 Test (org.junit.Test)50 WorldDslProcessor (co.rsk.test.dsl.WorldDslProcessor)42 World (co.rsk.test.World)23 Block (org.ethereum.core.Block)13 DslCommand (co.rsk.test.dsl.DslCommand)7 Account (org.ethereum.core.Account)7 BigInteger (java.math.BigInteger)6 Transaction (org.ethereum.core.Transaction)6 DslProcessorException (co.rsk.test.dsl.DslProcessorException)2 TransactionInfo (org.ethereum.db.TransactionInfo)2 BlockChainStatus (co.rsk.core.bc.BlockChainStatus)1 DataWord (org.ethereum.vm.DataWord)1