Skip to content

Commit 4c3ef87

Browse files
authored
Await .eventually test matchers (#5408)
1 parent dd04dfe commit 4c3ef87

File tree

4 files changed

+111
-108
lines changed

4 files changed

+111
-108
lines changed

test/account/utils/draft-ERC4337Utils.test.js

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('ERC4337Utils', function () {
2727
const validAfter = 0x9abcdef0n;
2828
const validationData = packValidationData(validAfter, validUntil, authorizer);
2929

30-
expect(this.utils.$parseValidationData(validationData)).to.eventually.deep.equal([
30+
await expect(this.utils.$parseValidationData(validationData)).to.eventually.deep.equal([
3131
authorizer.address,
3232
validAfter,
3333
validUntil,
@@ -39,21 +39,21 @@ describe('ERC4337Utils', function () {
3939
const validAfter = 0x12345678n;
4040
const validationData = packValidationData(validAfter, 0, authorizer);
4141

42-
expect(this.utils.$parseValidationData(validationData)).to.eventually.deep.equal([
42+
await expect(this.utils.$parseValidationData(validationData)).to.eventually.deep.equal([
4343
authorizer.address,
4444
validAfter,
4545
MAX_UINT48,
4646
]);
4747
});
4848

4949
it('parse canonical values', async function () {
50-
expect(this.utils.$parseValidationData(this.SIG_VALIDATION_SUCCESS)).to.eventually.deep.equal([
50+
await expect(this.utils.$parseValidationData(this.SIG_VALIDATION_SUCCESS)).to.eventually.deep.equal([
5151
ethers.ZeroAddress,
5252
0n,
5353
MAX_UINT48,
5454
]);
5555

56-
expect(this.utils.$parseValidationData(this.SIG_VALIDATION_FAILED)).to.eventually.deep.equal([
56+
await expect(this.utils.$parseValidationData(this.SIG_VALIDATION_FAILED)).to.eventually.deep.equal([
5757
ADDRESS_ONE,
5858
0n,
5959
MAX_UINT48,
@@ -68,7 +68,7 @@ describe('ERC4337Utils', function () {
6868
const validAfter = 0x9abcdef0n;
6969
const validationData = packValidationData(validAfter, validUntil, authorizer);
7070

71-
expect(
71+
await expect(
7272
this.utils.$packValidationData(ethers.Typed.address(authorizer), validAfter, validUntil),
7373
).to.eventually.equal(validationData);
7474
});
@@ -79,22 +79,22 @@ describe('ERC4337Utils', function () {
7979
const validAfter = 0x9abcdef0n;
8080
const validationData = packValidationData(validAfter, validUntil, false);
8181

82-
expect(this.utils.$packValidationData(ethers.Typed.bool(success), validAfter, validUntil)).to.eventually.equal(
83-
validationData,
84-
);
82+
await expect(
83+
this.utils.$packValidationData(ethers.Typed.bool(success), validAfter, validUntil),
84+
).to.eventually.equal(validationData);
8585
});
8686

8787
it('packing reproduced canonical values', async function () {
88-
expect(this.utils.$packValidationData(ethers.Typed.address(ethers.ZeroAddress), 0n, 0n)).to.eventually.equal(
89-
this.SIG_VALIDATION_SUCCESS,
90-
);
91-
expect(this.utils.$packValidationData(ethers.Typed.bool(true), 0n, 0n)).to.eventually.equal(
88+
await expect(
89+
this.utils.$packValidationData(ethers.Typed.address(ethers.ZeroAddress), 0n, 0n),
90+
).to.eventually.equal(this.SIG_VALIDATION_SUCCESS);
91+
await expect(this.utils.$packValidationData(ethers.Typed.bool(true), 0n, 0n)).to.eventually.equal(
9292
this.SIG_VALIDATION_SUCCESS,
9393
);
94-
expect(this.utils.$packValidationData(ethers.Typed.address(ADDRESS_ONE), 0n, 0n)).to.eventually.equal(
94+
await expect(this.utils.$packValidationData(ethers.Typed.address(ADDRESS_ONE), 0n, 0n)).to.eventually.equal(
9595
this.SIG_VALIDATION_FAILED,
9696
);
97-
expect(this.utils.$packValidationData(ethers.Typed.bool(false), 0n, 0n)).to.eventually.equal(
97+
await expect(this.utils.$packValidationData(ethers.Typed.bool(false), 0n, 0n)).to.eventually.equal(
9898
this.SIG_VALIDATION_FAILED,
9999
);
100100
});
@@ -112,8 +112,8 @@ describe('ERC4337Utils', function () {
112112
const expected = packValidationData(validAfter2, validUntil1, true);
113113

114114
// check symmetry
115-
expect(this.utils.$combineValidationData(validationData1, validationData2)).to.eventually.equal(expected);
116-
expect(this.utils.$combineValidationData(validationData2, validationData1)).to.eventually.equal(expected);
115+
await expect(this.utils.$combineValidationData(validationData1, validationData2)).to.eventually.equal(expected);
116+
await expect(this.utils.$combineValidationData(validationData2, validationData1)).to.eventually.equal(expected);
117117
});
118118

119119
for (const [authorizer1, authorizer2] of [
@@ -126,8 +126,8 @@ describe('ERC4337Utils', function () {
126126
const expected = packValidationData(validAfter2, validUntil1, false);
127127

128128
// check symmetry
129-
expect(this.utils.$combineValidationData(validationData1, validationData2)).to.eventually.equal(expected);
130-
expect(this.utils.$combineValidationData(validationData2, validationData1)).to.eventually.equal(expected);
129+
await expect(this.utils.$combineValidationData(validationData1, validationData2)).to.eventually.equal(expected);
130+
await expect(this.utils.$combineValidationData(validationData2, validationData1)).to.eventually.equal(expected);
131131
});
132132
}
133133
});
@@ -139,7 +139,7 @@ describe('ERC4337Utils', function () {
139139
const validUntil = MAX_UINT48;
140140
const validationData = packValidationData(validAfter, validUntil, aggregator);
141141

142-
expect(this.utils.$getValidationData(validationData)).to.eventually.deep.equal([aggregator.address, false]);
142+
await expect(this.utils.$getValidationData(validationData)).to.eventually.deep.equal([aggregator.address, false]);
143143
});
144144

145145
it('returns the validation data with invalid validity range (expired)', async function () {
@@ -148,7 +148,7 @@ describe('ERC4337Utils', function () {
148148
const validUntil = 1;
149149
const validationData = packValidationData(validAfter, validUntil, aggregator);
150150

151-
expect(this.utils.$getValidationData(validationData)).to.eventually.deep.equal([aggregator.address, true]);
151+
await expect(this.utils.$getValidationData(validationData)).to.eventually.deep.equal([aggregator.address, true]);
152152
});
153153

154154
it('returns the validation data with invalid validity range (not yet valid)', async function () {
@@ -157,11 +157,11 @@ describe('ERC4337Utils', function () {
157157
const validUntil = MAX_UINT48;
158158
const validationData = packValidationData(validAfter, validUntil, aggregator);
159159

160-
expect(this.utils.$getValidationData(validationData)).to.eventually.deep.equal([aggregator.address, true]);
160+
await expect(this.utils.$getValidationData(validationData)).to.eventually.deep.equal([aggregator.address, true]);
161161
});
162162

163-
it('returns address(0) and false for validationData = 0', function () {
164-
expect(this.utils.$getValidationData(0n)).to.eventually.deep.equal([ethers.ZeroAddress, false]);
163+
it('returns address(0) and false for validationData = 0', async function () {
164+
await expect(this.utils.$getValidationData(0n)).to.eventually.deep.equal([ethers.ZeroAddress, false]);
165165
});
166166
});
167167

@@ -172,13 +172,13 @@ describe('ERC4337Utils', function () {
172172
const otherChainId = 0xdeadbeef;
173173

174174
// check that helper matches entrypoint logic
175-
expect(entrypoint.getUserOpHash(userOp.packed)).to.eventually.equal(userOp.hash(entrypoint, chainId));
175+
await expect(entrypoint.getUserOpHash(userOp.packed)).to.eventually.equal(userOp.hash(entrypoint, chainId));
176176

177177
// check library against helper
178-
expect(this.utils.$hash(userOp.packed, entrypoint, chainId)).to.eventually.equal(
178+
await expect(this.utils.$hash(userOp.packed, entrypoint, chainId)).to.eventually.equal(
179179
userOp.hash(entrypoint, chainId),
180180
);
181-
expect(this.utils.$hash(userOp.packed, entrypoint, otherChainId)).to.eventually.equal(
181+
await expect(this.utils.$hash(userOp.packed, entrypoint, otherChainId)).to.eventually.equal(
182182
userOp.hash(entrypoint, otherChainId),
183183
);
184184
});
@@ -202,34 +202,34 @@ describe('ERC4337Utils', function () {
202202
});
203203

204204
it('returns factory', async function () {
205-
expect(this.utils.$factory(this.userOp.packed)).to.eventually.equal(this.factory);
206-
expect(this.utils.$factory(this.emptyUserOp.packed)).to.eventually.equal(ethers.ZeroAddress);
205+
await expect(this.utils.$factory(this.userOp.packed)).to.eventually.equal(this.factory);
206+
await expect(this.utils.$factory(this.emptyUserOp.packed)).to.eventually.equal(ethers.ZeroAddress);
207207
});
208208

209209
it('returns factoryData', async function () {
210-
expect(this.utils.$factoryData(this.userOp.packed)).to.eventually.equal('0x123456');
211-
expect(this.utils.$factoryData(this.emptyUserOp.packed)).to.eventually.equal('0x');
210+
await expect(this.utils.$factoryData(this.userOp.packed)).to.eventually.equal('0x123456');
211+
await expect(this.utils.$factoryData(this.emptyUserOp.packed)).to.eventually.equal('0x');
212212
});
213213
});
214214

215215
it('returns verificationGasLimit', async function () {
216216
const userOp = new UserOperation({ sender: this.sender, nonce: 1, verificationGas: 0x12345678n });
217-
expect(this.utils.$verificationGasLimit(userOp.packed)).to.eventually.equal(userOp.verificationGas);
217+
await expect(this.utils.$verificationGasLimit(userOp.packed)).to.eventually.equal(userOp.verificationGas);
218218
});
219219

220220
it('returns callGasLimit', async function () {
221221
const userOp = new UserOperation({ sender: this.sender, nonce: 1, callGas: 0x12345678n });
222-
expect(this.utils.$callGasLimit(userOp.packed)).to.eventually.equal(userOp.callGas);
222+
await expect(this.utils.$callGasLimit(userOp.packed)).to.eventually.equal(userOp.callGas);
223223
});
224224

225225
it('returns maxPriorityFeePerGas', async function () {
226226
const userOp = new UserOperation({ sender: this.sender, nonce: 1, maxPriorityFee: 0x12345678n });
227-
expect(this.utils.$maxPriorityFeePerGas(userOp.packed)).to.eventually.equal(userOp.maxPriorityFee);
227+
await expect(this.utils.$maxPriorityFeePerGas(userOp.packed)).to.eventually.equal(userOp.maxPriorityFee);
228228
});
229229

230230
it('returns maxFeePerGas', async function () {
231231
const userOp = new UserOperation({ sender: this.sender, nonce: 1, maxFeePerGas: 0x12345678n });
232-
expect(this.utils.$maxFeePerGas(userOp.packed)).to.eventually.equal(userOp.maxFeePerGas);
232+
await expect(this.utils.$maxFeePerGas(userOp.packed)).to.eventually.equal(userOp.maxFeePerGas);
233233
});
234234

235235
it('returns gasPrice', async function () {
@@ -239,7 +239,7 @@ describe('ERC4337Utils', function () {
239239
maxPriorityFee: 0x12345678n,
240240
maxFeePerGas: 0x87654321n,
241241
});
242-
expect(this.utils.$gasPrice(userOp.packed)).to.eventually.equal(userOp.maxPriorityFee);
242+
await expect(this.utils.$gasPrice(userOp.packed)).to.eventually.equal(userOp.maxPriorityFee);
243243
});
244244

245245
describe('paymasterAndData', function () {
@@ -260,27 +260,27 @@ describe('ERC4337Utils', function () {
260260
});
261261

262262
it('returns paymaster', async function () {
263-
expect(this.utils.$paymaster(this.userOp.packed)).to.eventually.equal(this.userOp.paymaster);
264-
expect(this.utils.$paymaster(this.emptyUserOp.packed)).to.eventually.equal(ethers.ZeroAddress);
263+
await expect(this.utils.$paymaster(this.userOp.packed)).to.eventually.equal(this.userOp.paymaster);
264+
await expect(this.utils.$paymaster(this.emptyUserOp.packed)).to.eventually.equal(ethers.ZeroAddress);
265265
});
266266

267267
it('returns verificationGasLimit', async function () {
268-
expect(this.utils.$paymasterVerificationGasLimit(this.userOp.packed)).to.eventually.equal(
268+
await expect(this.utils.$paymasterVerificationGasLimit(this.userOp.packed)).to.eventually.equal(
269269
this.userOp.paymasterVerificationGasLimit,
270270
);
271-
expect(this.utils.$paymasterVerificationGasLimit(this.emptyUserOp.packed)).to.eventually.equal(0n);
271+
await expect(this.utils.$paymasterVerificationGasLimit(this.emptyUserOp.packed)).to.eventually.equal(0n);
272272
});
273273

274274
it('returns postOpGasLimit', async function () {
275-
expect(this.utils.$paymasterPostOpGasLimit(this.userOp.packed)).to.eventually.equal(
275+
await expect(this.utils.$paymasterPostOpGasLimit(this.userOp.packed)).to.eventually.equal(
276276
this.userOp.paymasterPostOpGasLimit,
277277
);
278-
expect(this.utils.$paymasterPostOpGasLimit(this.emptyUserOp.packed)).to.eventually.equal(0n);
278+
await expect(this.utils.$paymasterPostOpGasLimit(this.emptyUserOp.packed)).to.eventually.equal(0n);
279279
});
280280

281281
it('returns data', async function () {
282-
expect(this.utils.$paymasterData(this.userOp.packed)).to.eventually.equal(this.userOp.paymasterData);
283-
expect(this.utils.$paymasterData(this.emptyUserOp.packed)).to.eventually.equal('0x');
282+
await expect(this.utils.$paymasterData(this.userOp.packed)).to.eventually.equal(this.userOp.paymasterData);
283+
await expect(this.utils.$paymasterData(this.emptyUserOp.packed)).to.eventually.equal('0x');
284284
});
285285
});
286286
});

0 commit comments

Comments
 (0)