Search in sources :

Example 41 with Transaction

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

the class TraceModuleImplTest method retrieveSimpleContractCreationTrace.

@Test
public void retrieveSimpleContractCreationTrace() throws Exception {
    DslParser parser = DslParser.fromResource("dsl/contracts01.txt");
    ReceiptStore receiptStore = new ReceiptStoreImpl(new HashMapDB());
    World world = new World(receiptStore);
    WorldDslProcessor processor = new WorldDslProcessor(world);
    processor.processCommands(parser);
    Transaction transaction = world.getTransactionByName("tx01");
    TraceModuleImpl traceModule = new TraceModuleImpl(world.getBlockChain(), world.getBlockStore(), receiptStore, world.getBlockExecutor());
    JsonNode result = traceModule.traceTransaction(transaction.getHash().toJsonString());
    Assert.assertNotNull(result);
    Assert.assertTrue(result.isArray());
    ArrayNode aresult = (ArrayNode) result;
    Assert.assertEquals(1, aresult.size());
    Assert.assertTrue(result.get(0).isObject());
    ObjectNode oresult = (ObjectNode) result.get(0);
    Assert.assertNotNull(oresult.get("type"));
    Assert.assertEquals("\"create\"", oresult.get("type").toString());
    Assert.assertNotNull(oresult.get("action"));
    Assert.assertNull(oresult.get("action").get("creationMethod"));
    Assert.assertNotNull(oresult.get("action").get("init"));
    Assert.assertNull(oresult.get("action").get("input"));
}
Also used : ReceiptStoreImpl(org.ethereum.db.ReceiptStoreImpl) WorldDslProcessor(co.rsk.test.dsl.WorldDslProcessor) Transaction(org.ethereum.core.Transaction) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DslParser(co.rsk.test.dsl.DslParser) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) HashMapDB(org.ethereum.datasource.HashMapDB) World(co.rsk.test.World) ReceiptStore(org.ethereum.db.ReceiptStore) Test(org.junit.Test)

Example 42 with Transaction

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

the class TraceModuleImplTest method retrieveSuicideInvocationTrace.

private static void retrieveSuicideInvocationTrace(World world, ReceiptStore receiptStore, String txname) throws Exception {
    Transaction transaction = world.getTransactionByName(txname);
    TraceModuleImpl traceModule = new TraceModuleImpl(world.getBlockChain(), world.getBlockStore(), receiptStore, world.getBlockExecutor());
    JsonNode result = traceModule.traceTransaction(transaction.getHash().toJsonString());
    Assert.assertNotNull(result);
    Assert.assertTrue(result.isArray());
    ArrayNode aresult = (ArrayNode) result;
    Assert.assertEquals(2, aresult.size());
    Assert.assertTrue(result.get(1).isObject());
    ObjectNode oresult = (ObjectNode) result.get(1);
    Assert.assertNotNull(oresult.get("type"));
    Assert.assertEquals("\"suicide\"", oresult.get("type").toString());
    Assert.assertNotNull(oresult.get("action"));
    Assert.assertNull(oresult.get("action").get("from"));
    Assert.assertNotNull(oresult.get("action").get("address"));
    Assert.assertNotNull(oresult.get("action").get("refundAddress"));
    Assert.assertNotNull(oresult.get("action").get("balance"));
}
Also used : Transaction(org.ethereum.core.Transaction) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 43 with Transaction

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

the class TraceModuleImplTest method retrieveSimpleAccountTransfer.

