Search in sources :

Example 46 with World

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

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

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

the class WorldDslProcessorTest method processTransactionWithGasAndGasPriceBuildCommand.

@Test
public void processTransactionWithGasAndGasPriceBuildCommand() throws DslProcessorException {
    World world = new World();
    WorldDslProcessor processor = new WorldDslProcessor(world);
    DslParser parser = new DslParser("account_new acc1\naccount_new acc2\ntransaction_build tx01\nsender acc1\nreceiver acc2\nvalue 1000\ngas 1200000\ngasPrice 2\nbuild");
    processor.processCommands(parser);
    Account acc1 = world.getAccountByName("acc1");
    Account acc2 = world.getAccountByName("acc2");
    Assert.assertNotNull(acc1);
    Assert.assertNotNull(acc2);
    Transaction tx01 = world.getTransactionByName("tx01");
    Assert.assertNotNull(tx01);
    Assert.assertArrayEquals(acc1.getAddress().getBytes(), tx01.getSender().getBytes());
    Assert.assertArrayEquals(acc2.getAddress().getBytes(), tx01.getReceiveAddress().getBytes());
    Assert.assertEquals(new BigInteger("1000"), tx01.getValue().asBigInteger());
    Assert.assertNotNull(tx01.getData());
    Assert.assertEquals(0, tx01.getData().length);
    Assert.assertEquals(new BigInteger("2"), tx01.getGasPrice().asBigInteger());
    Assert.assertEquals(new BigInteger("1200000"), tx01.getGasLimitAsInteger());
}
Also used : WorldDslProcessor(co.rsk.test.dsl.WorldDslProcessor) Account(org.ethereum.core.Account) Transaction(org.ethereum.core.Transaction) DslParser(co.rsk.test.dsl.DslParser) BigInteger(java.math.BigInteger) World(co.rsk.test.World) Test(org.junit.Test)

Example 49 with World

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

Example 50 with World

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

the class WorldDslProcessorTest method createProcessorWithWorld.

@Test
public void createProcessorWithWorld() {
    World world = new World();
    WorldDslProcessor processor = new WorldDslProcessor(world);
    Assert.assertSame(world, processor.getWorld());
}
Also used : WorldDslProcessor(co.rsk.test.dsl.WorldDslProcessor) 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