Search in sources :

Example 11 with WorldDslProcessor

use of co.rsk.test.dsl.WorldDslProcessor 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 WorldDslProcessor

use of co.rsk.test.dsl.WorldDslProcessor 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 13 with WorldDslProcessor

use of co.rsk.test.dsl.WorldDslProcessor 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 14 with WorldDslProcessor

use of co.rsk.test.dsl.WorldDslProcessor 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 15 with WorldDslProcessor

use of co.rsk.test.dsl.WorldDslProcessor 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

WorldDslProcessor (co.rsk.test.dsl.WorldDslProcessor)43 Test (org.junit.Test)43 DslParser (co.rsk.test.dsl.DslParser)42 World (co.rsk.test.World)24 Block (org.ethereum.core.Block)13 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