Skip to content

Commit

Permalink
<test>(integration): add receipt test. (#768)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyonRay authored Apr 19, 2023
1 parent c00ccab commit a0e3ae6
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Base64;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;

import org.apache.commons.collections4.ListUtils;
Expand All @@ -36,6 +37,7 @@
import org.fisco.bcos.sdk.v3.codec.datatypes.generated.Int256;
import org.fisco.bcos.sdk.v3.crypto.keypair.CryptoKeyPair;
import org.fisco.bcos.sdk.v3.model.ConstantConfig;
import org.fisco.bcos.sdk.v3.model.EnumNodeVersion;
import org.fisco.bcos.sdk.v3.model.PrecompiledRetCode;
import org.fisco.bcos.sdk.v3.model.TransactionReceipt;
import org.fisco.bcos.sdk.v3.model.callback.TransactionCallback;
Expand Down Expand Up @@ -91,6 +93,26 @@ public void test1HelloWorld() throws Exception {
Assert.assertEquals(response.getTransactionReceipt().getStatus(), 0);
Assert.assertEquals(response.getReturnCode(), 0);
Assert.assertEquals(0, response.getTransactionReceipt().getStatus());

TransactionReceipt transactionReceipt = response.getTransactionReceipt();
// test TransactionReceipt all fields
Assert.assertTrue(Objects.nonNull(transactionReceipt.getTransactionHash()) && StringUtils.isNotBlank(transactionReceipt.getTransactionHash()));
Assert.assertTrue(Objects.nonNull(transactionReceipt.getGasUsed()) && StringUtils.isNotBlank(transactionReceipt.getGasUsed()) && Integer.parseInt(transactionReceipt.getGasUsed()) > 0);
Assert.assertTrue(Objects.nonNull(transactionReceipt.getVersion()) && transactionReceipt.getVersion() >= 0);
Assert.assertTrue(Objects.nonNull(transactionReceipt.getBlockNumber()) && transactionReceipt.getBlockNumber().compareTo(BigInteger.ZERO) >= 0);
Assert.assertTrue(Objects.nonNull(transactionReceipt.getOutput()) && StringUtils.isNotBlank(transactionReceipt.getOutput()));
Assert.assertTrue(Objects.nonNull(transactionReceipt.getReceiptHash()) && StringUtils.isNotBlank(transactionReceipt.getReceiptHash()));
Assert.assertTrue(Objects.nonNull(transactionReceipt.getFrom()) && StringUtils.isNotBlank(transactionReceipt.getFrom()));
if (client.getChainVersion().compareToVersion(EnumNodeVersion.BCOS_3_1_0) >= 0) {
Assert.assertTrue(Objects.nonNull(transactionReceipt.getChecksumContractAddress()) && StringUtils.isNotBlank(transactionReceipt.getChecksumContractAddress()));
Assert.assertTrue(transactionReceipt.getChecksumContractAddress().equalsIgnoreCase(transactionReceipt.getContractAddress()));
}
Assert.assertTrue(Objects.nonNull(transactionReceipt.getTo()));

if (client.getChainVersion().compareToVersion(EnumNodeVersion.BCOS_3_3_0) >= 0) {
Assert.assertTrue(Objects.nonNull(transactionReceipt.getInput()) && StringUtils.isNotBlank(transactionReceipt.getInput()));
}

String helloWorldAddress = response.getContractAddress();
Assert.assertTrue(
StringUtils.isNotBlank(response.getContractAddress())
Expand Down

0 comments on commit a0e3ae6

Please sign in to comment.