Search in sources :

Example 36 with DslParser

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

the class DslParserTest method parseSimpleCommandWithAdditionalSpacesAndTabs.

@Test
public void parseSimpleCommandWithAdditionalSpacesAndTabs() {
    DslParser parser = new DslParser("        do\t\t    arg1  \t    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 37 with DslParser

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

the class DslParserTest method parseSimpleCommandSkippingEmptyLines.

@Test
public void parseSimpleCommandSkippingEmptyLines() {
    DslParser parser = new DslParser("   \ndo arg1 arg2\n   ");
    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 38 with DslParser

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

the class DslParserTest method parseSimpleCommandWithNoArguments.

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

Example 39 with DslParser

use of co.rsk.test.dsl.DslParser 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());
}
Also used : WorldDslProcessor(co.rsk.test.dsl.WorldDslProcessor) DslParser(co.rsk.test.dsl.DslParser) Block(org.ethereum.core.Block) World(co.rsk.test.World) Test(org.junit.Test)

Example 40 with DslParser

use of co.rsk.test.dsl.DslParser 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());
}
Also used : WorldDslProcessor(co.rsk.test.dsl.WorldDslProcessor) Account(org.ethereum.core.Account) DslParser(co.rsk.test.dsl.DslParser) BigInteger(java.math.BigInteger) World(co.rsk.test.World) 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