Skip to content

Commit d4e6236

Browse files
authored
Fix deprecated expectEvent.inLogs OpenZeppelin#3332 (OpenZeppelin#3333)
1 parent 5a75065 commit d4e6236

16 files changed

+133
-136
lines changed

test/finance/PaymentSplitter.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,22 @@ contract('PaymentSplitter', function (accounts) {
130130
// distribute to payees
131131

132132
const tracker1 = await balance.tracker(payee1);
133-
const { logs: logs1 } = await this.contract.release(payee1);
133+
const receipt1 = await this.contract.release(payee1);
134134
const profit1 = await tracker1.delta();
135135
expect(profit1).to.be.bignumber.equal(ether('0.20'));
136-
expectEvent.inLogs(logs1, 'PaymentReleased', { to: payee1, amount: profit1 });
136+
expectEvent(receipt1, 'PaymentReleased', { to: payee1, amount: profit1 });
137137

138138
const tracker2 = await balance.tracker(payee2);
139-
const { logs: logs2 } = await this.contract.release(payee2);
139+
const receipt2 = await this.contract.release(payee2);
140140
const profit2 = await tracker2.delta();
141141
expect(profit2).to.be.bignumber.equal(ether('0.10'));
142-
expectEvent.inLogs(logs2, 'PaymentReleased', { to: payee2, amount: profit2 });
142+
expectEvent(receipt2, 'PaymentReleased', { to: payee2, amount: profit2 });
143143

144144
const tracker3 = await balance.tracker(payee3);
145-
const { logs: logs3 } = await this.contract.release(payee3);
145+
const receipt3 = await this.contract.release(payee3);
146146
const profit3 = await tracker3.delta();
147147
expect(profit3).to.be.bignumber.equal(ether('0.70'));
148-
expectEvent.inLogs(logs3, 'PaymentReleased', { to: payee3, amount: profit3 });
148+
expectEvent(receipt3, 'PaymentReleased', { to: payee3, amount: profit3 });
149149

150150
// end balance should be zero
151151
expect(await balance.current(this.contract.address)).to.be.bignumber.equal('0');

test/governance/utils/Votes.behavior.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ function shouldBehaveLikeVotes () {
108108
}),
109109
));
110110

111-
const { logs } = await this.votes.delegateBySig(this.account1Delegatee, nonce, MAX_UINT256, v, r, s);
112-
const { args } = logs.find(({ event }) => event === 'DelegateChanged');
111+
const receipt = await this.votes.delegateBySig(this.account1Delegatee, nonce, MAX_UINT256, v, r, s);
112+
const { args } = receipt.logs.find(({ event }) => event === 'DelegateChanged');
113113
expect(args.delegator).to.not.be.equal(delegatorAddress);
114114
expect(args.fromDelegate).to.be.equal(ZERO_ADDRESS);
115115
expect(args.toDelegate).to.be.equal(this.account1Delegatee);

