@Override public TransactionReceipt getTransactionReceipt(String branchId, String txId) { return branchGroup.getTransactionReceiptStore(BranchId.of(branchId)).get(txId); } }
public TransactionReceiptStore buildTransactionReciptStore(BranchId branchId) { return new TransactionReceiptStore(getDbSource(branchId + "/txreceipt")); }
public void commitBlockResult(BlockRuntimeResult result) { // TODO store transaction bybatch Map<String, JsonObject> changes = result.getBlockResult(); result.getTxReceipts().stream().forEach(txr -> { txReceiptStore.put(txr); }); if (!changes.isEmpty()) { changes.entrySet().stream().forEach(r -> { stateStore.put(r.getKey(), r.getValue()); }); } // TODO make transaction Receipt Event }
@Test public void testTransctionReceipt() { TransactionReceipt receipt = new TransactionReceiptImpl(); receipt.setTxId("TEST_TRANSACTION_1234512345"); receipt.setStatus(ExecuteStatus.SUCCESS); store.put(receipt); TransactionReceipt receipt2 = store.get("TEST_TRANSACTION_1234512345"); assert receipt.getTxId().equalsIgnoreCase(receipt2.getTxId()); assert receipt.getStatus() == receipt2.getStatus(); }
public void close() { this.blockStore.close(); this.transactionStore.close(); this.metaStore.close(); // TODO refactoring this.stateStore.close(); this.transactionReceiptStore.close(); }
@Before public void setUp() { store = new TransactionReceiptStore(new HashMapDbSource()); }
@Test public void getTransactionReceiptTest() { when(txReceiptStoreMock.get(txId)).thenReturn(txReceipt); TransactionReceipt res = txApiImpl.getTransactionReceipt(branchId.toString(), txId); assertEquals(res.getTxId(), txId); }
@Test public void testPutTransctionReceipt() { TransactionReceipt receipt = new TransactionReceiptImpl(); receipt.setTxId("TEST_TRANSACTION"); receipt.setStatus(ExecuteStatus.SUCCESS); store.put(receipt); }
new Runtime<>( new StateStore<>(new HashMapDbSource()), new TransactionReceiptStore(new HashMapDbSource())); runtime.addContract(stemContract, contract);
@Test public void yeedRuntimeTest() { CoinContract contract = new CoinContract(); ContractId coinContract = Constants.YEED_CONTRACT_ID; Runtime runtime = new Runtime<>( new StateStore<>(new HashMapDbSource()), new TransactionReceiptStore(new HashMapDbSource()) ); String genesisStr = "{\"alloc\": {\"c91e9d46dd4b7584f0b6348ee18277c10fd7cb94\":" + " {\"balance\": \"1000000000\"},\"1a0cdead3d1d1dbeef848fef9053b4f0ae06db9e\":" + " {\"balance\": \"1000000000\"},\"cee3d4755e47055b530deeba062c5bd0c17eb00f\":" + " {\"balance\": \"998000000000\"}}}"; JsonObject genesisParams = JsonUtil.parseJsonObject(genesisStr); runtime.addContract(coinContract, contract); BranchId branchId = TestConstants.YEED; TransactionBuilder builder = new TransactionBuilder(); TransactionHusk testTx = builder.setBranchId(branchId) .addTxBody(coinContract, "genesis", genesisParams) .setWallet(TestConstants.wallet()) .build(); TransactionRuntimeResult result = runtime.invoke(testTx); assertThat(result.getReceipt().isSuccess()).isTrue(); assertThat(result.getChangeValues() .get("c91e9d46dd4b7584f0b6348ee18277c10fd7cb94") .get("balance").getAsBigDecimal() ).isEqualTo(BigDecimal.valueOf(1000000000)); }
@Test public void executorTest() { CoinContract contract = new CoinContract(); Runtime runtime = new Runtime<>( new StateStore<>(new HashMapDbSource()), new TransactionReceiptStore(new HashMapDbSource()) ); runtime.addContract(ContractId.of("c10e873655becf550c4aece75a091f4553d6202d"), contract); // Block Store // Blockchain Runtime StoreBuilder builder = new StoreBuilder(new DefaultConfig(false)); BlockStore store = builder.buildBlockStore(BRANCH_ID); MetaStore meta = builder.buildMetaStore(BRANCH_ID); BlockExecutor ex = new BlockExecutor(store, meta, runtime); // BlockStore add genesis block and other ex.runExecuteBlocks(); } }