public TransactionReceiptStore buildTransactionReciptStore(BranchId branchId) { return new TransactionReceiptStore(getDbSource(branchId + "/txreceipt")); }
@Before public void setUp() { store = new TransactionReceiptStore(new HashMapDbSource()); }
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(); } }