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"));
}
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"));
}
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());
}
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());
}
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());
}
Aggregations