Skip to content

Commit 4a67c6f

Browse files
Normalize BigInt usage in tests and fix minor inconsistencies (#5851)
Co-authored-by: dneptolus <[email protected]> Co-authored-by: Ernesto García <[email protected]>
1 parent 76f1563 commit 4a67c6f

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

test/governance/Governor.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ describe('Governor', function () {
682682

683683
await expect(this.helper.propose())
684684
.to.be.revertedWithCustomError(this.mock, 'GovernorInvalidProposalLength')
685-
.withArgs(0, 0, 0);
685+
.withArgs(0n, 0n, 0n);
686686
});
687687

688688
it('mismatch #1', async function () {
@@ -696,7 +696,7 @@ describe('Governor', function () {
696696
);
697697
await expect(this.helper.propose())
698698
.to.be.revertedWithCustomError(this.mock, 'GovernorInvalidProposalLength')
699-
.withArgs(0, 1, 1);
699+
.withArgs(0n, 1n, 1n);
700700
});
701701

702702
it('mismatch #2', async function () {
@@ -710,7 +710,7 @@ describe('Governor', function () {
710710
);
711711
await expect(this.helper.propose())
712712
.to.be.revertedWithCustomError(this.mock, 'GovernorInvalidProposalLength')
713-
.withArgs(1, 1, 0);
713+
.withArgs(1n, 1n, 0n);
714714
});
715715

716716
it('mismatch #3', async function () {
@@ -724,7 +724,7 @@ describe('Governor', function () {
724724
);
725725
await expect(this.helper.propose())
726726
.to.be.revertedWithCustomError(this.mock, 'GovernorInvalidProposalLength')
727-
.withArgs(1, 0, 1);
727+
.withArgs(1n, 0n, 1n);
728728
});
729729
});
730730

test/governance/TimelockController.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ describe('TimelockController', function () {
739739
),
740740
)
741741
.to.be.revertedWithCustomError(this.mock, 'TimelockInvalidOperationLength')
742-
.withArgs(0, this.operation.payloads.length, this.operation.values.length);
742+
.withArgs(0n, this.operation.payloads.length, this.operation.values.length);
743743
});
744744

