Skip to content

Commit

Permalink
Update integration tests to work with new event systems
Browse files Browse the repository at this point in the history
  • Loading branch information
tramonex-nate committed Feb 1, 2017
1 parent 676dce8 commit 6e5c787
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ public void testFibonacciNotify() throws Exception {
TransactionReceipt transactionReceipt = fibonacci.fibonacciNotify(
new Uint256(BigInteger.valueOf(15))).get();

EventValues result = fibonacci.processNotifyEvent(transactionReceipt);
Fibonacci.NotifyEventResponse result = fibonacci.getNotifyEvents(transactionReceipt).get(0);

assertThat(result.getNonIndexedValues(),
equalTo(Arrays.asList(
new Uint256(BigInteger.valueOf(15)),
new Uint256(BigInteger.valueOf(610)))));
assertThat(result.input,
equalTo(new Uint256(BigInteger.valueOf(15))));

assertThat(result.result,
equalTo(new Uint256(BigInteger.valueOf(610))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
import static org.web3j.generated.HumanStandardToken.*;

/**
* Generated HumanStandardToken integration test for all supported scenarios.
Expand All @@ -27,7 +28,7 @@ public void testContract() throws Exception {
BigInteger aliceQty = BigInteger.valueOf(1_000_000);
BigInteger bobQty = BigInteger.ZERO;

HumanStandardToken contract = HumanStandardToken.deploy(parity, ALICE,
HumanStandardToken contract = deploy(parity, ALICE,
GAS_PRICE, GAS_LIMIT,
BigInteger.ZERO,
new Uint256(aliceQty), new Utf8String("web3j tokens"),
Expand All @@ -51,14 +52,13 @@ public void testContract() throws Exception {
assertThat(contract.balanceOf(new Address(BOB.getAddress())).get(),
equalTo(new Uint256(bobQty)));

EventValues aliceTransferEventValues = contract.processTransferEvent(aliceTransferReceipt);
assertThat(aliceTransferEventValues.getIndexedValues(),
equalTo(Arrays.asList(
new Address(ALICE.getAddress()),
new Address(BOB.getAddress()))));
assertThat(aliceTransferEventValues.getNonIndexedValues(),
equalTo(Collections.singletonList(
new Uint256(transferQuantity))));
TransferEventResponse aliceTransferEventValues = contract.getTransferEvents(aliceTransferReceipt).get(0);
assertThat(aliceTransferEventValues._from,
equalTo(ALICE.getAddress()));
assertThat(aliceTransferEventValues._to,
equalTo(BOB.getAddress()));
assertThat(aliceTransferEventValues._value,
equalTo(new Uint256(transferQuantity)));

// set an allowance
assertThat(contract.allowance(
Expand All @@ -68,14 +68,13 @@ public void testContract() throws Exception {
transferQuantity = BigInteger.valueOf(50);
TransactionReceipt approveReceipt = contract.approve(new Address(BOB.getAddress()), new Uint256(transferQuantity)).get();

EventValues approvalEventValues = contract.processApprovalEvent(approveReceipt);
assertThat(approvalEventValues.getIndexedValues(),
equalTo(Arrays.asList(
new Address(ALICE.getAddress()),
new Address(BOB.getAddress()))));
assertThat(approvalEventValues.getNonIndexedValues(),
equalTo(Collections.singletonList(
new Uint256(transferQuantity))));
ApprovalEventResponse approvalEventValues = contract.getApprovalEvents(approveReceipt).get(0);
assertThat(approvalEventValues._owner,
equalTo(ALICE.getAddress()));
assertThat(approvalEventValues._spender,
equalTo(BOB.getAddress()));
assertThat(approvalEventValues._value,
equalTo(new Uint256(transferQuantity)));

assertThat(contract.allowance(
new Address(ALICE.getAddress()), new Address(BOB.getAddress())).get(),
Expand All @@ -101,13 +100,12 @@ public void testContract() throws Exception {
assertThat(contract.balanceOf(new Address(BOB.getAddress())).get(),
equalTo(new Uint256(bobQty)));

EventValues bobTransferEventValues = contract.processTransferEvent(bobTransferReceipt);
assertThat(bobTransferEventValues.getIndexedValues(),
equalTo(Arrays.asList(
new Address(ALICE.getAddress()),
new Address(BOB.getAddress()))));
assertThat(bobTransferEventValues.getNonIndexedValues(),
equalTo(Collections.singletonList(
new Uint256(transferQuantity))));
TransferEventResponse bobTransferEventValues = contract.getTransferEvents(bobTransferReceipt).get(0);
assertThat(bobTransferEventValues._from,
equalTo(ALICE.getAddress()));
assertThat(bobTransferEventValues._to,
equalTo(BOB.getAddress()));
assertThat(bobTransferEventValues._value,
equalTo(new Uint256(transferQuantity)));
}
}

0 comments on commit 6e5c787

Please sign in to comment.