diff --git a/test/finance/PaymentSplitter.test.js b/test/finance/PaymentSplitter.test.js index 6df0c4cb9..fdb81f610 100644 --- a/test/finance/PaymentSplitter.test.js +++ b/test/finance/PaymentSplitter.test.js @@ -130,22 +130,22 @@ contract('PaymentSplitter', function (accounts) { // distribute to payees const tracker1 = await balance.tracker(payee1); - const { logs: logs1 } = await this.contract.release(payee1); + const receipt1 = await this.contract.release(payee1); const profit1 = await tracker1.delta(); expect(profit1).to.be.bignumber.equal(ether('0.20')); - expectEvent.inLogs(logs1, 'PaymentReleased', { to: payee1, amount: profit1 }); + expectEvent(receipt1, 'PaymentReleased', { to: payee1, amount: profit1 }); const tracker2 = await balance.tracker(payee2); - const { logs: logs2 } = await this.contract.release(payee2); + const receipt2 = await this.contract.release(payee2); const profit2 = await tracker2.delta(); expect(profit2).to.be.bignumber.equal(ether('0.10')); - expectEvent.inLogs(logs2, 'PaymentReleased', { to: payee2, amount: profit2 }); + expectEvent(receipt2, 'PaymentReleased', { to: payee2, amount: profit2 }); const tracker3 = await balance.tracker(payee3); - const { logs: logs3 } = await this.contract.release(payee3); + const receipt3 = await this.contract.release(payee3); const profit3 = await tracker3.delta(); expect(profit3).to.be.bignumber.equal(ether('0.70')); - expectEvent.inLogs(logs3, 'PaymentReleased', { to: payee3, amount: profit3 }); + expectEvent(receipt3, 'PaymentReleased', { to: payee3, amount: profit3 }); // end balance should be zero expect(await balance.current(this.contract.address)).to.be.bignumber.equal('0'); diff --git a/test/governance/utils/Votes.behavior.js b/test/governance/utils/Votes.behavior.js index 17b49eaa9..aee227bdb 100644 --- a/test/governance/utils/Votes.behavior.js +++ b/test/governance/utils/Votes.behavior.js @@ -108,8 +108,8 @@ function shouldBehaveLikeVotes () { }), )); - const { logs } = await this.votes.delegateBySig(this.account1Delegatee, nonce, MAX_UINT256, v, r, s); - const { args } = logs.find(({ event }) => event === 'DelegateChanged'); + const receipt = await this.votes.delegateBySig(this.account1Delegatee, nonce, MAX_UINT256, v, r, s); + const { args } = receipt.logs.find(({ event }) => event === 'DelegateChanged'); expect(args.delegator).to.not.be.equal(delegatorAddress); expect(args.fromDelegate).to.be.equal(ZERO_ADDRESS); expect(args.toDelegate).to.be.equal(this.account1Delegatee); diff --git a/test/security/Pausable.test.js b/test/security/Pausable.test.js index 146815949..86701bcfd 100644 --- a/test/security/Pausable.test.js +++ b/test/security/Pausable.test.js @@ -32,11 +32,11 @@ contract('Pausable', function (accounts) { context('when paused', function () { beforeEach(async function () { - ({ logs: this.logs } = await this.pausable.pause({ from: pauser })); + (this.receipt = await this.pausable.pause({ from: pauser })); }); it('emits a Paused event', function () { - expectEvent.inLogs(this.logs, 'Paused', { account: pauser }); + expectEvent(this.receipt, 'Paused', { account: pauser }); }); it('cannot perform normal process in pause', async function () { @@ -60,11 +60,11 @@ contract('Pausable', function (accounts) { context('when unpaused', function () { beforeEach(async function () { - ({ logs: this.logs } = await this.pausable.unpause({ from: pauser })); + (this.receipt = await this.pausable.unpause({ from: pauser })); }); it('emits an Unpaused event', function () { - expectEvent.inLogs(this.logs, 'Unpaused', { account: pauser }); + expectEvent(this.receipt, 'Unpaused', { account: pauser }); }); it('should resume allowing normal process', async function () { diff --git a/test/token/ERC1155/ERC1155.behavior.js b/test/token/ERC1155/ERC1155.behavior.js index 0e87f5af1..4cdcfe1e7 100644 --- a/test/token/ERC1155/ERC1155.behavior.js +++ b/test/token/ERC1155/ERC1155.behavior.js @@ -165,9 +165,9 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, }); describe('setApprovalForAll', function () { - let logs; + let receipt; beforeEach(async function () { - ({ logs } = await this.token.setApprovalForAll(proxy, true, { from: multiTokenHolder })); + (receipt = await this.token.setApprovalForAll(proxy, true, { from: multiTokenHolder })); }); it('sets approval status which can be queried via isApprovedForAll', async function () { @@ -175,7 +175,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, }); it('emits an ApprovalForAll log', function () { - expectEvent.inLogs(logs, 'ApprovalForAll', { account: multiTokenHolder, operator: proxy, approved: true }); + expectEvent(receipt, 'ApprovalForAll', { account: multiTokenHolder, operator: proxy, approved: true }); }); it('can unset approval for an operator', async function () { @@ -247,7 +247,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, }); it('emits a TransferSingle log', function () { - expectEvent.inLogs(this.transferLogs, 'TransferSingle', { + expectEvent(this.transferLogs, 'TransferSingle', { operator, from, to: this.toWhom, @@ -260,7 +260,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, context('when called by the multiTokenHolder', async function () { beforeEach(async function () { this.toWhom = recipient; - ({ logs: this.transferLogs } = + (this.transferLogs = await this.token.safeTransferFrom(multiTokenHolder, recipient, firstTokenId, firstAmount, '0x', { from: multiTokenHolder, })); @@ -302,7 +302,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, beforeEach(async function () { this.toWhom = recipient; await this.token.setApprovalForAll(proxy, true, { from: multiTokenHolder }); - ({ logs: this.transferLogs } = + (this.transferLogs = await this.token.safeTransferFrom(multiTokenHolder, recipient, firstTokenId, firstAmount, '0x', { from: proxy, })); @@ -344,7 +344,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, '0x', { from: multiTokenHolder }, ); - ({ logs: this.transferLogs } = this.transferReceipt); + (this.transferLogs = this.transferReceipt); }); transferWasSuccessful.call(this, { @@ -377,7 +377,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, data, { from: multiTokenHolder }, ); - ({ logs: this.transferLogs } = this.transferReceipt); + (this.transferLogs = this.transferReceipt); }); transferWasSuccessful.call(this, { @@ -525,7 +525,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, }); it('emits a TransferBatch log', function () { - expectEvent.inLogs(this.transferLogs, 'TransferBatch', { + expectEvent(this.transferLogs, 'TransferBatch', { operator, from, to: this.toWhom, @@ -538,7 +538,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, context('when called by the multiTokenHolder', async function () { beforeEach(async function () { this.toWhom = recipient; - ({ logs: this.transferLogs } = + (this.transferLogs = await this.token.safeBatchTransferFrom( multiTokenHolder, recipient, [firstTokenId, secondTokenId], @@ -578,7 +578,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, beforeEach(async function () { this.toWhom = recipient; await this.token.setApprovalForAll(proxy, true, { from: multiTokenHolder }); - ({ logs: this.transferLogs } = + (this.transferLogs = await this.token.safeBatchTransferFrom( multiTokenHolder, recipient, [firstTokenId, secondTokenId], @@ -620,7 +620,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, [firstAmount, secondAmount], '0x', { from: multiTokenHolder }, ); - ({ logs: this.transferLogs } = this.transferReceipt); + (this.transferLogs = this.transferReceipt); }); batchTransferWasSuccessful.call(this, { @@ -651,7 +651,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, [firstAmount, secondAmount], data, { from: multiTokenHolder }, ); - ({ logs: this.transferLogs } = this.transferReceipt); + (this.transferLogs = this.transferReceipt); }); batchTransferWasSuccessful.call(this, { @@ -729,7 +729,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, [firstAmount, secondAmount], '0x', { from: multiTokenHolder }, ); - ({ logs: this.transferLogs } = this.transferReceipt); + (this.transferLogs = this.transferReceipt); }); batchTransferWasSuccessful.call(this, { diff --git a/test/token/ERC1155/ERC1155.test.js b/test/token/ERC1155/ERC1155.test.js index dffe054b6..a0a8cf3ff 100644 --- a/test/token/ERC1155/ERC1155.test.js +++ b/test/token/ERC1155/ERC1155.test.js @@ -38,11 +38,11 @@ contract('ERC1155', function (accounts) { context('with minted tokens', function () { beforeEach(async function () { - ({ logs: this.logs } = await this.token.mint(tokenHolder, tokenId, mintAmount, data, { from: operator })); + (this.receipt = await this.token.mint(tokenHolder, tokenId, mintAmount, data, { from: operator })); }); it('emits a TransferSingle event', function () { - expectEvent.inLogs(this.logs, 'TransferSingle', { + expectEvent(this.receipt, 'TransferSingle', { operator, from: ZERO_ADDRESS, to: tokenHolder, @@ -79,7 +79,7 @@ contract('ERC1155', function (accounts) { context('with minted batch of tokens', function () { beforeEach(async function () { - ({ logs: this.logs } = await this.token.mintBatch( + (this.receipt = await this.token.mintBatch( tokenBatchHolder, tokenBatchIds, mintAmounts, @@ -89,7 +89,7 @@ contract('ERC1155', function (accounts) { }); it('emits a TransferBatch event', function () { - expectEvent.inLogs(this.logs, 'TransferBatch', { + expectEvent(this.receipt, 'TransferBatch', { operator, from: ZERO_ADDRESS, to: tokenBatchHolder, @@ -142,7 +142,7 @@ contract('ERC1155', function (accounts) { context('with minted-then-burnt tokens', function () { beforeEach(async function () { await this.token.mint(tokenHolder, tokenId, mintAmount, data); - ({ logs: this.logs } = await this.token.burn( + (this.receipt = await this.token.burn( tokenHolder, tokenId, burnAmount, @@ -151,7 +151,7 @@ contract('ERC1155', function (accounts) { }); it('emits a TransferSingle event', function () { - expectEvent.inLogs(this.logs, 'TransferSingle', { + expectEvent(this.receipt, 'TransferSingle', { operator, from: tokenHolder, to: ZERO_ADDRESS, @@ -199,7 +199,7 @@ contract('ERC1155', function (accounts) { context('with minted-then-burnt tokens', function () { beforeEach(async function () { await this.token.mintBatch(tokenBatchHolder, tokenBatchIds, mintAmounts, data); - ({ logs: this.logs } = await this.token.burnBatch( + (this.receipt = await this.token.burnBatch( tokenBatchHolder, tokenBatchIds, burnAmounts, @@ -208,7 +208,7 @@ contract('ERC1155', function (accounts) { }); it('emits a TransferBatch event', function () { - expectEvent.inLogs(this.logs, 'TransferBatch', { + expectEvent(this.receipt, 'TransferBatch', { operator, from: tokenBatchHolder, to: ZERO_ADDRESS, diff --git a/test/token/ERC20/extensions/ERC20Burnable.behavior.js b/test/token/ERC20/extensions/ERC20Burnable.behavior.js index 3ba2fc9d9..a931bf60d 100644 --- a/test/token/ERC20/extensions/ERC20Burnable.behavior.js +++ b/test/token/ERC20/extensions/ERC20Burnable.behavior.js @@ -16,7 +16,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { function shouldBurn (amount) { beforeEach(async function () { - ({ logs: this.logs } = await this.token.burn(amount, { from: owner })); + (this.receipt = await this.token.burn(amount, { from: owner })); }); it('burns the requested amount', async function () { @@ -24,7 +24,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { }); it('emits a transfer event', async function () { - expectEvent.inLogs(this.logs, 'Transfer', { + expectEvent(this.receipt, 'Transfer', { from: owner, to: ZERO_ADDRESS, value: amount, @@ -59,8 +59,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { beforeEach(async function () { await this.token.approve(burner, originalAllowance, { from: owner }); - const { logs } = await this.token.burnFrom(owner, amount, { from: burner }); - this.logs = logs; + this.receipt = await this.token.burnFrom(owner, amount, { from: burner }); }); it('burns the requested amount', async function () { @@ -72,7 +71,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { }); it('emits a transfer event', async function () { - expectEvent.inLogs(this.logs, 'Transfer', { + expectEvent(this.receipt, 'Transfer', { from: owner, to: ZERO_ADDRESS, value: amount, diff --git a/test/token/ERC20/extensions/ERC20Snapshot.test.js b/test/token/ERC20/extensions/ERC20Snapshot.test.js index b05ca2b99..64d922706 100644 --- a/test/token/ERC20/extensions/ERC20Snapshot.test.js +++ b/test/token/ERC20/extensions/ERC20Snapshot.test.js @@ -17,14 +17,14 @@ contract('ERC20Snapshot', function (accounts) { describe('snapshot', function () { it('emits a snapshot event', async function () { - const { logs } = await this.token.snapshot(); - expectEvent.inLogs(logs, 'Snapshot'); + const receipt = await this.token.snapshot(); + expectEvent(receipt, 'Snapshot'); }); it('creates increasing snapshots ids, starting from 1', async function () { for (const id of ['1', '2', '3', '4', '5']) { - const { logs } = await this.token.snapshot(); - expectEvent.inLogs(logs, 'Snapshot', { id }); + const receipt = await this.token.snapshot(); + expectEvent(receipt, 'Snapshot', { id }); } }); }); @@ -42,8 +42,8 @@ contract('ERC20Snapshot', function (accounts) { beforeEach(async function () { this.initialSnapshotId = new BN('1'); - const { logs } = await this.token.snapshot(); - expectEvent.inLogs(logs, 'Snapshot', { id: this.initialSnapshotId }); + const receipt = await this.token.snapshot(); + expectEvent(receipt, 'Snapshot', { id: this.initialSnapshotId }); }); context('with no supply changes after the snapshot', function () { @@ -66,8 +66,8 @@ contract('ERC20Snapshot', function (accounts) { beforeEach(async function () { this.secondSnapshotId = new BN('2'); - const { logs } = await this.token.snapshot(); - expectEvent.inLogs(logs, 'Snapshot', { id: this.secondSnapshotId }); + const receipt = await this.token.snapshot(); + expectEvent(receipt, 'Snapshot', { id: this.secondSnapshotId }); }); it('snapshots return the supply before and after the changes', async function () { @@ -84,8 +84,8 @@ contract('ERC20Snapshot', function (accounts) { this.secondSnapshotIds = ['2', '3', '4']; for (const id of this.secondSnapshotIds) { - const { logs } = await this.token.snapshot(); - expectEvent.inLogs(logs, 'Snapshot', { id }); + const receipt = await this.token.snapshot(); + expectEvent(receipt, 'Snapshot', { id }); } }); @@ -116,8 +116,8 @@ contract('ERC20Snapshot', function (accounts) { beforeEach(async function () { this.initialSnapshotId = new BN('1'); - const { logs } = await this.token.snapshot(); - expectEvent.inLogs(logs, 'Snapshot', { id: this.initialSnapshotId }); + const receipt = await this.token.snapshot(); + expectEvent(receipt, 'Snapshot', { id: this.initialSnapshotId }); }); context('with no balance changes after the snapshot', function () { @@ -147,8 +147,8 @@ contract('ERC20Snapshot', function (accounts) { beforeEach(async function () { this.secondSnapshotId = new BN('2'); - const { logs } = await this.token.snapshot(); - expectEvent.inLogs(logs, 'Snapshot', { id: this.secondSnapshotId }); + const receipt = await this.token.snapshot(); + expectEvent(receipt, 'Snapshot', { id: this.secondSnapshotId }); }); it('snapshots return the balances before and after the changes', async function () { @@ -174,8 +174,8 @@ contract('ERC20Snapshot', function (accounts) { this.secondSnapshotIds = ['2', '3', '4']; for (const id of this.secondSnapshotIds) { - const { logs } = await this.token.snapshot(); - expectEvent.inLogs(logs, 'Snapshot', { id }); + const receipt = await this.token.snapshot(); + expectEvent(receipt, 'Snapshot', { id }); } }); diff --git a/test/token/ERC20/extensions/ERC20Votes.test.js b/test/token/ERC20/extensions/ERC20Votes.test.js index a0ab60abe..325f26726 100644 --- a/test/token/ERC20/extensions/ERC20Votes.test.js +++ b/test/token/ERC20/extensions/ERC20Votes.test.js @@ -206,8 +206,8 @@ contract('ERC20Votes', function (accounts) { }), )); - const { logs } = await this.token.delegateBySig(holderDelegatee, nonce, MAX_UINT256, v, r, s); - const { args } = logs.find(({ event }) => event == 'DelegateChanged'); + const receipt = await this.token.delegateBySig(holderDelegatee, nonce, MAX_UINT256, v, r, s); + const { args } = receipt.logs.find(({ event }) => event == 'DelegateChanged'); expect(args.delegator).to.not.be.equal(delegatorAddress); expect(args.fromDelegate).to.be.equal(ZERO_ADDRESS); expect(args.toDelegate).to.be.equal(holderDelegatee); diff --git a/test/token/ERC20/extensions/ERC20VotesComp.test.js b/test/token/ERC20/extensions/ERC20VotesComp.test.js index 0f0c25ebf..a91ff1230 100644 --- a/test/token/ERC20/extensions/ERC20VotesComp.test.js +++ b/test/token/ERC20/extensions/ERC20VotesComp.test.js @@ -206,8 +206,8 @@ contract('ERC20VotesComp', function (accounts) { }), )); - const { logs } = await this.token.delegateBySig(holderDelegatee, nonce, MAX_UINT256, v, r, s); - const { args } = logs.find(({ event }) => event == 'DelegateChanged'); + const receipt = await this.token.delegateBySig(holderDelegatee, nonce, MAX_UINT256, v, r, s); + const { args } = receipt.logs.find(({ event }) => event == 'DelegateChanged'); expect(args.delegator).to.not.be.equal(delegatorAddress); expect(args.fromDelegate).to.be.equal(ZERO_ADDRESS); expect(args.toDelegate).to.be.equal(holderDelegatee); diff --git a/test/token/ERC721/ERC721.behavior.js b/test/token/ERC721/ERC721.behavior.js index 75944be70..603057776 100644 --- a/test/token/ERC721/ERC721.behavior.js +++ b/test/token/ERC721/ERC721.behavior.js @@ -76,7 +76,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another const tokenId = firstTokenId; const data = '0x42'; - let logs = null; + let receipt = null; beforeEach(async function () { await this.token.approve(approved, tokenId, { from: owner }); @@ -89,7 +89,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another }); it('emits a Transfer event', async function () { - expectEvent.inLogs(logs, 'Transfer', { from: owner, to: this.toWhom, tokenId: tokenId }); + expectEvent(receipt, 'Transfer', { from: owner, to: this.toWhom, tokenId: tokenId }); }); it('clears the approval for the token ID', async function () { @@ -97,7 +97,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another }); it('emits an Approval event', async function () { - expectEvent.inLogs(logs, 'Approval', { owner, approved: ZERO_ADDRESS, tokenId: tokenId }); + expectEvent(receipt, 'Approval', { owner, approved: ZERO_ADDRESS, tokenId: tokenId }); }); it('adjusts owners balances', async function () { @@ -116,21 +116,21 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another const shouldTransferTokensByUsers = function (transferFunction) { context('when called by the owner', function () { beforeEach(async function () { - ({ logs } = await transferFunction.call(this, owner, this.toWhom, tokenId, { from: owner })); + (receipt = await transferFunction.call(this, owner, this.toWhom, tokenId, { from: owner })); }); transferWasSuccessful({ owner, tokenId, approved }); }); context('when called by the approved individual', function () { beforeEach(async function () { - ({ logs } = await transferFunction.call(this, owner, this.toWhom, tokenId, { from: approved })); + (receipt = await transferFunction.call(this, owner, this.toWhom, tokenId, { from: approved })); }); transferWasSuccessful({ owner, tokenId, approved }); }); context('when called by the operator', function () { beforeEach(async function () { - ({ logs } = await transferFunction.call(this, owner, this.toWhom, tokenId, { from: operator })); + (receipt = await transferFunction.call(this, owner, this.toWhom, tokenId, { from: operator })); }); transferWasSuccessful({ owner, tokenId, approved }); }); @@ -138,14 +138,14 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another context('when called by the owner without an approved user', function () { beforeEach(async function () { await this.token.approve(ZERO_ADDRESS, tokenId, { from: owner }); - ({ logs } = await transferFunction.call(this, owner, this.toWhom, tokenId, { from: operator })); + (receipt = await transferFunction.call(this, owner, this.toWhom, tokenId, { from: operator })); }); transferWasSuccessful({ owner, tokenId, approved: null }); }); context('when sent to the owner', function () { beforeEach(async function () { - ({ logs } = await transferFunction.call(this, owner, owner, tokenId, { from: owner })); + (receipt = await transferFunction.call(this, owner, owner, tokenId, { from: owner })); }); it('keeps ownership of the token', async function () { @@ -157,7 +157,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another }); it('emits only a transfer event', async function () { - expectEvent.inLogs(logs, 'Transfer', { + expectEvent(receipt, 'Transfer', { from: owner, to: owner, tokenId: tokenId, @@ -422,7 +422,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another describe('approve', function () { const tokenId = firstTokenId; - let logs = null; + let receipt = null; const itClearsApproval = function () { it('clears approval for the token', async function () { @@ -438,7 +438,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another const itEmitsApprovalEvent = function (address) { it('emits an approval event', async function () { - expectEvent.inLogs(logs, 'Approval', { + expectEvent(receipt, 'Approval', { owner: owner, approved: address, tokenId: tokenId, @@ -449,7 +449,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another context('when clearing approval', function () { context('when there was no prior approval', function () { beforeEach(async function () { - ({ logs } = await this.token.approve(ZERO_ADDRESS, tokenId, { from: owner })); + (receipt = await this.token.approve(ZERO_ADDRESS, tokenId, { from: owner })); }); itClearsApproval(); @@ -459,7 +459,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another context('when there was a prior approval', function () { beforeEach(async function () { await this.token.approve(approved, tokenId, { from: owner }); - ({ logs } = await this.token.approve(ZERO_ADDRESS, tokenId, { from: owner })); + (receipt = await this.token.approve(ZERO_ADDRESS, tokenId, { from: owner })); }); itClearsApproval(); @@ -470,7 +470,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another context('when approving a non-zero address', function () { context('when there was no prior approval', function () { beforeEach(async function () { - ({ logs } = await this.token.approve(approved, tokenId, { from: owner })); + (receipt = await this.token.approve(approved, tokenId, { from: owner })); }); itApproves(approved); @@ -480,7 +480,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another context('when there was a prior approval to the same address', function () { beforeEach(async function () { await this.token.approve(approved, tokenId, { from: owner }); - ({ logs } = await this.token.approve(approved, tokenId, { from: owner })); + (receipt = await this.token.approve(approved, tokenId, { from: owner })); }); itApproves(approved); @@ -490,7 +490,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another context('when there was a prior approval to a different address', function () { beforeEach(async function () { await this.token.approve(anotherApproved, tokenId, { from: owner }); - ({ logs } = await this.token.approve(anotherApproved, tokenId, { from: owner })); + (receipt = await this.token.approve(anotherApproved, tokenId, { from: owner })); }); itApproves(anotherApproved); @@ -524,7 +524,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another context('when the sender is an operator', function () { beforeEach(async function () { await this.token.setApprovalForAll(operator, true, { from: owner }); - ({ logs } = await this.token.approve(approved, tokenId, { from: operator })); + (receipt = await this.token.approve(approved, tokenId, { from: operator })); }); itApproves(approved); @@ -549,9 +549,9 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another }); it('emits an approval event', async function () { - const { logs } = await this.token.setApprovalForAll(operator, true, { from: owner }); + const receipt = await this.token.setApprovalForAll(operator, true, { from: owner }); - expectEvent.inLogs(logs, 'ApprovalForAll', { + expectEvent(receipt, 'ApprovalForAll', { owner: owner, operator: operator, approved: true, @@ -571,9 +571,9 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another }); it('emits an approval event', async function () { - const { logs } = await this.token.setApprovalForAll(operator, true, { from: owner }); + const receipt = await this.token.setApprovalForAll(operator, true, { from: owner }); - expectEvent.inLogs(logs, 'ApprovalForAll', { + expectEvent(receipt, 'ApprovalForAll', { owner: owner, operator: operator, approved: true, @@ -599,9 +599,9 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another }); it('emits an approval event', async function () { - const { logs } = await this.token.setApprovalForAll(operator, true, { from: owner }); + const receipt = await this.token.setApprovalForAll(operator, true, { from: owner }); - expectEvent.inLogs(logs, 'ApprovalForAll', { + expectEvent(receipt, 'ApprovalForAll', { owner: owner, operator: operator, approved: true, @@ -657,11 +657,11 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another context('with minted token', async function () { beforeEach(async function () { - ({ logs: this.logs } = await this.token.mint(owner, firstTokenId)); + (this.receipt = await this.token.mint(owner, firstTokenId)); }); it('emits a Transfer event', function () { - expectEvent.inLogs(this.logs, 'Transfer', { from: ZERO_ADDRESS, to: owner, tokenId: firstTokenId }); + expectEvent(this.receipt, 'Transfer', { from: ZERO_ADDRESS, to: owner, tokenId: firstTokenId }); }); it('creates the token', async function () { @@ -690,15 +690,15 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another context('with burnt token', function () { beforeEach(async function () { - ({ logs: this.logs } = await this.token.burn(firstTokenId)); + (this.receipt = await this.token.burn(firstTokenId)); }); it('emits a Transfer event', function () { - expectEvent.inLogs(this.logs, 'Transfer', { from: owner, to: ZERO_ADDRESS, tokenId: firstTokenId }); + expectEvent(this.receipt, 'Transfer', { from: owner, to: ZERO_ADDRESS, tokenId: firstTokenId }); }); it('emits an Approval event', function () { - expectEvent.inLogs(this.logs, 'Approval', { owner, approved: ZERO_ADDRESS, tokenId: firstTokenId }); + expectEvent(this.receipt, 'Approval', { owner, approved: ZERO_ADDRESS, tokenId: firstTokenId }); }); it('deletes the token', async function () { @@ -830,7 +830,7 @@ function shouldBehaveLikeERC721Enumerable (errorPrefix, owner, newOwner, approve context('with minted token', async function () { beforeEach(async function () { - ({ logs: this.logs } = await this.token.mint(owner, firstTokenId)); + (this.receipt = await this.token.mint(owner, firstTokenId)); }); it('adjusts owner tokens by index', async function () { @@ -858,7 +858,7 @@ function shouldBehaveLikeERC721Enumerable (errorPrefix, owner, newOwner, approve context('with burnt token', function () { beforeEach(async function () { - ({ logs: this.logs } = await this.token.burn(firstTokenId)); + (this.receipt = await this.token.burn(firstTokenId)); }); it('removes that token from the token list of the owner', async function () { diff --git a/test/token/ERC721/extensions/ERC721Burnable.test.js b/test/token/ERC721/extensions/ERC721Burnable.test.js index 3ffca104c..bbf56e6a7 100644 --- a/test/token/ERC721/extensions/ERC721Burnable.test.js +++ b/test/token/ERC721/extensions/ERC721Burnable.test.js @@ -27,12 +27,11 @@ contract('ERC721Burnable', function (accounts) { describe('burn', function () { const tokenId = firstTokenId; - let logs = null; + let receipt = null; describe('when successful', function () { beforeEach(async function () { - const result = await this.token.burn(tokenId, { from: owner }); - logs = result.logs; + receipt = await this.token.burn(tokenId, { from: owner }); }); it('burns the given token ID and adjusts the balance of the owner', async function () { @@ -44,7 +43,7 @@ contract('ERC721Burnable', function (accounts) { }); it('emits a burn event', async function () { - expectEvent.inLogs(logs, 'Transfer', { + expectEvent(receipt, 'Transfer', { from: owner, to: ZERO_ADDRESS, tokenId: tokenId, @@ -55,8 +54,7 @@ contract('ERC721Burnable', function (accounts) { describe('when there is a previous approval burned', function () { beforeEach(async function () { await this.token.approve(approved, tokenId, { from: owner }); - const result = await this.token.burn(tokenId, { from: owner }); - logs = result.logs; + receipt = await this.token.burn(tokenId, { from: owner }); }); context('getApproved', function () { diff --git a/test/token/ERC777/ERC777.behavior.js b/test/token/ERC777/ERC777.behavior.js index 9c96d0e6b..f6af94227 100644 --- a/test/token/ERC777/ERC777.behavior.js +++ b/test/token/ERC777/ERC777.behavior.js @@ -186,10 +186,10 @@ function shouldSendTokens (from, operator, to, amount, data, operatorData) { const initialFromBalance = await this.token.balanceOf(from); const initialToBalance = await this.token.balanceOf(to); - let logs; + let receipt; if (!operatorCall) { - ({ logs } = await this.token.send(to, amount, data, { from })); - expectEvent.inLogs(logs, 'Sent', { + (receipt = await this.token.send(to, amount, data, { from })); + expectEvent(receipt, 'Sent', { operator: from, from, to, @@ -198,8 +198,8 @@ function shouldSendTokens (from, operator, to, amount, data, operatorData) { operatorData: null, }); } else { - ({ logs } = await this.token.operatorSend(from, to, amount, data, operatorData, { from: operator })); - expectEvent.inLogs(logs, 'Sent', { + (receipt = await this.token.operatorSend(from, to, amount, data, operatorData, { from: operator })); + expectEvent(receipt, 'Sent', { operator, from, to, @@ -209,7 +209,7 @@ function shouldSendTokens (from, operator, to, amount, data, operatorData) { }); } - expectEvent.inLogs(logs, 'Transfer', { + expectEvent(receipt, 'Transfer', { from, to, value: amount, @@ -240,10 +240,10 @@ function shouldBurnTokens (from, operator, amount, data, operatorData) { const initialTotalSupply = await this.token.totalSupply(); const initialFromBalance = await this.token.balanceOf(from); - let logs; + let receipt; if (!operatorCall) { - ({ logs } = await this.token.burn(amount, data, { from })); - expectEvent.inLogs(logs, 'Burned', { + (receipt = await this.token.burn(amount, data, { from })); + expectEvent(receipt, 'Burned', { operator: from, from, amount, @@ -251,8 +251,8 @@ function shouldBurnTokens (from, operator, amount, data, operatorData) { operatorData: null, }); } else { - ({ logs } = await this.token.operatorBurn(from, amount, data, operatorData, { from: operator })); - expectEvent.inLogs(logs, 'Burned', { + (receipt = await this.token.operatorBurn(from, amount, data, operatorData, { from: operator })); + expectEvent(receipt, 'Burned', { operator, from, amount, @@ -261,7 +261,7 @@ function shouldBurnTokens (from, operator, amount, data, operatorData) { }); } - expectEvent.inLogs(logs, 'Transfer', { + expectEvent(receipt, 'Transfer', { from, to: ZERO_ADDRESS, value: amount, @@ -291,9 +291,9 @@ function shouldInternalMintTokens (operator, to, amount, data, operatorData) { const initialTotalSupply = await this.token.totalSupply(); const initialToBalance = await this.token.balanceOf(to); - const { logs } = await this.token.mintInternal(to, amount, data, operatorData, { from: operator }); + const receipt = await this.token.mintInternal(to, amount, data, operatorData, { from: operator }); - expectEvent.inLogs(logs, 'Minted', { + expectEvent(receipt, 'Minted', { operator, to, amount, @@ -301,7 +301,7 @@ function shouldInternalMintTokens (operator, to, amount, data, operatorData) { operatorData, }); - expectEvent.inLogs(logs, 'Transfer', { + expectEvent(receipt, 'Transfer', { from: ZERO_ADDRESS, to, value: amount, diff --git a/test/token/ERC777/ERC777.test.js b/test/token/ERC777/ERC777.test.js index 40b840c7d..51da130d4 100644 --- a/test/token/ERC777/ERC777.test.js +++ b/test/token/ERC777/ERC777.test.js @@ -320,8 +320,8 @@ contract('ERC777', function (accounts) { it('non-operators can be revoked', async function () { expect(await this.token.isOperatorFor(newOperator, holder)).to.equal(false); - const { logs } = await this.token.revokeOperator(newOperator, { from: holder }); - expectEvent.inLogs(logs, 'RevokedOperator', { operator: newOperator, tokenHolder: holder }); + const receipt = await this.token.revokeOperator(newOperator, { from: holder }); + expectEvent(receipt, 'RevokedOperator', { operator: newOperator, tokenHolder: holder }); expect(await this.token.isOperatorFor(newOperator, holder)).to.equal(false); }); @@ -329,8 +329,8 @@ contract('ERC777', function (accounts) { it('non-operators can be authorized', async function () { expect(await this.token.isOperatorFor(newOperator, holder)).to.equal(false); - const { logs } = await this.token.authorizeOperator(newOperator, { from: holder }); - expectEvent.inLogs(logs, 'AuthorizedOperator', { operator: newOperator, tokenHolder: holder }); + const receipt = await this.token.authorizeOperator(newOperator, { from: holder }); + expectEvent(receipt, 'AuthorizedOperator', { operator: newOperator, tokenHolder: holder }); expect(await this.token.isOperatorFor(newOperator, holder)).to.equal(true); }); @@ -345,15 +345,15 @@ contract('ERC777', function (accounts) { }); it('can be re-authorized', async function () { - const { logs } = await this.token.authorizeOperator(newOperator, { from: holder }); - expectEvent.inLogs(logs, 'AuthorizedOperator', { operator: newOperator, tokenHolder: holder }); + const receipt = await this.token.authorizeOperator(newOperator, { from: holder }); + expectEvent(receipt, 'AuthorizedOperator', { operator: newOperator, tokenHolder: holder }); expect(await this.token.isOperatorFor(newOperator, holder)).to.equal(true); }); it('can be revoked', async function () { - const { logs } = await this.token.revokeOperator(newOperator, { from: holder }); - expectEvent.inLogs(logs, 'RevokedOperator', { operator: newOperator, tokenHolder: holder }); + const receipt = await this.token.revokeOperator(newOperator, { from: holder }); + expectEvent(receipt, 'RevokedOperator', { operator: newOperator, tokenHolder: holder }); expect(await this.token.isOperatorFor(newOperator, holder)).to.equal(false); }); @@ -361,15 +361,15 @@ contract('ERC777', function (accounts) { describe('default operators', function () { it('can be re-authorized', async function () { - const { logs } = await this.token.authorizeOperator(defaultOperatorA, { from: holder }); - expectEvent.inLogs(logs, 'AuthorizedOperator', { operator: defaultOperatorA, tokenHolder: holder }); + const receipt = await this.token.authorizeOperator(defaultOperatorA, { from: holder }); + expectEvent(receipt, 'AuthorizedOperator', { operator: defaultOperatorA, tokenHolder: holder }); expect(await this.token.isOperatorFor(defaultOperatorA, holder)).to.equal(true); }); it('can be revoked', async function () { - const { logs } = await this.token.revokeOperator(defaultOperatorA, { from: holder }); - expectEvent.inLogs(logs, 'RevokedOperator', { operator: defaultOperatorA, tokenHolder: holder }); + const receipt = await this.token.revokeOperator(defaultOperatorA, { from: holder }); + expectEvent(receipt, 'RevokedOperator', { operator: defaultOperatorA, tokenHolder: holder }); expect(await this.token.isOperatorFor(defaultOperatorA, holder)).to.equal(false); }); @@ -399,8 +399,8 @@ contract('ERC777', function (accounts) { }); it('revoked default operator can be re-authorized', async function () { - const { logs } = await this.token.authorizeOperator(defaultOperatorA, { from: holder }); - expectEvent.inLogs(logs, 'AuthorizedOperator', { operator: defaultOperatorA, tokenHolder: holder }); + const receipt = await this.token.authorizeOperator(defaultOperatorA, { from: holder }); + expectEvent(receipt, 'AuthorizedOperator', { operator: defaultOperatorA, tokenHolder: holder }); expect(await this.token.isOperatorFor(defaultOperatorA, holder)).to.equal(true); }); diff --git a/test/utils/Context.behavior.js b/test/utils/Context.behavior.js index 0f60945a1..8728e1021 100644 --- a/test/utils/Context.behavior.js +++ b/test/utils/Context.behavior.js @@ -5,8 +5,8 @@ const ContextMock = artifacts.require('ContextMock'); function shouldBehaveLikeRegularContext (sender) { describe('msgSender', function () { it('returns the transaction sender when called from an EOA', async function () { - const { logs } = await this.context.msgSender({ from: sender }); - expectEvent.inLogs(logs, 'Sender', { sender }); + const receipt = await this.context.msgSender({ from: sender }); + expectEvent(receipt, 'Sender', { sender }); }); it('returns the transaction sender when from another contract', async function () { @@ -26,8 +26,8 @@ function shouldBehaveLikeRegularContext (sender) { }); it('returns the transaction data when called from an EOA', async function () { - const { logs } = await this.context.msgData(integerValue, stringValue); - expectEvent.inLogs(logs, 'Data', { data: callData, integerValue, stringValue }); + const receipt = await this.context.msgData(integerValue, stringValue); + expectEvent(receipt, 'Data', { data: callData, integerValue, stringValue }); }); it('returns the transaction sender when from another contract', async function () { diff --git a/test/utils/escrow/Escrow.behavior.js b/test/utils/escrow/Escrow.behavior.js index b6d3a69c2..ab5905994 100644 --- a/test/utils/escrow/Escrow.behavior.js +++ b/test/utils/escrow/Escrow.behavior.js @@ -26,8 +26,8 @@ function shouldBehaveLikeEscrow (owner, [payee1, payee2]) { }); it('emits a deposited event', async function () { - const { logs } = await this.escrow.deposit(payee1, { from: owner, value: amount }); - expectEvent.inLogs(logs, 'Deposited', { + const receipt = await this.escrow.deposit(payee1, { from: owner, value: amount }); + expectEvent(receipt, 'Deposited', { payee: payee1, weiAmount: amount, }); @@ -79,8 +79,8 @@ function shouldBehaveLikeEscrow (owner, [payee1, payee2]) { it('emits a withdrawn event', async function () { await this.escrow.deposit(payee1, { from: owner, value: amount }); - const { logs } = await this.escrow.withdraw(payee1, { from: owner }); - expectEvent.inLogs(logs, 'Withdrawn', { + const receipt = await this.escrow.withdraw(payee1, { from: owner }); + expectEvent(receipt, 'Withdrawn', { payee: payee1, weiAmount: amount, }); diff --git a/test/utils/escrow/RefundEscrow.test.js b/test/utils/escrow/RefundEscrow.test.js index 3ef28c684..26c19b366 100644 --- a/test/utils/escrow/RefundEscrow.test.js +++ b/test/utils/escrow/RefundEscrow.test.js @@ -54,8 +54,8 @@ contract('RefundEscrow', function (accounts) { 'Ownable: caller is not the owner', ); - const { logs } = await this.escrow.close({ from: owner }); - expectEvent.inLogs(logs, 'RefundsClosed'); + const receipt = await this.escrow.close({ from: owner }); + expectEvent(receipt, 'RefundsClosed'); }); context('closed state', function () { @@ -101,8 +101,8 @@ contract('RefundEscrow', function (accounts) { 'Ownable: caller is not the owner', ); - const { logs } = await this.escrow.enableRefunds({ from: owner }); - expectEvent.inLogs(logs, 'RefundsEnabled'); + const receipt = await this.escrow.enableRefunds({ from: owner }); + expectEvent(receipt, 'RefundsEnabled'); }); context('refund state', function () {