@Test
public void retrieveSimpleAccountTransfer() throws Exception {
    DslParser parser = DslParser.fromResource("dsl/transfers01.txt");
    ReceiptStore receiptStore = new ReceiptStoreImpl(new HashMapDB());
    World world = new World(receiptStore);
    WorldDslProcessor processor = new WorldDslProcessor(world);
    processor.processCommands(parser);
    Transaction transaction = world.getTransactionByName("tx01");
    TraceModuleImpl traceModule = new TraceModuleImpl(world.getBlockChain(), world.getBlockStore(), receiptStore, world.getBlockExecutor());
    JsonNode result = traceModule.traceTransaction(transaction.getHash().toJsonString());
    Assert.assertNotNull(result);
    Assert.assertTrue(result.isArray());
    ArrayNode aresult = (ArrayNode) result;
    Assert.assertEquals(1, aresult.size());
    Assert.assertTrue(result.get(0).isObject());
    ObjectNode oresult = (ObjectNode) result.get(0);
    Assert.assertNotNull(oresult.get("type"));
    Assert.assertEquals("\"call\"", oresult.get("type").toString());
}
Also used : ReceiptStoreImpl(org.ethereum.db.ReceiptStoreImpl) WorldDslProcessor(co.rsk.test.dsl.WorldDslProcessor) Transaction(org.ethereum.core.Transaction) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DslParser(co.rsk.test.dsl.DslParser) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) HashMapDB(org.ethereum.datasource.HashMapDB) World(co.rsk.test.World) ReceiptStore(org.ethereum.db.ReceiptStore) Test(org.junit.Test)

Example 44 with Transaction

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

the class TxPoolModuleImplTest method txpool_status_manyTxs.

@Test
public void txpool_status_manyTxs() {
    Transaction tx1 = createSampleTransaction();
    Transaction tx2 = createSampleTransaction();
    Transaction tx3 = createSampleTransaction();
    Transaction tx4 = createSampleTransaction();
    List<Transaction> transactions = Arrays.asList(tx1, tx2, tx3);
    List<Transaction> txs = Arrays.asList(tx1, tx4);
    when(transactionPool.getPendingTransactions()).thenReturn(transactions);
    when(transactionPool.getQueuedTransactions()).thenReturn(txs);
    JsonNode node = txPoolModule.status();
    JsonNode queuedNode = checkFieldIsNumber(node, "queued");
    JsonNode pendingNode = checkFieldIsNumber(node, "pending");
    Assert.assertEquals(txs.size(), queuedNode.asInt());
    Assert.assertEquals(transactions.size(), pendingNode.asInt());
}
Also used : Transaction(org.ethereum.core.Transaction) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 45 with Transaction

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

the class PendingTransactionsNotificationEmitterTest method notificationContainsHashedTransaction.

@Test
public void notificationContainsHashedTransaction() {
    SubscriptionId subscriptionId = new SubscriptionId(("0x7392"));
    Transaction transaction = TransactionUtils.createTransaction();
    EthSubscriptionNotification<String> notification = emitter.getNotification(subscriptionId, transaction);
    assertEquals(transaction.getHash().toJsonString(), notification.getParams().getResult());
    assertEquals(subscriptionId, notification.getParams().getSubscription());
}
Also used : Transaction(org.ethereum.core.Transaction) Test(org.junit.Test)

Aggregations

Transaction (org.ethereum.core.Transaction)257 Test (org.junit.Test)166 Block (org.ethereum.core.Block)73 RskAddress (co.rsk.core.RskAddress)69 ActivationConfigsForTest (org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)57 InternalTransaction (org.ethereum.vm.program.InternalTransaction)57 SimpleRskTransaction (co.rsk.peg.simples.SimpleRskTransaction)39 ActivationConfig (org.ethereum.config.blockchain.upgrades.ActivationConfig)39 BigInteger (java.math.BigInteger)38 ArrayList (java.util.ArrayList)38 Repository (org.ethereum.core.Repository)35 JsonNode (com.fasterxml.jackson.databind.JsonNode)32 ECKey (org.ethereum.crypto.ECKey)30 co.rsk.bitcoinj.core (co.rsk.bitcoinj.core)29 Keccak256 (co.rsk.crypto.Keccak256)28 Account (org.ethereum.core.Account)26 World (co.rsk.test.World)23 DslParser (co.rsk.test.dsl.DslParser)23 WorldDslProcessor (co.rsk.test.dsl.WorldDslProcessor)23 MutableRepository (org.ethereum.db.MutableRepository)22