Search in sources :

Example 31 with WorldDslProcessor

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

the class DslFilesTest method runUncles05Resource.

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

Example 32 with WorldDslProcessor

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

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

Example 34 with WorldDslProcessor

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

the class WorldDslProcessorTest method raiseIfUnknownCommand.

@Test
public void raiseIfUnknownCommand() {
    WorldDslProcessor processor = new WorldDslProcessor(new World());
    try {
        processor.processCommands(new DslParser("foo"));
        Assert.fail();
    } catch (DslProcessorException ex) {
        Assert.assertEquals("Unknown command 'foo'", ex.getMessage());
    }
}
Also used : WorldDslProcessor(co.rsk.test.dsl.WorldDslProcessor) DslParser(co.rsk.test.dsl.DslParser) World(co.rsk.test.World) DslProcessorException(co.rsk.test.dsl.DslProcessorException) Test(org.junit.Test)

Example 35 with WorldDslProcessor

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

the class WorldDslProcessorTest method processAssertConnectWithImportedBestBlock.

@Test
public void processAssertConnectWithImportedBestBlock() throws DslProcessorException {
    World world = new World();
    WorldDslProcessor processor = new WorldDslProcessor(world);
    DslParser parser = new DslParser("block_chain g00 b01 b02\nblock_connect b01 b02\nassert_connect 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)

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