test/security/Pausable.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ contract('Pausable', function (accounts) {
3232

3333
context('when paused', function () {
3434
beforeEach(async function () {
35-
({ logs: this.logs } = await this.pausable.pause({ from: pauser }));
35+
(this.receipt = await this.pausable.pause({ from: pauser }));
3636
});
3737

3838
it('emits a Paused event', function () {
39-
expectEvent.inLogs(this.logs, 'Paused', { account: pauser });
39+
expectEvent(this.receipt, 'Paused', { account: pauser });
4040
});
4141

4242
it('cannot perform normal process in pause', async function () {
@@ -60,11 +60,11 @@ contract('Pausable', function (accounts) {
6060

6161
context('when unpaused', function () {
6262
beforeEach(async function () {
63-
({ logs: this.logs } = await this.pausable.unpause({ from: pauser }));
63+
(this.receipt = await this.pausable.unpause({ from: pauser }));
6464
});
6565

6666
it('emits an Unpaused event', function () {
67-
expectEvent.inLogs(this.logs, 'Unpaused', { account: pauser });
67+
expectEvent(this.receipt, 'Unpaused', { account: pauser });
6868
});
6969

7070
it('should resume allowing normal process', async function () {

test/token/ERC1155/ERC1155.behavior.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,17 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
165165
});
166166

167167
describe('setApprovalForAll', function () {
168-
let logs;
168+
let receipt;
169169
beforeEach(async function () {
170-
({ logs } = await this.token.setApprovalForAll(proxy, true, { from: multiTokenHolder }));
170+
(receipt = await this.token.setApprovalForAll(proxy, true, { from: multiTokenHolder }));
171171
});
172172

173173
it('sets approval status which can be queried via isApprovedForAll', async function () {
174174
expect(await this.token.isApprovedForAll(multiTokenHolder, proxy)).to.be.equal(true);
175175
});
176176

177177
it('emits an ApprovalForAll log', function () {
178-
expectEvent.inLogs(logs, 'ApprovalForAll', { account: multiTokenHolder, operator: proxy, approved: true });
178+
expectEvent(receipt, 'ApprovalForAll', { account: multiTokenHolder, operator: proxy, approved: true });
179179
});
180180

181181
it('can unset approval for an operator', async function () {
@@ -247,7 +247,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
247247
});
248248

249249
it('emits a TransferSingle log', function () {
250-
expectEvent.inLogs(this.transferLogs, 'TransferSingle', {
250+
expectEvent(this.transferLogs, 'TransferSingle', {
251251
operator,
252252
from,
253253
to: this.toWhom,
@@ -260,7 +260,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
260260
context('when called by the multiTokenHolder', async function () {
261261
beforeEach(async function () {
262262
this.toWhom = recipient;
263-
({ logs: this.transferLogs } =
263+
(this.transferLogs =
264264
await this.token.safeTransferFrom(multiTokenHolder, recipient, firstTokenId, firstAmount, '0x', {
265265
from: multiTokenHolder,
266266
}));
@@ -302,7 +302,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
302302
beforeEach(async function () {
303303
this.toWhom = recipient;
304304
await this.token.setApprovalForAll(proxy, true, { from: multiTokenHolder });
305-
({ logs: this.transferLogs } =
305+
(this.transferLogs =
306306
await this.token.safeTransferFrom(multiTokenHolder, recipient, firstTokenId, firstAmount, '0x', {
307307
from: proxy,
308308
}));
@@ -344,7 +344,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
344344
'0x',
345345
{ from: multiTokenHolder },
346346
);
347-
({ logs: this.transferLogs } = this.transferReceipt);
347+
(this.transferLogs = this.transferReceipt);
348348
});
349349

350350
transferWasSuccessful.call(this, {
@@ -377,7 +377,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
377377
data,
378378
{ from: multiTokenHolder },
379379
);
380-
({ logs: this.transferLogs } = this.transferReceipt);
380+
(this.transferLogs = this.transferReceipt);
381381
});
382382

383383
transferWasSuccessful.call(this, {
@@ -525,7 +525,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
525525
});
526526

527527
it('emits a TransferBatch log', function () {
528-
expectEvent.inLogs(this.transferLogs, 'TransferBatch', {
528+
expectEvent(this.transferLogs, 'TransferBatch', {
529529
operator,
530530
from,
531531
to: this.toWhom,
@@ -538,7 +538,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
538538
context('when called by the multiTokenHolder', async function () {
539539
beforeEach(async function () {
540540
this.toWhom = recipient;
541-
({ logs: this.transferLogs } =
541+
(this.transferLogs =
542542
await this.token.safeBatchTransferFrom(
543543
multiTokenHolder, recipient,
544544
[firstTokenId, secondTokenId],
@@ -578,7 +578,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
578578
beforeEach(async function () {
579579
this.toWhom = recipient;
580580
await this.token.setApprovalForAll(proxy, true, { from: multiTokenHolder });
581-
({ logs: this.transferLogs } =
581+
(this.transferLogs =
582582
await this.token.safeBatchTransferFrom(
583583
multiTokenHolder, recipient,
584584
[firstTokenId, secondTokenId],
@@ -620,7 +620,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
620620
[firstAmount, secondAmount],
621621
'0x', { from: multiTokenHolder },
622622
);
623-
({ logs: this.transferLogs } = this.transferReceipt);
623+
(this.transferLogs = this.transferReceipt);
624624
});
625625

626626
batchTransferWasSuccessful.call(this, {
@@ -651,7 +651,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
651651
[firstAmount, secondAmount],
652652
data, { from: multiTokenHolder },
653653
);
654-
({ logs: this.transferLogs } = this.transferReceipt);
654+
(this.transferLogs = this.transferReceipt);
655655
});
656656

657657
batchTransferWasSuccessful.call(this, {
@@ -729,7 +729,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
729729
[firstAmount, secondAmount],
730730
'0x', { from: multiTokenHolder },
731731
);
732-
({ logs: this.transferLogs } = this.transferReceipt);
732+
(this.transferLogs = this.transferReceipt);
733733
});
734734

735735
batchTransferWasSuccessful.call(this, {

test/token/ERC1155/ERC1155.test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ contract('ERC1155', function (accounts) {
3838

3939
context('with minted tokens', function () {
4040
beforeEach(async function () {
41-
({ logs: this.logs } = await this.token.mint(tokenHolder, tokenId, mintAmount, data, { from: operator }));
41+
(this.receipt = await this.token.mint(tokenHolder, tokenId, mintAmount, data, { from: operator }));
4242
});
4343

4444
it('emits a TransferSingle event', function () {
45-
expectEvent.inLogs(this.logs, 'TransferSingle', {
45+
expectEvent(this.receipt, 'TransferSingle', {
4646
operator,
4747
from: ZERO_ADDRESS,
4848
to: tokenHolder,
@@ -79,7 +79,7 @@ contract('ERC1155', function (accounts) {
7979

8080
context('with minted batch of tokens', function () {
8181
beforeEach(async function () {
82-
({ logs: this.logs } = await this.token.mintBatch(
82+
(this.receipt = await this.token.mintBatch(
8383
tokenBatchHolder,
8484
tokenBatchIds,
8585
mintAmounts,
@@ -89,7 +89,7 @@ contract('ERC1155', function (accounts) {
8989
});
9090

9191
it('emits a TransferBatch event', function () {
92-
expectEvent.inLogs(this.logs, 'TransferBatch', {
92+
expectEvent(this.receipt, 'TransferBatch', {
9393
operator,
9494
from: ZERO_ADDRESS,
9595
to: tokenBatchHolder,
@@ -142,7 +142,7 @@ contract('ERC1155', function (accounts) {
142142
context('with minted-then-burnt tokens', function () {
143143
beforeEach(async function () {
144144
await this.token.mint(tokenHolder, tokenId, mintAmount, data);
145-
({ logs: this.logs } = await this.token.burn(
145+
(this.receipt = await this.token.burn(
146146
tokenHolder,
147147
tokenId,
148148
burnAmount,
@@ -151,7 +151,7 @@ contract('ERC1155', function (accounts) {
151151
});
152152

153153
it('emits a TransferSingle event', function () {
154-
expectEvent.inLogs(this.logs, 'TransferSingle', {
154+
expectEvent(this.receipt, 'TransferSingle', {
155155
operator,
156156
from: tokenHolder,
157157
to: ZERO_ADDRESS,
@@ -199,7 +199,7 @@ contract('ERC1155', function (accounts) {
199199
context('with minted-then-burnt tokens', function () {
200200
beforeEach(async function () {
201201
await this.token.mintBatch(tokenBatchHolder, tokenBatchIds, mintAmounts, data);
202-
({ logs: this.logs } = await this.token.burnBatch(
202+
(this.receipt = await this.token.burnBatch(
203203
tokenBatchHolder,
204204
tokenBatchIds,
205205
burnAmounts,
@@ -208,7 +208,7 @@ contract('ERC1155', function (accounts) {
208208
});
209209

210210
it('emits a TransferBatch event', function () {
211-
expectEvent.inLogs(this.logs, 'TransferBatch', {
211+
expectEvent(this.receipt, 'TransferBatch', {
212212
operator,
213213
from: tokenBatchHolder,
214214
to: ZERO_ADDRESS,

test/token/ERC20/extensions/ERC20Burnable.behavior.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) {
1616

1717
function shouldBurn (amount) {
1818
beforeEach(async function () {
19-
({ logs: this.logs } = await this.token.burn(amount, { from: owner }));
19+
(this.receipt = await this.token.burn(amount, { from: owner }));
2020
});
2121

2222
it('burns the requested amount', async function () {
2323
expect(await this.token.balanceOf(owner)).to.be.bignumber.equal(initialBalance.sub(amount));
2424
});
2525

2626
it('emits a transfer event', async function () {
27-
expectEvent.inLogs(this.logs, 'Transfer', {
27+
expectEvent(this.receipt, 'Transfer', {
2828
from: owner,
2929
to: ZERO_ADDRESS,
3030
value: amount,
@@ -59,8 +59,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) {
5959

6060
beforeEach(async function () {
6161
await this.token.approve(burner, originalAllowance, { from: owner });
62-
const { logs } = await this.token.burnFrom(owner, amount, { from: burner });
63-
this.logs = logs;
62+
this.receipt = await this.token.burnFrom(owner, amount, { from: burner });
6463
});
6564

6665
it('burns the requested amount', async function () {
@@ -72,7 +71,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) {
7271
});
7372

7473
it('emits a transfer event', async function () {
75-
expectEvent.inLogs(this.logs, 'Transfer', {
74+
expectEvent(this.receipt, 'Transfer', {
7675
from: owner,
7776
to: ZERO_ADDRESS,
7877
value: amount,

test/token/ERC20/extensions/ERC20Snapshot.test.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ contract('ERC20Snapshot', function (accounts) {
1717

1818
describe('snapshot', function () {
1919
it('emits a snapshot event', async function () {
20-
const { logs } = await this.token.snapshot();
21-
expectEvent.inLogs(logs, 'Snapshot');
20+
const receipt = await this.token.snapshot();
21+
expectEvent(receipt, 'Snapshot');
2222
});
2323

2424
it('creates increasing snapshots ids, starting from 1', async function () {
2525
for (const id of ['1', '2', '3', '4', '5']) {
26-
const { logs } = await this.token.snapshot();
27-
expectEvent.inLogs(logs, 'Snapshot', { id });
26+
const receipt = await this.token.snapshot();
27+
expectEvent(receipt, 'Snapshot', { id });
2828
}
2929
});
3030
});
@@ -42,8 +42,8 @@ contract('ERC20Snapshot', function (accounts) {
4242
beforeEach(async function () {
4343
this.initialSnapshotId = new BN('1');
4444

45-
const { logs } = await this.token.snapshot();
46-
expectEvent.inLogs(logs, 'Snapshot', { id: this.initialSnapshotId });
45+
const receipt = await this.token.snapshot();
46+
expectEvent(receipt, 'Snapshot', { id: this.initialSnapshotId });
4747
});
4848

4949
context('with no supply changes after the snapshot', function () {
@@ -66,8 +66,8 @@ contract('ERC20Snapshot', function (accounts) {
6666
beforeEach(async function () {
6767
this.secondSnapshotId = new BN('2');
6868

69-
const { logs } = await this.token.snapshot();
70-
expectEvent.inLogs(logs, 'Snapshot', { id: this.secondSnapshotId });
69+
const receipt = await this.token.snapshot();
70+
expectEvent(receipt, 'Snapshot', { id: this.secondSnapshotId });
7171
});
7272

7373
it('snapshots return the supply before and after the changes', async function () {
@@ -84,8 +84,8 @@ contract('ERC20Snapshot', function (accounts) {
8484
this.secondSnapshotIds = ['2', '3', '4'];
8585

8686
for (const id of this.secondSnapshotIds) {
87-
const { logs } = await this.token.snapshot();
88-
expectEvent.inLogs(logs, 'Snapshot', { id });
87+
const receipt = await this.token.snapshot();
88+
expectEvent(receipt, 'Snapshot', { id });
8989
}
9090
});
9191

@@ -116,8 +116,8 @@ contract('ERC20Snapshot', function (accounts) {
116116
beforeEach(async function () {
117117
this.initialSnapshotId = new BN('1');
118118

119-
const { logs } = await this.token.snapshot();
120-
expectEvent.inLogs(logs, 'Snapshot', { id: this.initialSnapshotId });
119+
const receipt = await this.token.snapshot();
120+
expectEvent(receipt, 'Snapshot', { id: this.initialSnapshotId });
121121
});
122122

123123
context('with no balance changes after the snapshot', function () {
@@ -147,8 +147,8 @@ contract('ERC20Snapshot', function (accounts) {
147147
beforeEach(async function () {
148148
this.secondSnapshotId = new BN('2');
149149

150-
const { logs } = await this.token.snapshot();
151-
expectEvent.inLogs(logs, 'Snapshot', { id: this.secondSnapshotId });
150+
const receipt = await this.token.snapshot();
151+
expectEvent(receipt, 'Snapshot', { id: this.secondSnapshotId });
152152
});
153153

154154
it('snapshots return the balances before and after the changes', async function () {
@@ -174,8 +174,8 @@ contract('ERC20Snapshot', function (accounts) {
174174
this.secondSnapshotIds = ['2', '3', '4'];
175175

176176
for (const id of this.secondSnapshotIds) {
177-
const { logs } = await this.token.snapshot();
178-
expectEvent.inLogs(logs, 'Snapshot', { id });
177+
const receipt = await this.token.snapshot();
178+
expectEvent(receipt, 'Snapshot', { id });
179179
}
180180
});
181181

test/token/ERC20/extensions/ERC20Votes.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ contract('ERC20Votes', function (accounts) {
206206
}),
207207
));
208208

209-
const { logs } = await this.token.delegateBySig(holderDelegatee, nonce, MAX_UINT256, v, r, s);
210-
const { args } = logs.find(({ event }) => event == 'DelegateChanged');
209+
const receipt = await this.token.delegateBySig(holderDelegatee, nonce, MAX_UINT256, v, r, s);
210+
const { args } = receipt.logs.find(({ event }) => event == 'DelegateChanged');
211211
expect(args.delegator).to.not.be.equal(delegatorAddress);
212212
expect(args.fromDelegate).to.be.equal(ZERO_ADDRESS);
213213
expect(args.toDelegate).to.be.equal(holderDelegatee);

test/token/ERC20/extensions/ERC20VotesComp.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ contract('ERC20VotesComp', function (accounts) {
206206
}),
207207
));
208208

209-
const { logs } = await this.token.delegateBySig(holderDelegatee, nonce, MAX_UINT256, v, r, s);
210-
const { args } = logs.find(({ event }) => event == 'DelegateChanged');
209+
const receipt = await this.token.delegateBySig(holderDelegatee, nonce, MAX_UINT256, v, r, s);
210+
const { args } = receipt.logs.find(({ event }) => event == 'DelegateChanged');
211211
expect(args.delegator).to.not.be.equal(delegatorAddress);
212212
expect(args.fromDelegate).to.be.equal(ZERO_ADDRESS);
213213
expect(args.toDelegate).to.be.equal(holderDelegatee);

0 commit comments

Comments
 (0)