Search in sources :

Example 36 with TransactionReceipt

use of org.ethereum.core.TransactionReceipt in project rskj by rsksmart.

the class ReceiptStoreImplTest method addTwoTransactionsAndGetTransactionBySecondBlock.

@Test
public void addTwoTransactionsAndGetTransactionBySecondBlock() {
    TransactionReceipt receipt0 = createReceipt();
    Keccak256 blockHash0 = new Keccak256("0102030405060708090000000000000000000000000000000000000000000000");
    store.add(blockHash0.getBytes(), 3, receipt0);
    TransactionReceipt receipt = createReceipt();
    Keccak256 blockHash = new Keccak256("0102030405060708000000000000000000000000000000000000000000000000");
    store.add(blockHash.getBytes(), 42, receipt);
    Optional<TransactionInfo> resultOpt = store.get(receipt.getTransaction().getHash().getBytes(), blockHash.getBytes());
    TransactionInfo result = resultOpt.get();
    Assert.assertNotNull(result.getBlockHash());
    Assert.assertArrayEquals(blockHash.getBytes(), result.getBlockHash());
    Assert.assertEquals(42, result.getIndex());
    Assert.assertArrayEquals(receipt.getEncoded(), result.getReceipt().getEncoded());
}
Also used : TransactionReceipt(org.ethereum.core.TransactionReceipt) Keccak256(co.rsk.crypto.Keccak256) Test(org.junit.Test)

Example 37 with TransactionReceipt

use of org.ethereum.core.TransactionReceipt in project rskj by rsksmart.

the class VmDslTest method invokeRecursiveContractsUsing401Levels.

@Test
public void invokeRecursiveContractsUsing401Levels() throws FileNotFoundException, DslProcessorException {
    DslParser parser = DslParser.fromResource("dsl/recursive02.txt");
    World world = new World();
    WorldDslProcessor processor = new WorldDslProcessor(world);
    processor.processCommands(parser);
    Block block = world.getBlockByName("b02");
    Assert.assertNotNull(block);
    Assert.assertEquals(1, block.getTransactionsList().size());
    Transaction creationTransaction = world.getTransactionByName("tx01");
    Assert.assertNotNull(creationTransaction);
    DataWord counterValue = world.getRepositoryLocator().snapshotAt(block.getHeader()).getStorageValue(creationTransaction.getContractAddress(), DataWord.ZERO);
    Assert.assertNull(counterValue);
    TransactionReceipt transactionReceipt = world.getTransactionReceiptByName("tx02");
    Assert.assertNotNull(transactionReceipt);
    byte[] status = transactionReceipt.getStatus();
    Assert.assertNotNull(status);
    Assert.assertEquals(0, status.length);
}
Also used : WorldDslProcessor(co.rsk.test.dsl.WorldDslProcessor) Transaction(org.ethereum.core.Transaction) TransactionReceipt(org.ethereum.core.TransactionReceipt) DslParser(co.rsk.test.dsl.DslParser) Block(org.ethereum.core.Block) DataWord(org.ethereum.vm.DataWord) World(co.rsk.test.World) Test(org.junit.Test)

Example 38 with TransactionReceipt

use of org.ethereum.core.TransactionReceipt in project rskj by rsksmart.

the class VmDslTest method invokeRecursiveContractsUsing400Levels.

@Test
public void invokeRecursiveContractsUsing400Levels() throws FileNotFoundException, DslProcessorException {
    System.gc();
    DslParser parser = DslParser.fromResource("dsl/recursive01.txt");
    World world = new World();
    WorldDslProcessor processor = new WorldDslProcessor(world);
    processor.processCommands(parser);
    Block block = world.getBlockByName("b02");
    Assert.assertNotNull(block);
    Assert.assertEquals(1, block.getTransactionsList().size());
    Transaction creationTransaction = world.getTransactionByName("tx01");
    Assert.assertNotNull(creationTransaction);
    DataWord counterValue = world.getRepositoryLocator().snapshotAt(block.getHeader()).getStorageValue(creationTransaction.getContractAddress(), DataWord.ZERO);
    Assert.assertNotNull(counterValue);
    Assert.assertEquals(200, counterValue.intValue());
    TransactionReceipt transactionReceipt = world.getTransactionReceiptByName("tx02");
    Assert.assertNotNull(transactionReceipt);
    byte[] status = transactionReceipt.getStatus();
    Assert.assertNotNull(status);
    Assert.assertEquals(1, status.length);
    Assert.assertEquals(1, status[0]);
}
Also used : WorldDslProcessor(co.rsk.test.dsl.WorldDslProcessor) Transaction(org.ethereum.core.Transaction) TransactionReceipt(org.ethereum.core.TransactionReceipt) DslParser(co.rsk.test.dsl.DslParser) Block(org.ethereum.core.Block) DataWord(org.ethereum.vm.DataWord) World(co.rsk.test.World) Test(org.junit.Test)

Example 39 with TransactionReceipt

use of org.ethereum.core.TransactionReceipt in project rskj by rsksmart.

the class Blake2bEipExampleTest method runTest.

@Test
public void runTest() throws FileNotFoundException, DslProcessorException {
    TestSystemProperties config = new TestSystemProperties(rawConfig -> rawConfig.withValue("blockchain.config.hardforkActivationHeights.iris300", ConfigValueFactory.fromAnyRef(0)));
    World world = new World(config);
    WorldDslProcessor processor = new WorldDslProcessor(world);
    DslParser parser = DslParser.fromResource("dsl/blake2b/eip_152_example.txt");
    processor.processCommands(parser);
    TransactionReceipt tx02Receipt = world.getTransactionReceiptByName("tx02");
    Assert.assertEquals(1, TransactionReceiptUtil.getEventCount(tx02Receipt, "ResultOk", null));
}
Also used : WorldDslProcessor(co.rsk.test.dsl.WorldDslProcessor) TransactionReceipt(org.ethereum.core.TransactionReceipt) DslParser(co.rsk.test.dsl.DslParser) World(co.rsk.test.World) TestSystemProperties(co.rsk.config.TestSystemProperties) Test(org.junit.Test)

Aggregations

TransactionReceipt (org.ethereum.core.TransactionReceipt)39 Test (org.junit.Test)30 Block (org.ethereum.core.Block)17 Transaction (org.ethereum.core.Transaction)15 Keccak256 (co.rsk.crypto.Keccak256)13 World (co.rsk.test.World)13 TransactionInfo (org.ethereum.db.TransactionInfo)10 RskAddress (co.rsk.core.RskAddress)8 CallArguments (org.ethereum.rpc.CallArguments)8 ArrayList (java.util.ArrayList)7 EthModuleTestUtils (org.ethereum.util.EthModuleTestUtils)7 LogInfo (org.ethereum.vm.LogInfo)7 BigInteger (java.math.BigInteger)6 Bloom (org.ethereum.core.Bloom)6 ProgramResult (org.ethereum.vm.program.ProgramResult)6 TestSystemProperties (co.rsk.config.TestSystemProperties)5 DslParser (co.rsk.test.dsl.DslParser)4 WorldDslProcessor (co.rsk.test.dsl.WorldDslProcessor)4 Trie (co.rsk.trie.Trie)4 List (java.util.List)4