Search in sources :

Example 51 with World

use of co.rsk.test.World in project rskj by rsksmart.

the class WorldDslProcessorTest method processAssertConnectWithBlockWithoutParent.

@Test
public void processAssertConnectWithBlockWithoutParent() throws DslProcessorException {
    World world = new World();
    WorldDslProcessor processor = new WorldDslProcessor(world);
    DslParser parser = new DslParser("block_chain g00 b01 b02\nblock_connect b02\nassert_connect no_parent");
    processor.processCommands(parser);
    Block block = world.getBlockChain().getStatus().getBestBlock();
    Assert.assertNotNull(block);
    Assert.assertEquals(0, 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 52 with World

use of co.rsk.test.World 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 53 with World

use of co.rsk.test.World in project rskj by rsksmart.

the class WorldDslProcessorTest method processAssertBalance.

@Test
public void processAssertBalance() throws DslProcessorException {
    World world = new World();
    WorldDslProcessor processor = new WorldDslProcessor(world);
    DslParser parser = new DslParser("account_new acc1 1000\nassert_balance acc1 1000\n");
    processor.processCommands(parser);
    Account account = world.getAccountByName("acc1");
    Assert.assertNotNull(account);
}
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 54 with World

use of co.rsk.test.World 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 55 with World

use of co.rsk.test.World in project rskj by rsksmart.

the class WorldDslProcessorTest method processBlockChainCommandWithTwoChildBlocksSkippingMultilineComments.

@Test
public void processBlockChainCommandWithTwoChildBlocksSkippingMultilineComments() throws DslProcessorException {
    World world = new World();
    WorldDslProcessor processor = new WorldDslProcessor(world);
    DslParser parser = new DslParser("comment\nthis is a comment\nend\nblock_chain g00 b01 b02\ncomment\nthis is another comment\nwith two lines\n  end  \n");
    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)

Aggregations

World (co.rsk.test.World)198 Test (org.junit.Test)169 WorldDslProcessor (co.rsk.test.dsl.WorldDslProcessor)55 DslParser (co.rsk.test.dsl.DslParser)52 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)46 HashMapDB (org.ethereum.datasource.HashMapDB)45 AccountBuilder (co.rsk.test.builders.AccountBuilder)36 Block (org.ethereum.core.Block)36 ReceiptStore (org.ethereum.db.ReceiptStore)34 BlockBuilder (co.rsk.test.builders.BlockBuilder)31 ReceiptStoreImpl (org.ethereum.db.ReceiptStoreImpl)31 Blockchain (org.ethereum.core.Blockchain)30 TransactionBuilder (co.rsk.test.builders.TransactionBuilder)24 Transaction (org.ethereum.core.Transaction)23 BigInteger (java.math.BigInteger)17 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)15 SyncConfiguration (co.rsk.net.sync.SyncConfiguration)15 JsonNode (com.fasterxml.jackson.databind.JsonNode)15 Account (org.ethereum.core.Account)15 TestSystemProperties (co.rsk.config.TestSystemProperties)14