Fix deprecated expectEvent.inLogs #3332 (#3333)

pull/3356/head
Niccolò Petti 3 years ago committed by GitHub
parent 5a75065659
commit d4e6236b2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      test/finance/PaymentSplitter.test.js
  2. 4
      test/governance/utils/Votes.behavior.js
  3. 8
      test/security/Pausable.test.js
  4. 28
      test/token/ERC1155/ERC1155.behavior.js
  5. 16
      test/token/ERC1155/ERC1155.test.js
  6. 9
      test/token/ERC20/extensions/ERC20Burnable.behavior.js
  7. 32
      test/token/ERC20/extensions/ERC20Snapshot.test.js
  8. 4
      test/token/ERC20/extensions/ERC20Votes.test.js
  9. 4
      test/token/ERC20/extensions/ERC20VotesComp.test.js
  10. 60
      test/token/ERC721/ERC721.behavior.js
  11. 10
      test/token/ERC721/extensions/ERC721Burnable.test.js
  12. 30
      test/token/ERC777/ERC777.behavior.js
  13. 28
      test/token/ERC777/ERC777.test.js
  14. 8
      test/utils/Context.behavior.js
  15. 8
      test/utils/escrow/Escrow.behavior.js
  16. 8
      test/utils/escrow/RefundEscrow.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');

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save