From 6a243df6e1f9e257a8b4f12c95357e4b8e8e908e Mon Sep 17 00:00:00 2001 From: Michele Balistreri Date: Wed, 29 Apr 2020 13:33:14 +0300 Subject: [PATCH] close #13 --- contracts/Bucket.sol | 3 +++ test/contract_spec.js | 4 +++- test/nft_contract_spec.js | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/contracts/Bucket.sol b/contracts/Bucket.sol index e4124f3..c12fc7c 100644 --- a/contracts/Bucket.sol +++ b/contracts/Bucket.sol @@ -26,6 +26,8 @@ abstract contract Bucket { bytes32 code; } + event Redeemed(address indexed recipient, uint256 indexed data); + mapping(address => Redeemable) public redeemables; modifier onlyOwner() { @@ -79,6 +81,7 @@ abstract contract Bucket { redeemable.data = 0; transferRedeemable(data, _redeem); + emit Redeemed(recipient, data); } function kill() external onlyOwner { diff --git a/test/contract_spec.js b/test/contract_spec.js index 416f196..163bee6 100644 --- a/test/contract_spec.js +++ b/test/contract_spec.js @@ -276,11 +276,13 @@ contract("ERC20Bucket", function () { const sig = await signRedeem(ERC20Bucket._address, signer, message); const redeem = ERC20Bucket.methods.redeem(message, sig); const redeemGas = await redeem.estimateGas(); - await redeem.send({ + let receipt = await redeem.send({ from: relayer, gas: redeemGas, }); + assert.equal(receipt.events.Redeemed.returnValues.recipient, recipient); + assert.equal(receipt.events.Redeemed.returnValues.data, redeemable.data); let expectedBucketBalance = parseInt(initialBucketBalance) - amount; let bucketBalance = await TestToken.methods.balanceOf(ERC20Bucket._address).call(); diff --git a/test/nft_contract_spec.js b/test/nft_contract_spec.js index e1502f8..e535afb 100644 --- a/test/nft_contract_spec.js +++ b/test/nft_contract_spec.js @@ -221,11 +221,14 @@ contract("NFTBucket", function () { const sig = await signRedeem(NFTBucket._address, signer, message); const redeem = NFTBucket.methods.redeem(message, sig); const redeemGas = await redeem.estimateGas(); - await redeem.send({ + let receipt = await redeem.send({ from: relayer, gas: redeemGas, }); + assert.equal(receipt.events.Redeemed.returnValues.recipient, recipient); + assert.equal(receipt.events.Redeemed.returnValues.data, tokenID); + let tokenOwner = await TestNFT.methods.ownerOf(tokenID).call(); assert.equal(tokenOwner, receiver, `Token owner is ${tokenOwner} instead of the expected ${receiver}`); }