Skip to content

Commit 03dea82

Browse files
committed
chore(aerodrome-ability): update e2e tests to use setupVincentDevelopmentEnvironment
1 parent 4ddce81 commit 03dea82

File tree

2 files changed

+14
-101
lines changed

2 files changed

+14
-101
lines changed

packages/apps/ability-aerodrome-swap/test/e2e/swap-no-sponsorship.spec.ts

Lines changed: 7 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import {
2-
delegator,
3-
delegatee,
4-
funder,
5-
appManager,
6-
ensureUnexpiredCapacityToken,
2+
setupVincentDevelopmentEnvironment,
73
getChainHelpers,
84
getEnv,
95
type PkpInfo,
@@ -46,61 +42,20 @@ describe('Aerodrome Swap Ability E2E Tests without Gas Sponsorship', () => {
4642
let baseRpcProvider: providers.JsonRpcProvider;
4743

4844
beforeAll(async () => {
49-
await funder.checkFunderBalance();
50-
await delegatee.ensureAppDelegateeFunded();
51-
await appManager.ensureAppManagerFunded();
52-
53-
const chainHelpers = await getChainHelpers();
54-
wallets = chainHelpers.wallets;
55-
baseRpcProvider = chainHelpers.providers.base;
56-
57-
await ensureUnexpiredCapacityToken(wallets.appDelegatee);
58-
5945
const PERMISSION_DATA: PermissionData = {
6046
// Aerodrome Swap Ability has no policies
6147
[aerodromeBundledAbility.ipfsCid]: {},
6248
};
6349

64-
const abilityIpfsCids: string[] = Object.keys(PERMISSION_DATA);
65-
const abilityPolicies: string[][] = abilityIpfsCids.map((abilityIpfsCid) => {
66-
return Object.keys(PERMISSION_DATA[abilityIpfsCid]);
67-
});
68-
69-
// If an app exists for the delegatee, we will create a new app version with the new ipfs cids
70-
// Otherwise, we will create an app w/ version 1 appVersion with the new ipfs cids
71-
const existingApp = await delegatee.getAppInfo();
72-
console.log('[beforeAll] existingApp', existingApp);
73-
let appId: number;
74-
let appVersion: number;
75-
if (!existingApp) {
76-
console.log('[beforeAll] No existing app, registering new app');
77-
const newApp = await appManager.registerNewApp({ abilityIpfsCids, abilityPolicies });
78-
appId = newApp.appId;
79-
appVersion = newApp.appVersion;
80-
} else {
81-
console.log('[beforeAll] Existing app, registering new app version');
82-
const newAppVersion = await appManager.registerNewAppVersion({
83-
abilityIpfsCids,
84-
abilityPolicies,
85-
});
86-
appId = existingApp.appId;
87-
appVersion = newAppVersion.appVersion;
88-
}
89-
90-
agentPkpInfo = await delegator.getFundedAgentPkp();
91-
92-
await delegator.permitAppVersionForAgentWalletPkp({
50+
const setupResult = await setupVincentDevelopmentEnvironment({
9351
permissionData: PERMISSION_DATA,
94-
appId,
95-
appVersion,
96-
agentPkpInfo,
9752
});
9853

99-
await delegator.addPermissionForAbilities(
100-
wallets.agentWalletOwner,
101-
agentPkpInfo.tokenId,
102-
abilityIpfsCids,
103-
);
54+
agentPkpInfo = setupResult.agentPkpInfo;
55+
wallets = setupResult.wallets;
56+
57+
const chainHelpers = await getChainHelpers();
58+
baseRpcProvider = chainHelpers.providers.base;
10459
});
10560

10661
afterAll(async () => {

packages/apps/ability-aerodrome-swap/test/e2e/swap-with-sponsorship.spec.ts

Lines changed: 7 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import {
2-
delegator,
3-
delegatee,
4-
funder,
5-
appManager,
6-
ensureUnexpiredCapacityToken,
2+
setupVincentDevelopmentEnvironment,
73
getChainHelpers,
84
getEnv,
95
type PkpInfo,
@@ -54,58 +50,20 @@ describe('Aerodrome Swap Ability E2E Tests with Alchemy Gas Sponsorship', () =>
5450
let SMART_ACCOUNT_CLIENT: SmartAccountClient;
5551

5652
beforeAll(async () => {
57-
await funder.checkFunderBalance();
58-
await delegatee.ensureAppDelegateeFunded();
59-
await appManager.ensureAppManagerFunded();
60-
61-
const chainHelpers = await getChainHelpers();
62-
wallets = chainHelpers.wallets;
63-
baseRpcProvider = chainHelpers.providers.base;
64-
65-
await ensureUnexpiredCapacityToken(wallets.appDelegatee);
66-
6753
const PERMISSION_DATA: PermissionData = {
6854
// Aerodrome Swap Ability has no policies
6955
[aerodromeBundledAbility.ipfsCid]: {},
7056
};
7157

72-
const abilityIpfsCids: string[] = Object.keys(PERMISSION_DATA);
73-
const abilityPolicies: string[][] = abilityIpfsCids.map((abilityIpfsCid) => {
74-
return Object.keys(PERMISSION_DATA[abilityIpfsCid]);
75-
});
76-
77-
// If an app exists for the delegatee, we will create a new app version with the new ipfs cids
78-
// Otherwise, we will create an app w/ version 1 appVersion with the new ipfs cids
79-
const existingApp = await delegatee.getAppInfo();
80-
let appId: number;
81-
let appVersion: number;
82-
if (!existingApp) {
83-
const newApp = await appManager.registerNewApp({ abilityIpfsCids, abilityPolicies });
84-
appId = newApp.appId;
85-
appVersion = newApp.appVersion;
86-
} else {
87-
const newAppVersion = await appManager.registerNewAppVersion({
88-
abilityIpfsCids,
89-
abilityPolicies,
90-
});
91-
appId = existingApp.appId;
92-
appVersion = newAppVersion.appVersion;
93-
}
94-
95-
agentPkpInfo = await delegator.getFundedAgentPkp();
96-
97-
await delegator.permitAppVersionForAgentWalletPkp({
58+
const setupResult = await setupVincentDevelopmentEnvironment({
9859
permissionData: PERMISSION_DATA,
99-
appId,
100-
appVersion,
101-
agentPkpInfo,
10260
});
10361

104-
await delegator.addPermissionForAbilities(
105-
wallets.agentWalletOwner,
106-
agentPkpInfo.tokenId,
107-
abilityIpfsCids,
108-
);
62+
agentPkpInfo = setupResult.agentPkpInfo;
63+
wallets = setupResult.wallets;
64+
65+
const chainHelpers = await getChainHelpers();
66+
baseRpcProvider = chainHelpers.providers.base;
10967

11068
SMART_ACCOUNT_CLIENT = await createModularAccountV2Client({
11169
mode: '7702' as const,

0 commit comments

Comments
 (0)