Skip to content

Commit 356a8b0

Browse files
authored
Fixes flaky e2e test. (#83)
- Fixes expectUserOperationToSucceed parameter type - Fixes expectUserOperationToSucceed to actually execute toBeTruthy assertion - Fixes call to expectUserOperationToSucceed in flaky test to pass UserOperationReceipt rather than UserOperationHash
1 parent 87ef890 commit 356a8b0

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

packages/delegator-e2e/test/caveats/ownershipTransfer.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ describe('Ownership Transfer Caveat', () => {
148148
...gasPrice,
149149
});
150150

151-
await expectUserOperationToSucceed(userOpHash);
151+
const receipt = await sponsoredBundlerClient.waitForUserOperationReceipt({
152+
hash: userOpHash,
153+
});
154+
155+
await expectUserOperationToSucceed(receipt);
152156

153157
// Verify ownership was transferred successfully
154158
const finalOwner = await getContractOwner(contractAddress);
@@ -304,7 +308,11 @@ describe('Ownership Transfer Caveat', () => {
304308
...gasPrice,
305309
});
306310

307-
await expectUserOperationToSucceed(userOpHash);
311+
const receipt = await sponsoredBundlerClient.waitForUserOperationReceipt({
312+
hash: userOpHash,
313+
});
314+
315+
await expectUserOperationToSucceed(receipt);
308316

309317
// Verify ownership was transferred successfully
310318
const finalOwner = await getContractOwner(contractAddress);

packages/delegator-e2e/test/utils/assertions.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { Address } from 'viem';
22
import { expect } from 'vitest';
33
import { publicClient } from './helpers';
4-
import { UserOperationReceiptResponse } from '@metamask/delegation-toolkit';
5-
4+
import type { UserOperationReceipt } from 'viem/account-abstraction';
65
// common assertions to be shared across tests
76

87
export const expectCodeAt = async (address: Address, message?: string) => {
@@ -21,11 +20,11 @@ export const expectNoCodeAt = async (address: Address, message?: string) => {
2120
// todo: make this attempt to decode the failure logs
2221
// that is why I've made this asyncronous
2322
export const expectUserOperationToSucceed = async (
24-
receipt: UserOperationReceiptResponse,
23+
receipt: UserOperationReceipt,
2524
message?: string,
2625
) => {
2726
expect(
2827
receipt.success,
2928
message || `Expected user operation ${receipt.userOpHash} to succeed`,
30-
).toBeTruthy;
29+
).toBeTruthy();
3130
};

0 commit comments

Comments
 (0)