Skip to content

Commit

Permalink
<rec&fix>(transaction): refator transaction request, fix v2 assemble …
Browse files Browse the repository at this point in the history
…transaction service bug.
  • Loading branch information
kyonRay committed Dec 28, 2023
1 parent 985e86b commit c344840
Show file tree
Hide file tree
Showing 9 changed files with 459 additions and 320 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public void test2ComplexCodecWithStringParams() throws Exception {
String abi = abiAndBinaryByContractName.getKey();
TransactionRequestBuilder requestBuilder = new TransactionRequestBuilder(abi, abiAndBinaryByContractName.getValue());
DeployTransactionRequestWithStringParams deployTransactionRequestWithStringParams = requestBuilder.buildDeployStringParamsRequest(deployParams);
TransactionResponse response = transactionService.deployContractWithStringParams(deployTransactionRequestWithStringParams);
TransactionResponse response = transactionService.deployContract(deployTransactionRequestWithStringParams);
Assert.assertEquals(response.getTransactionReceipt().getStatus(), 0);
String contractAddress = response.getContractAddress();
Assert.assertTrue(StringUtils.isNotBlank(response.getContractAddress()));
Expand All @@ -320,7 +320,7 @@ public void test2ComplexCodecWithStringParams() throws Exception {
List<String> callParams = new ArrayList<>();
// use no params method
TransactionRequestWithStringParams request = requestBuilder.setMethod("getStructA").setTo(contractAddress).buildStringParamsRequest(callParams);
CallResponse callResponse = transactionService.sendCallWithStringParams(request);
CallResponse callResponse = transactionService.sendCall(request);
List<Object> returnObject = callResponse.getReturnObject();
Assert.assertEquals(returnObject.size(), 1);
Assert.assertEquals(callResponse.getReturnABIObject().size(), 1);
Expand All @@ -329,7 +329,7 @@ public void test2ComplexCodecWithStringParams() throws Exception {
// use one params method
callParams.add("[[\"test2312312312312\"],[\"ffffffff1234567890123456ffffffffffffffff1234567890123456ffffffff\"]]");
TransactionRequestWithStringParams request2 = requestBuilder.setMethod("getStructA").setTo(contractAddress).buildStringParamsRequest(callParams);
CallResponse callResponse2 = transactionService.sendCallWithStringParams(request2);
CallResponse callResponse2 = transactionService.sendCall(request2);
returnObject = callResponse2.getReturnObject();
Assert.assertEquals(returnObject.size(), 1);
Assert.assertEquals(callResponse2.getReturnABIObject().size(), 1);
Expand All @@ -341,7 +341,7 @@ public void test2ComplexCodecWithStringParams() throws Exception {
List<String> params = new ArrayList<>();
params.add("[[\"0xabcd\"],[\"0x1234\"]]");
TransactionRequestWithStringParams transactionRequestWithStringParams = requestBuilder.setMethod("setBytesArrayArray").setTo(contractAddress).buildStringParamsRequest(params);
TransactionResponse transactionResponse = transactionService.sendTransactionWithStringParams(transactionRequestWithStringParams);
TransactionResponse transactionResponse = transactionService.sendTransaction(transactionRequestWithStringParams);
Assert.assertEquals(transactionResponse.getTransactionReceipt().getStatus(), 0);
List<Type> results = transactionResponse.getResults();
List<Object> returnObject = transactionResponse.getReturnObject();
Expand All @@ -357,7 +357,7 @@ public void test2ComplexCodecWithStringParams() throws Exception {
List<String> params = new ArrayList<>();
params.add("[[\"0xffffffff1234567890123456ffffffffffffffff1234567890123456ffffffff\",\"0xffffffff1234567890123456ffffffffffffffff1234567890123456ffffffff\"],[\"0xffffffff1234567890123456ffffffffffffffff1234567890123456ffffffff\"]]");
TransactionRequestWithStringParams transactionRequestWithStringParams = requestBuilder.setMethod("setBytes32ArrayArray").buildStringParamsRequest(params);
TransactionResponse transactionResponse = transactionService.sendTransactionWithStringParams(transactionRequestWithStringParams);
TransactionResponse transactionResponse = transactionService.sendTransaction(transactionRequestWithStringParams);
Assert.assertEquals(transactionResponse.getTransactionReceipt().getStatus(), 0);
List<Type> results = transactionResponse.getResults();
List<Object> returnObject = transactionResponse.getReturnObject();
Expand All @@ -375,7 +375,7 @@ public void test2ComplexCodecWithStringParams() throws Exception {
List<String> params = new ArrayList<>();
params.add("[[\"0xabcdef\",\"0xffffffff1234567890123456ffffffffffffffff1234567890123456ffffffff\"],[\"0xffffffff1234567890123456ffffffffffffffff1234567890123456ffffffff\",\"0x1234\"]]");
TransactionRequestWithStringParams transactionRequestWithStringParams = requestBuilder.setMethod("setBytesStaticArrayArray").buildStringParamsRequest(params);
TransactionResponse transactionResponse = transactionService.sendTransactionWithStringParams(transactionRequestWithStringParams);
TransactionResponse transactionResponse = transactionService.sendTransaction(transactionRequestWithStringParams);
Assert.assertEquals(transactionResponse.getTransactionReceipt().getStatus(), 0);
List<Type> results = transactionResponse.getResults();
List<Object> returnObject = transactionResponse.getReturnObject();
Expand All @@ -393,7 +393,7 @@ public void test2ComplexCodecWithStringParams() throws Exception {
List<String> params = new ArrayList<>();
params.add("[[\"0x1234567890123456789012345678901234567890123456789012345678901234\",\"0xffffffff1234567890123456ffffffffffffffff1234567890123456ffffffff\"],[\"0x1234567890123456789012345678901234567890123456789012345678901234\",\"0xffffffff1234567890123456ffffffffffffffff1234567890123456ffffffff\"],[\"0xffffffff1234567890123456ffffffffffffffff1234567890123456ffffffff\",\"0x1234567890123456789012345678901234567890123456789012345678901234\"]]");
TransactionRequestWithStringParams transactionRequestWithStringParams = requestBuilder.setMethod("setBytes32StaticArrayArray").buildStringParamsRequest(params);
TransactionResponse transactionResponse = transactionService.sendTransactionWithStringParams(transactionRequestWithStringParams);
TransactionResponse transactionResponse = transactionService.sendTransaction(transactionRequestWithStringParams);
Assert.assertEquals(transactionResponse.getTransactionReceipt().getStatus(), 0);
List<Type> results = transactionResponse.getResults();
List<Object> returnObject = transactionResponse.getReturnObject();
Expand All @@ -411,7 +411,7 @@ public void test2ComplexCodecWithStringParams() throws Exception {
List<String> params = new ArrayList<>();
params.add("[[\"12312314565456345test\"],[\"ffffffff1234567890123456ffffffffffffffff1234567890123456ffffffff\"]]");
TransactionRequestWithStringParams transactionRequestWithStringParams = requestBuilder.setMethod("buildStructB").buildStringParamsRequest(params);
TransactionResponse transactionResponse = transactionService.sendTransactionWithStringParams(transactionRequestWithStringParams);
TransactionResponse transactionResponse = transactionService.sendTransaction(transactionRequestWithStringParams);

Assert.assertEquals(transactionResponse.getTransactionReceipt().getStatus(), 0);
List<Type> results = transactionResponse.getResults();
Expand All @@ -430,7 +430,7 @@ public void test2ComplexCodecWithStringParams() throws Exception {
params.add("[-128,129,[32]]");
// use static struct params, get single struct
TransactionRequestWithStringParams transactionRequestWithStringParams = requestBuilder.setMethod("buildStaticStruct").buildStringParamsRequest(params);
TransactionResponse transactionResponse = transactionService.sendTransactionWithStringParams(transactionRequestWithStringParams);
TransactionResponse transactionResponse = transactionService.sendTransaction(transactionRequestWithStringParams);

Assert.assertEquals(transactionResponse.getTransactionReceipt().getStatus(), 0);
List<Type> results = transactionResponse.getResults();
Expand All @@ -447,7 +447,7 @@ public void test2ComplexCodecWithStringParams() throws Exception {
params2.add("-256");
params2.add("12321421");
TransactionRequestWithStringParams transactionRequestWithStringParams2 = requestBuilder.setMethod("buildStaticStruct").buildStringParamsRequest(params2);
TransactionResponse transactionResponse2 = transactionService.sendTransactionWithStringParams(transactionRequestWithStringParams2);
TransactionResponse transactionResponse2 = transactionService.sendTransaction(transactionRequestWithStringParams2);
Assert.assertEquals(transactionResponse.getTransactionReceipt().getStatus(), 0);
results = transactionResponse2.getResults();
returnObject = transactionResponse2.getReturnObject();
Expand Down
Loading

0 comments on commit c344840

Please sign in to comment.