| @@ -110,6 +110,8 @@ public class IntegrationBase { | |||||
| TransactionTemplate txTpl = blockchainService.newTransaction(ledgerHash); | TransactionTemplate txTpl = blockchainService.newTransaction(ledgerHash); | ||||
| txTpl.dataAccounts().register(dataAccount.getIdentity()); | txTpl.dataAccounts().register(dataAccount.getIdentity()); | ||||
| txTpl.dataAccount(dataAccount.getAddress()).set("total", 200, -1); | txTpl.dataAccount(dataAccount.getAddress()).set("total", 200, -1); | ||||
| // txTpl.dataAccount(dataAccount.getAddress()).set("param1", "v", -1); | |||||
| // txTpl.dataAccount(dataAccount.getAddress()).set("param2", 200, -1); | |||||
| // 签名; | // 签名; | ||||
| PreparedTransaction ptx = txTpl.prepare(); | PreparedTransaction ptx = txTpl.prepare(); | ||||
| @@ -473,6 +475,7 @@ public class IntegrationBase { | |||||
| // execute the contract; | // execute the contract; | ||||
| testContractExe(adminKey, ledgerHash, keyPairResponse.keyPair, blockchainService, ledgerRepository); | testContractExe(adminKey, ledgerHash, keyPairResponse.keyPair, blockchainService, ledgerRepository); | ||||
| testContractExe1(adminKey, ledgerHash, keyPairResponse.keyPair, blockchainService, ledgerRepository); | |||||
| return block; | return block; | ||||
| } | } | ||||
| @@ -490,7 +493,6 @@ public class IntegrationBase { | |||||
| // contractDeployKey.getAddress().toBase58(),321123); | // contractDeployKey.getAddress().toBase58(),321123); | ||||
| txTpl.contract(contractDeployKey.getAddress(),AssetContract2.class).issue(byteObj, | txTpl.contract(contractDeployKey.getAddress(),AssetContract2.class).issue(byteObj, | ||||
| dataKey.getAddress().toBase58(),Bytes.fromString("123321")); | dataKey.getAddress().toBase58(),Bytes.fromString("123321")); | ||||
| // txTpl.contract(contractDeployKey.getAddress(),AssetContract2.class).issue(byteObj,dataKey.getAddress().toBase58(),123456); | |||||
| // 签名; | // 签名; | ||||
| PreparedTransaction ptx = txTpl.prepare(); | PreparedTransaction ptx = txTpl.prepare(); | ||||
| @@ -507,6 +509,34 @@ public class IntegrationBase { | |||||
| assertEquals("100",kvDataEntries[0].getValue().toString()); | assertEquals("100",kvDataEntries[0].getValue().toString()); | ||||
| } | } | ||||
| private static <T> void testContractExe1(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainKeypair dataKey, | |||||
| BlockchainService blockchainService,LedgerRepository ledgerRepository) { | |||||
| LedgerInfo ledgerInfo = blockchainService.getLedger(ledgerHash); | |||||
| LedgerBlock previousBlock = blockchainService.getBlock(ledgerHash, ledgerInfo.getLatestBlockHeight() - 1); | |||||
| // 定义交易; | |||||
| TransactionTemplate txTpl = blockchainService.newTransaction(ledgerHash); | |||||
| AssetContract2 assetContract = txTpl.contract(contractDeployKey.getAddress(), AssetContract2.class); | |||||
| ContractBizContent contractBizContent = () -> new String[]{"param1","param2"}; | |||||
| assetContract.issue(contractBizContent,dataKey.getAddress().toBase58(),123456); | |||||
| // 签名; | |||||
| PreparedTransaction ptx = txTpl.prepare(); | |||||
| ptx.sign(adminKey); | |||||
| // 提交并等待共识返回; | |||||
| TransactionResponse txResp = ptx.commit(); | |||||
| // 验证结果; | |||||
| Assert.assertTrue(txResp.isSuccess()); | |||||
| assertEquals(ptx.getHash(),txResp.getContentHash()); | |||||
| LedgerBlock block = ledgerRepository.getBlock(txResp.getBlockHeight()); | |||||
| KVDataEntry[] kvDataEntries = ledgerRepository.getDataAccountSet(block).getDataAccount(dataKey.getAddress()).getDataEntries(1,2); | |||||
| assertEquals("value1",kvDataEntries[0].getValue().toString()); | |||||
| assertEquals(888L,kvDataEntries[1].getValue()); | |||||
| } | |||||
| /** | /** | ||||
| * 根据合约构建字节数组; | * 根据合约构建字节数组; | ||||
| * | * | ||||