745745
it('length mismatch #2', async function () {
@@ -1152,7 +1152,7 @@ describe('TimelockController', function () {
11521152
it('call payable with eth', async function () {
11531153
const operation = genOperation(
11541154
this.callreceivermock,
1155-
1,
1155+
1n,
11561156
this.callreceivermock.interface.encodeFunctionData('mockFunction'),
11571157
ethers.ZeroHash,
11581158
'0x5ab73cd33477dcd36c1e05e28362719d0ed59a7b9ff14939de63a43073dc1f44',
@@ -1170,7 +1170,7 @@ describe('TimelockController', function () {
11701170
await this.mock
11711171
.connect(this.executor)
11721172
.execute(operation.target, operation.value, operation.data, operation.predecessor, operation.salt, {
1173-
value: 1,
1173+
value: 1n,
11741174
});
11751175

11761176
expect(await ethers.provider.getBalance(this.mock)).to.equal(0n);
@@ -1264,7 +1264,7 @@ describe('TimelockController', function () {
12641264
await this.token.connect(this.other).safeTransferFrom(
12651265
this.other,
12661266
this.mock,
1267-
...Object.entries(tokenIds)[0n], // id + amount
1267+
...Object.entries(tokenIds)[0], // id + amount
12681268
'0x',
12691269
);
12701270
});

test/governance/extensions/GovernorCountingOverridable.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ describe('GovernorCountingOverridable', function () {
9393
expect(await ethers.provider.getBalance(this.receiver)).to.equal(value);
9494
});
9595

96-
describe('cast override vote', async function () {
96+
describe('cast override vote', function () {
9797
beforeEach(async function () {
9898
// user 1 -(delegate 10 tokens)-> user 2
9999
// user 2 -(delegate 7 tokens)-> user 2

test/governance/extensions/GovernorSequentialProposalId.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ describe('GovernorSequentialProposalId', function () {
167167
await this.helper.connect(this.proposer).propose();
168168
await expect(this.helper.connect(this.proposer).propose())
169169
.to.be.revertedWithCustomError(this.mock, 'GovernorUnexpectedProposalState')
170-
.withArgs(await this.proposal.id, 0, ethers.ZeroHash);
170+
.withArgs(await this.proposal.id, 0n, ethers.ZeroHash);
171171
});
172172

173173
it('nominal workflow', async function () {

test/governance/utils/Votes.behavior.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function shouldBehaveLikeVotes(tokens, { mode = 'blocknumber', fungible = true }
6565

6666
expect(await this.votes.delegates(this.alice)).to.equal(this.alice);
6767
expect(await this.votes.getVotes(this.alice)).to.equal(weight);
68-
expect(await this.votes.getVotes(this.bob)).to.equal(0);
68+
expect(await this.votes.getVotes(this.bob)).to.equal(0n);
6969

7070
const tx = await this.votes.connect(this.alice).delegate(this.bob);
7171
const timepoint = await time.clockFromReceipt[mode](tx);
@@ -74,9 +74,9 @@ function shouldBehaveLikeVotes(tokens, { mode = 'blocknumber', fungible = true }
7474
.to.emit(this.votes, 'DelegateChanged')
7575
.withArgs(this.alice, this.alice, this.bob)
7676
.to.emit(this.votes, 'DelegateVotesChanged')
77-
.withArgs(this.alice, weight, 0)
77+
.withArgs(this.alice, weight, 0n)
7878
.to.emit(this.votes, 'DelegateVotesChanged')
79-
.withArgs(this.bob, 0, weight);
79+
.withArgs(this.bob, 0n, weight);
8080

8181
expect(await this.votes.delegates(this.alice)).to.equal(this.bob);
8282
expect(await this.votes.getVotes(this.alice)).to.equal(0n);
@@ -117,7 +117,7 @@ function shouldBehaveLikeVotes(tokens, { mode = 'blocknumber', fungible = true }
117117
.to.emit(this.votes, 'DelegateChanged')
118118
.withArgs(this.delegator, ethers.ZeroAddress, this.delegatee)
119119
.to.emit(this.votes, 'DelegateVotesChanged')
120-
.withArgs(this.delegatee, 0, weight);
120+
.withArgs(this.delegatee, 0n, weight);
121121

122122
expect(await this.votes.delegates(this.delegator.address)).to.equal(this.delegatee);
123123
expect(await this.votes.getVotes(this.delegator.address)).to.equal(0n);
@@ -187,7 +187,7 @@ function shouldBehaveLikeVotes(tokens, { mode = 'blocknumber', fungible = true }
187187

188188
await expect(this.votes.delegateBySig(this.delegatee, nonce + 1n, ethers.MaxUint256, v, r, s))
189189
.to.be.revertedWithCustomError(this.votes, 'InvalidAccountNonce')
190-
.withArgs(this.delegator, 0);
190+
.withArgs(this.delegator, 0n);
191191
});
192192

193193
it('rejects expired permit', async function () {
@@ -217,7 +217,7 @@ function shouldBehaveLikeVotes(tokens, { mode = 'blocknumber', fungible = true }
217217
});
218218

219219
it('reverts if block number >= current block', async function () {
220-
const timepoint = 5e10;
220+
const timepoint = 50_000_000_000n;
221221
const clock = await this.votes.clock();
222222
await expect(this.votes.getPastTotalSupply(timepoint))
223223
.to.be.revertedWithCustomError(this.votes, 'ERC5805FutureLookup')
@@ -257,7 +257,7 @@ function shouldBehaveLikeVotes(tokens, { mode = 'blocknumber', fungible = true }
257257
t4.timepoint = await time.clockFromReceipt[mode](t4);
258258
t5.timepoint = await time.clockFromReceipt[mode](t5);
259259

260-
expect(await this.votes.getPastTotalSupply(t0.timepoint - 1n)).to.equal(0);
260+
expect(await this.votes.getPastTotalSupply(t0.timepoint - 1n)).to.equal(0n);
261261
expect(await this.votes.getPastTotalSupply(t0.timepoint)).to.equal(weight[0]);
262262
expect(await this.votes.getPastTotalSupply(t0.timepoint + 1n)).to.equal(weight[0]);
263263
expect(await this.votes.getPastTotalSupply(t1.timepoint)).to.equal(weight[0] + weight[1]);
@@ -268,7 +268,7 @@ function shouldBehaveLikeVotes(tokens, { mode = 'blocknumber', fungible = true }
268268
expect(await this.votes.getPastTotalSupply(t3.timepoint + 1n)).to.equal(weight[0] + weight[2]);
269269
expect(await this.votes.getPastTotalSupply(t4.timepoint)).to.equal(weight[2]);
270270
expect(await this.votes.getPastTotalSupply(t4.timepoint + 1n)).to.equal(weight[2]);
271-
expect(await this.votes.getPastTotalSupply(t5.timepoint)).to.equal(0);
271+
expect(await this.votes.getPastTotalSupply(t5.timepoint)).to.equal(0n);
272272
await expect(this.votes.getPastTotalSupply(t5.timepoint + 1n))
273273
.to.be.revertedWithCustomError(this.votes, 'ERC5805FutureLookup')
274274
.withArgs(t5.timepoint + 1n, t5.timepoint + 1n);
@@ -287,7 +287,7 @@ function shouldBehaveLikeVotes(tokens, { mode = 'blocknumber', fungible = true }
287287
describe('getPastVotes', function () {
288288
it('reverts if block number >= current block', async function () {
289289
const clock = await this.votes.clock();
290-
const timepoint = 5e10; // far in the future
290+
const timepoint = 50_000_000_000n; // far in the future
291291
await expect(this.votes.getPastVotes(this.bob, timepoint))
292292
.to.be.revertedWithCustomError(this.votes, 'ERC5805FutureLookup')
293293
.withArgs(timepoint, clock);

0 commit comments

Comments
 (0)