Skip to content

Commit

Permalink
Merge pull request hyperledger-web3j#493 from e-Contract/transaction-…
Browse files Browse the repository at this point in the history
…receipt-isStatusOK

isStatusOK on TransactionReceipt
  • Loading branch information
conor10 authored Apr 20, 2018
2 parents 3f3bc56 + 9f71630 commit b86ace8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ public void setStatus(String status) {
this.status = status;
}

public boolean isStatusOK() {
if (null == status) {
return true;
}
BigInteger statusQuantity = Numeric.decodeQuantity(status);
return BigInteger.ONE.equals(statusQuantity);
}

public String getFrom() {
return from;
}
Expand Down
14 changes: 14 additions & 0 deletions core/src/test/java/org/web3j/protocol/core/ResponseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,20 @@ public void testeEthGetTransactionReceiptAfterByzantium() {
equalTo(transactionReceipt));
}

@Test
public void testTransactionReceiptIsStatusOK() {
TransactionReceipt transactionReceipt = new TransactionReceipt();
transactionReceipt.setStatus("0x1");
assertThat(transactionReceipt.isStatusOK(), equalTo(true));

TransactionReceipt transactionReceiptNoStatus = new TransactionReceipt();
assertThat(transactionReceiptNoStatus.isStatusOK(), equalTo(true));

TransactionReceipt transactionReceiptZeroStatus = new TransactionReceipt();
transactionReceiptZeroStatus.setStatus("0x0");
assertThat(transactionReceiptZeroStatus.isStatusOK(), equalTo(false));
}

@Test
public void testEthGetCompilers() {
buildResponse(
Expand Down

0 comments on commit b86ace8

Please sign in to comment.