This commit is contained in:
Michele Balistreri 2020-04-29 13:33:14 +03:00
parent e118c153f9
commit 6a243df6e1
No known key found for this signature in database
GPG Key ID: E9567DA33A4F791A
3 changed files with 10 additions and 2 deletions

View File

@ -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 {

View File

@ -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();

View File

@ -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}`);
}