Search in sources :

Example 21 with WorldDslProcessor

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

the class WorldDslProcessorTest method processBlockBuildCommandWithUncles.

@Test
public void processBlockBuildCommandWithUncles() throws DslProcessorException {
    World world = new World();
    WorldDslProcessor processor = new WorldDslProcessor(world);
    DslParser parser = new DslParser("block_chain g00 b01\nblock_chain g00 u01\nblock_chain g00 u02\nblock_build b02\nparent b01\nuncles u01 u02\nbuild");
    processor.processCommands(parser);
    Block block = world.getBlockByName("b02");
    Assert.assertNotNull(block);
    Assert.assertEquals(2, block.getNumber());
    Assert.assertNotNull(block.getUncleList());
    Assert.assertFalse(block.getUncleList().isEmpty());
    Assert.assertEquals(2, block.getUncleList().size());
    Assert.assertEquals(world.getBlockByName("u01").getHash(), block.getUncleList().get(0).getHash());
    Assert.assertEquals(world.getBlockByName("u02").getHash(), block.getUncleList().get(1).getHash());
}
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 22 with WorldDslProcessor

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

the class WorldDslProcessorTest method failedAssertBestCommand.

@Test
public void failedAssertBestCommand() {
    World world = new World();
    WorldDslProcessor processor = new WorldDslProcessor(world);
    DslParser parser = new DslParser("block_chain g00 b01 b02\nblock_connect b01 b02\nassert_best b01");
    try {
        processor.processCommands(parser);
        Assert.fail();
    } catch (DslProcessorException ex) {
        Assert.assertEquals("Expected best block 'b01'", 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 23 with WorldDslProcessor

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

the class RevertOpCodeTest method runAndRevertThenRunFullContract.

@Test
public void runAndRevertThenRunFullContract() throws FileNotFoundException, DslProcessorException {
    DslParser parser = DslParser.fromResource("dsl/opcode_revert2.txt");
    World world = new World();
    WorldDslProcessor processor = new WorldDslProcessor(world);
    processor.processCommands(parser);
    Assert.assertNotNull(world.getAccountByName("acc1"));
    Assert.assertTrue(world.getTransactionByName("contract_with_revert").isContractCreation());
    Assert.assertTrue(!world.getTransactionByName("tx02").isContractCreation());
    Assert.assertTrue(!world.getTransactionByName("tx03").isContractCreation());
}
Also used : WorldDslProcessor(co.rsk.test.dsl.WorldDslProcessor) DslParser(co.rsk.test.dsl.DslParser) World(co.rsk.test.World) Test(org.junit.Test)

Example 24 with WorldDslProcessor

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

the class DslFilesTest method runBlocks03Resource.

@Test
public void runBlocks03Resource() throws FileNotFoundException, DslProcessorException {
    DslParser parser = DslParser.fromResource("dsl/blocks03.txt");
    World world = new World();
    WorldDslProcessor processor = new WorldDslProcessor(world);
    processor.processCommands(parser);
    Assert.assertNotNull(world.getBlockByName("b01"));
    Assert.assertNotNull(world.getBlockByName("b02"));
    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 25 with WorldDslProcessor

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

the class DslFilesTest method runUncles01Resource.

@Test
public void runUncles01Resource() throws FileNotFoundException, DslProcessorException {
    DslParser parser = DslParser.fromResource("dsl/uncles01.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.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)

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