use of co.rsk.test.dsl.DslParser in project rskj by rsksmart.
the class DslFilesTest method runCreate01Resource.
@Test
public void runCreate01Resource() throws FileNotFoundException, DslProcessorException {
DslParser parser = DslParser.fromResource("dsl/create01.txt");
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
processor.processCommands(parser);
Transaction transaction = world.getTransactionByName("tx01");
Assert.assertNotNull(transaction);
TransactionInfo txinfo = world.getBlockChain().getTransactionInfo(transaction.getHash().getBytes());
Assert.assertNotNull(txinfo);
BigInteger gasUsed = BigIntegers.fromUnsignedByteArray(txinfo.getReceipt().getGasUsed());
Assert.assertNotEquals(BigInteger.ZERO, gasUsed);
// According to TestRPC and geth, the gas used is 0x010c2d
Assert.assertEquals(BigIntegers.fromUnsignedByteArray(Hex.decode("010c2d")), gasUsed);
}
use of co.rsk.test.dsl.DslParser in project rskj by rsksmart.
the class DslFilesTest method runContracts06Resource.
@Test
public void runContracts06Resource() throws FileNotFoundException, DslProcessorException {
DslParser parser = DslParser.fromResource("dsl/contracts06.txt");
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
processor.processCommands(parser);
}
use of co.rsk.test.dsl.DslParser in project rskj by rsksmart.
the class DslFilesTest method runLogs01Resource.
@Test
public void runLogs01Resource() throws FileNotFoundException, DslProcessorException {
DslParser parser = DslParser.fromResource("dsl/logs01.txt");
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
processor.processCommands(parser);
// the transaction receipt should have three logs
BlockChainStatus status = world.getBlockChain().getStatus();
Assert.assertEquals(1, status.getBestBlockNumber());
Block block = status.getBestBlock();
Assert.assertEquals(1, block.getTransactionsList().size());
byte[] txhash = block.getTransactionsList().get(0).getHash().getBytes();
TransactionInfo txinfo = world.getBlockChain().getTransactionInfo(txhash);
// only three events, raised by
// Counter constructor
// Counter getValue
// Creator constructor
Assert.assertEquals(3, txinfo.getReceipt().getLogInfoList().size());
// only one topic in each event
Assert.assertEquals(1, txinfo.getReceipt().getLogInfoList().get(0).getTopics().size());
Assert.assertEquals(1, txinfo.getReceipt().getLogInfoList().get(1).getTopics().size());
Assert.assertEquals(1, txinfo.getReceipt().getLogInfoList().get(2).getTopics().size());
// the topics are different
DataWord topic1 = txinfo.getReceipt().getLogInfoList().get(0).getTopics().get(0);
DataWord topic2 = txinfo.getReceipt().getLogInfoList().get(1).getTopics().get(0);
DataWord topic3 = txinfo.getReceipt().getLogInfoList().get(2).getTopics().get(0);
Assert.assertNotEquals(topic1, topic2);
Assert.assertNotEquals(topic1, topic3);
Assert.assertNotEquals(topic2, topic3);
// only the third log was directly produced by the created contract
byte[] contractAddress = txinfo.getReceipt().getTransaction().getContractAddress().getBytes();
Assert.assertFalse(Arrays.equals(contractAddress, txinfo.getReceipt().getLogInfoList().get(0).getAddress()));
Assert.assertFalse(Arrays.equals(contractAddress, txinfo.getReceipt().getLogInfoList().get(1).getAddress()));
Assert.assertTrue(Arrays.equals(contractAddress, txinfo.getReceipt().getLogInfoList().get(2).getAddress()));
}
use of co.rsk.test.dsl.DslParser in project rskj by rsksmart.
the class DslFilesTest method runBlocks02Resource.
@Test
public void runBlocks02Resource() throws FileNotFoundException, DslProcessorException {
DslParser parser = DslParser.fromResource("dsl/blocks02.txt");
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
processor.processCommands(parser);
Assert.assertNotNull(world.getBlockByName("b01"));
Assert.assertNotNull(world.getBlockByName("c01"));
Assert.assertEquals(1, world.getBlockChain().getStatus().getBestBlock().getNumber());
}
use of co.rsk.test.dsl.DslParser in project rskj by rsksmart.
the class DslFilesTest method runContracts07Resource.
@Test
public void runContracts07Resource() throws FileNotFoundException, DslProcessorException {
DslParser parser = DslParser.fromResource("dsl/contracts07.txt");
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
processor.processCommands(parser);
}
Aggregations