Search in sources :

Example 16 with DslParser

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

the class DslParserTest method parseSimpleCommandSkippingCommentLines.

@Test
public void parseSimpleCommandSkippingCommentLines() {
    DslParser parser = new DslParser("# first comment   \ndo arg1 arg2\n  # second 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 17 with DslParser

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

the class WorldDslProcessorTest method processAssertConnectWithImportedNotBestBlock.

@Test
public void processAssertConnectWithImportedNotBestBlock() throws DslProcessorException {
    World world = new World();
    WorldDslProcessor processor = new WorldDslProcessor(world);
    DslParser parser = new DslParser("block_chain g00 b01 b02\nblock_chain g00 c01\nblock_connect b01 b02\n" + "block_connect c01\nassert_connect not_best");
    processor.processCommands(parser);
    Block block = world.getBlockChain().getStatus().getBestBlock();
    Assert.assertNotNull(block);
    Assert.assertEquals(2, block.getNumber());
}
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 18 with DslParser

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

the class WorldDslProcessorTest method processBlockConnectCommandWithTwoBlocks.

@Test
public void processBlockConnectCommandWithTwoBlocks() throws DslProcessorException {
    World world = new World();
    WorldDslProcessor processor = new WorldDslProcessor(world);
    DslParser parser = new DslParser("block_chain g00 b01 b02\nblock_connect b01 b02");
    processor.processCommands(parser);
    Block parent = world.getBlockByName("b01");
    Block block = world.getBlockChain().getStatus().getBestBlock();
    Assert.assertNotNull(parent);
    Assert.assertNotNull(block);
    Assert.assertEquals(2, block.getNumber());
    Assert.assertEquals(parent.getHash(), block.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 19 with DslParser

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

Example 20 with DslParser

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

the class WorldDslProcessorTest method processBlockBuildCommand.

@Test
public void processBlockBuildCommand() throws DslProcessorException {
    World world = new World();
    WorldDslProcessor processor = new WorldDslProcessor(world);
    DslParser parser = new DslParser("block_build b01\nparent g00\nbuild");
    processor.processCommands(parser);
    Block block = world.getBlockByName("b01");
    Assert.assertNotNull(block);
    Assert.assertEquals(1, block.getNumber());
}
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)

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