Search in sources :

Example 31 with TransactionReceipt

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

the class PrecompiledContractsCallErrorHandlingTests method assertTransaction.

private void assertTransaction(String tx, String precompiledAddress, int expectedPrecompiledSuccessEventCount, int expectedPrecompiledFailureEventCount, boolean expectedTransactionStatus) throws IOException {
    Transaction transaction = world.getTransactionByName(tx);
    Assert.assertNotNull(transaction);
    TransactionReceipt transactionReceipt = world.getTransactionReceiptByName(tx);
    assertExpectedData(transactionReceipt.getTransaction(), precompiledAddress);
    Assert.assertNotNull(transactionReceipt);
    Assert.assertEquals(expectedTransactionStatus, transactionReceipt.isSuccessful());
    assertEvents(transactionReceipt, "PrecompiledSuccess", expectedPrecompiledSuccessEventCount);
    assertEvents(transactionReceipt, "PrecompiledFailure", expectedPrecompiledFailureEventCount);
}
Also used : CallTransaction(org.ethereum.core.CallTransaction) Transaction(org.ethereum.core.Transaction) TransactionReceipt(org.ethereum.core.TransactionReceipt)

Example 32 with TransactionReceipt

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

the class ReceiptStoreImplFallbackTest method getOlderReceiptDataViaFallback.

@Test
public void getOlderReceiptDataViaFallback() {
    HashMapDB hashMapDB = new HashMapDB();
    ReceiptStore storeV1 = new ReceiptStoreImpl(hashMapDB);
    ReceiptStore storeV2 = new ReceiptStoreImplV2(hashMapDB);
    TransactionReceipt receipt = createReceipt();
    byte[] blockHash = Hex.decode("0102030405060708");
    storeV1.add(blockHash, 42, receipt);
    TransactionInfo result = storeV2.get(receipt.getTransaction().getHash().getBytes(), blockHash).orElse(null);
    Assert.assertNotNull(result);
    Assert.assertNotNull(result.getBlockHash());
    Assert.assertArrayEquals(blockHash, result.getBlockHash());
    Assert.assertEquals(42, result.getIndex());
    Assert.assertArrayEquals(receipt.getEncoded(), result.getReceipt().getEncoded());
}
Also used : TransactionReceipt(org.ethereum.core.TransactionReceipt) HashMapDB(org.ethereum.datasource.HashMapDB) Test(org.junit.Test)

Example 33 with TransactionReceipt

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

the class ReceiptStoreImplFallbackTest method ignoreNewerReceiptDataByInitialImpl.

@Test
public void ignoreNewerReceiptDataByInitialImpl() {
    HashMapDB hashMapDB = new HashMapDB();
    ReceiptStore storeV1 = new ReceiptStoreImpl(hashMapDB);
    ReceiptStore storeV2 = new ReceiptStoreImplV2(hashMapDB);
    TransactionReceipt receipt = createReceipt();
    byte[] blockHash = Hex.decode("0102030405060708");
    storeV2.add(blockHash, 42, receipt);
    TransactionInfo result = storeV1.get(receipt.getTransaction().getHash().getBytes(), blockHash).orElse(null);
    Assert.assertNull(result);
}
Also used : TransactionReceipt(org.ethereum.core.TransactionReceipt) HashMapDB(org.ethereum.datasource.HashMapDB) Test(org.junit.Test)

Example 34 with TransactionReceipt

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

the class ReceiptStoreImplTest method addTwoTransactionsAndGetLastTransaction.

@Test
public void addTwoTransactionsAndGetLastTransaction() {
    TransactionReceipt receipt0 = createReceipt();
    byte[] blockHash0 = Hex.decode("010203040506070809");
    store.add(blockHash0, 3, receipt0);
    TransactionReceipt receipt = createReceipt();
    byte[] blockHash = Hex.decode("0102030405060708");
    store.add(blockHash, 42, receipt);
    TransactionInfo result = store.get(receipt.getTransaction().getHash().getBytes(), blockHash).orElse(null);
    Assert.assertNotNull(result);
    Assert.assertNotNull(result.getBlockHash());
    Assert.assertArrayEquals(blockHash, result.getBlockHash());
    Assert.assertEquals(42, result.getIndex());
    Assert.assertArrayEquals(receipt.getEncoded(), result.getReceipt().getEncoded());
}
Also used : TransactionReceipt(org.ethereum.core.TransactionReceipt) Test(org.junit.Test)

Example 35 with TransactionReceipt

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

the class ReceiptStoreImplTest method addTwoTransactionsAndGetAllTransactions.

@Test
public void addTwoTransactionsAndGetAllTransactions() {
    TransactionReceipt receipt0 = createReceipt();
    byte[] blockHash0 = Hex.decode("010203040506070809");
    store.add(blockHash0, 3, receipt0);
    TransactionReceipt receipt = createReceipt();
    byte[] blockHash = Hex.decode("0102030405060708");
    store.add(blockHash, 42, receipt);
    Optional<TransactionInfo> txInfo0 = store.get(receipt.getTransaction().getHash().getBytes(), blockHash0);
    Assert.assertTrue(txInfo0.isPresent());
    Assert.assertNotNull(txInfo0.get().getBlockHash());
    Assert.assertArrayEquals(blockHash0, txInfo0.get().getBlockHash());
    Assert.assertEquals(3, txInfo0.get().getIndex());
    Assert.assertArrayEquals(receipt0.getEncoded(), txInfo0.get().getReceipt().getEncoded());
    Optional<TransactionInfo> txInfo = store.get(receipt.getTransaction().getHash().getBytes(), blockHash);
    Assert.assertTrue(txInfo.isPresent());
    Assert.assertNotNull(txInfo.get().getBlockHash());
    Assert.assertArrayEquals(blockHash, txInfo.get().getBlockHash());
    Assert.assertEquals(42, txInfo.get().getIndex());
    Assert.assertArrayEquals(receipt.getEncoded(), txInfo.get().getReceipt().getEncoded());
}
Also used : TransactionReceipt(org.ethereum.core.TransactionReceipt) 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