Skip to content

Commit 48f5cf2

Browse files
authored
Add E2E tests for revamped recovery pallet (#602)
* Add Asset Hub Westend chain and westend network group * Add recovery pallet E2E test module * Add Asset Hub Westend recovery E2E entrypoint * Remove redundant conditional in completeRecovery helper * Improve type safety in recovery test helpers * Adapt recovery tests to master SDK runtime - Rename `inheritanceOrder` to `inheritancePriority` following field rename in pallet - Rename `LowerOrderRecovered` to `HigherPriorityRecovered` following error rename - Increase `cancelDelay` in `cancelBeforeDelayFailsTest` and `approvalResetsTimerTest` from 4 to 20: `RELAY_PARENT_OFFSET=1` on master AHW advances relay by 4 per block, trivially satisfying a delay of 4 on the first `newBlock()` - Remove strict `expect(current).toBe(target)` assertion from `fullLifecycleTest`; relay overshoot is expected and the meaningful assertion is the event - Flip `controlInheritedAccountProxyFilteredTest` to `controlInheritedAccountNonTransferProxyTest`: the PR explicitly allows `control_inherited_account` through `NonTransfer` proxy * Bump block numbers * Move recovery tests to westend package * Add Westend PET package * Reduce `any` surface in recovery test helpers Replace `Client<any, any>` with `{ api: ApiPromise }` on helpers that only need the API. Consolidate all pallet-recovery event data field accesses into a single `recoveryEventData` extractor, containing the unavoidable cast to one site with an explanation. Remaining `any` casts are on `api.query.recovery` and the event predicate — both genuinely unavoidable until pallet-recovery gains generated TypeScript types in `@polkadot/api`. * Add some comments to PSM storage in Asset Hub chain file * Update block numbers
1 parent cb81579 commit 48f5cf2

8 files changed

Lines changed: 1268 additions & 60 deletions
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
ASSETHUBKUSAMA_BLOCK_NUMBER=16320734
2-
BASILISK_BLOCK_NUMBER=14037168
3-
BIFROSTKUSAMA_BLOCK_NUMBER=13679100
4-
BRIDGEHUBKUSAMA_BLOCK_NUMBER=8131570
5-
CORETIMEKUSAMA_BLOCK_NUMBER=5066739
6-
ENCOINTERKUSAMA_BLOCK_NUMBER=13497495
7-
KARURA_BLOCK_NUMBER=11498107
8-
KUSAMA_BLOCK_NUMBER=33364447
9-
MOONRIVER_BLOCK_NUMBER=16141016
10-
PEOPLEKUSAMA_BLOCK_NUMBER=8913298
11-
SHIDEN_BLOCK_NUMBER=14655667
1+
ASSETHUBKUSAMA_BLOCK_NUMBER=16399947
2+
BASILISK_BLOCK_NUMBER=14058899
3+
BIFROSTKUSAMA_BLOCK_NUMBER=13708373
4+
BRIDGEHUBKUSAMA_BLOCK_NUMBER=8146157
5+
CORETIMEKUSAMA_BLOCK_NUMBER=5081409
6+
ENCOINTERKUSAMA_BLOCK_NUMBER=13523022
7+
KARURA_BLOCK_NUMBER=11512753
8+
KUSAMA_BLOCK_NUMBER=33393870
9+
MOONRIVER_BLOCK_NUMBER=16167319
10+
PEOPLEKUSAMA_BLOCK_NUMBER=8942534
11+
SHIDEN_BLOCK_NUMBER=14680186
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
ACALA_BLOCK_NUMBER=11041055
2-
ASSETHUBPOLKADOT_BLOCK_NUMBER=15290168
3-
ASTAR_BLOCK_NUMBER=13210525
4-
BIFROSTPOLKADOT_BLOCK_NUMBER=12100916
5-
BRIDGEHUBPOLKADOT_BLOCK_NUMBER=7578775
6-
COLLECTIVESPOLKADOT_BLOCK_NUMBER=8785633
7-
CORETIMEPOLKADOT_BLOCK_NUMBER=4169586
8-
HYDRATION_BLOCK_NUMBER=12290624
9-
MOONBEAM_BLOCK_NUMBER=15476831
10-
PEOPLEPOLKADOT_BLOCK_NUMBER=4516028
11-
POLKADOT_BLOCK_NUMBER=31072053
1+
ACALA_BLOCK_NUMBER=11055889
2+
ASSETHUBPOLKADOT_BLOCK_NUMBER=15374642
3+
ASTAR_BLOCK_NUMBER=13233817
4+
BIFROSTPOLKADOT_BLOCK_NUMBER=12126432
5+
BRIDGEHUBPOLKADOT_BLOCK_NUMBER=7593633
6+
COLLECTIVESPOLKADOT_BLOCK_NUMBER=8800504
7+
CORETIMEPOLKADOT_BLOCK_NUMBER=4184445
8+
HYDRATION_BLOCK_NUMBER=12312341
9+
MOONBEAM_BLOCK_NUMBER=15504293
10+
PEOPLEPOLKADOT_BLOCK_NUMBER=4545218
11+
POLKADOT_BLOCK_NUMBER=31101915
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ASSETHUBWESTEND_BLOCK_NUMBER=14771717
1+
ASSETHUBWESTEND_BLOCK_NUMBER=14827899

packages/networks/src/chains/assethub.ts

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ import { defineChain } from '../defineChain.js'
44
import endpoints from '../pet-chain-endpoints.json' with { type: 'json' }
55
import { defaultAccounts, defaultAccountsSr25519, testAccounts } from '../testAccounts.js'
66

7-
/**
8-
* Build an XCM V5 Location for a local Assets pallet asset.
9-
* PSM storage and extrinsics now key by `StagingXcmV5Location` instead of raw asset IDs.
10-
*/
117
const assetLocation = (assetId: number) => ({
128
parents: 0,
139
interior: { X2: [{ PalletInstance: 50 }, { GeneralIndex: assetId }] },
@@ -65,21 +61,26 @@ const custom = {
6561
},
6662
}
6763

68-
const getPsmInitStorages = (config: typeof custom.assetHubWestend) => {
64+
const getAhwInitStorages = (config: typeof custom.assetHubWestend) => {
6965
return {
7066
System: {
7167
account: [
7268
[[defaultAccounts.alice.address], { providers: 1, data: { free: 1000e10 } }],
7369
[[defaultAccountsSr25519.alice.address], { providers: 1, data: { free: 1000e10 } }],
74-
[[testAccounts.alice.address], { providers: 1, data: { free: 1000e10 } }],
75-
[[testAccounts.bob.address], { providers: 1, data: { free: 1000e10 } }],
70+
// testAccounts funded at 100k WND — enough to cover recovery SecurityDeposit (10 WND) plus fees
71+
[[testAccounts.alice.address], { providers: 1, data: { free: 100_000e10 } }],
72+
[[testAccounts.bob.address], { providers: 1, data: { free: 100_000e10 } }],
73+
[[testAccounts.charlie.address], { providers: 1, data: { free: 100_000e10 } }],
74+
[[testAccounts.dave.address], { providers: 1, data: { free: 100_000e10 } }],
75+
[[testAccounts.eve.address], { providers: 1, data: { free: 100_000e10 } }],
76+
[[testAccounts.ferdie.address], { providers: 1, data: { free: 100_000e10 } }],
7677
],
7778
},
7879
Assets: {
80+
// Synthetic assets injected via Chopsticks override — not present on live WAH
7981
asset: [
80-
// USDX (1338) — synthetic, 2 decimals
8182
[
82-
[config.usdxIndex],
83+
[config.usdxIndex], // USDX: 2 decimals, total supply 10,000 USDX
8384
{
8485
owner: testAccounts.alice.address,
8586
issuer: testAccounts.alice.address,
@@ -95,9 +96,8 @@ const getPsmInitStorages = (config: typeof custom.assetHubWestend) => {
9596
status: 'Live',
9697
},
9798
],
98-
// DAI (1339) — synthetic, 18 decimals
9999
[
100-
[config.daiIndex],
100+
[config.daiIndex], // DAI: 18 decimals, total supply 10,000 DAI
101101
{
102102
owner: testAccounts.alice.address,
103103
issuer: testAccounts.alice.address,
@@ -122,41 +122,50 @@ const getPsmInitStorages = (config: typeof custom.assetHubWestend) => {
122122
[[config.daiIndex], { deposit: 0, name: 'Dai Stablecoin', symbol: 'DAI', decimals: 18, isFrozen: false }],
123123
],
124124
account: [
125+
// USDT (live on WAH) — alice and bob start with 1,000 USDT each
125126
[[config.usdtIndex, testAccounts.alice.address], { balance: 1000e6 }],
126127
[[config.usdtIndex, testAccounts.bob.address], { balance: 1000e6 }],
128+
// USDX — alice and bob start with 1,000 USDX each (2 decimals)
127129
[[config.usdxIndex, testAccounts.alice.address], { balance: 1000 * 100 }],
128130
[[config.usdxIndex, testAccounts.bob.address], { balance: 1000 * 100 }],
131+
// DAI — alice and bob start with 1,000 DAI each (18 decimals)
129132
[[config.daiIndex, testAccounts.alice.address], { balance: 1000n * 10n ** 18n }],
130133
[[config.daiIndex, testAccounts.bob.address], { balance: 1000n * 10n ** 18n }],
134+
// pUSD stable asset — alice starts with 1,000 pUSD (6 decimals)
131135
[[config.psmStableAssetId, testAccounts.alice.address], { balance: 1000e6 }],
132136
],
133137
},
134138
Psm: {
135-
maxPsmDebtOfTotal: 500_000,
139+
maxPsmDebtOfTotal: 500_000, // 50% of total supply ceiling
140+
// registered external assets the PSM will accept for minting/redemption
136141
externalAssets: [
137142
[[config.usdtLocation], { AllEnabled: null }],
138143
[[config.usdxLocation], { AllEnabled: null }],
139144
[[config.daiLocation], { AllEnabled: null }],
140145
],
146+
// decimal precision for each external asset — used to normalise amounts
141147
externalDecimals: [
142148
[[config.usdtLocation], 6],
143149
[[config.usdxLocation], 2],
144150
[[config.daiLocation], 18],
145151
],
152+
// 0.5% minting fee (5_000 / 1_000_000)
146153
mintingFee: [
147154
[[config.usdtLocation], 5_000],
148155
[[config.usdxLocation], 5_000],
149156
[[config.daiLocation], 5_000],
150157
],
158+
// 0.5% redemption fee
151159
redemptionFee: [
152160
[[config.usdtLocation], 5_000],
153161
[[config.usdxLocation], 5_000],
154162
[[config.daiLocation], 5_000],
155163
],
164+
// per-asset ceiling as a fraction of maxPsmDebtOfTotal (parts per million)
156165
assetCeilingWeight: [
157-
[[config.usdtLocation], 400_000],
158-
[[config.usdxLocation], 300_000],
159-
[[config.daiLocation], 300_000],
166+
[[config.usdtLocation], 400_000], // 40%
167+
[[config.usdxLocation], 300_000], // 30%
168+
[[config.daiLocation], 300_000], // 30%
160169
],
161170
psmDebt: [
162171
[[config.usdtLocation], 0],
@@ -192,50 +201,44 @@ const getInitStorages = (config: typeof custom.assetHubPolkadot | typeof custom.
192201
return baseStorages
193202
}
194203

204+
const assetHubProperties = (addressEncoding: number) =>
205+
({
206+
addressEncoding,
207+
proxyBlockProvider: 'NonLocal',
208+
schedulerBlockProvider: 'NonLocal',
209+
asyncBacking: 'Enabled',
210+
feeExtractor: standardFeeExtractor,
211+
}) as const
212+
213+
// Asset Hub Polkadot (SS58: 0)
195214
export const assetHubPolkadot = defineChain({
196215
name: 'assetHubPolkadot',
197216
endpoint: endpoints.assetHubPolkadot,
198217
paraId: 1000,
199218
networkGroup: 'polkadot',
200219
custom: custom.assetHubPolkadot,
201220
initStorages: getInitStorages(custom.assetHubPolkadot),
202-
properties: {
203-
addressEncoding: 0,
204-
proxyBlockProvider: 'NonLocal',
205-
schedulerBlockProvider: 'NonLocal',
206-
asyncBacking: 'Enabled',
207-
feeExtractor: standardFeeExtractor,
208-
},
221+
properties: assetHubProperties(0),
209222
})
210223

224+
// Asset Hub Kusama (SS58: 2)
211225
export const assetHubKusama = defineChain({
212226
name: 'assetHubKusama',
213227
endpoint: endpoints.assetHubKusama,
214228
paraId: 1000,
215229
networkGroup: 'kusama',
216230
custom: custom.assetHubKusama,
217231
initStorages: getInitStorages(custom.assetHubKusama),
218-
properties: {
219-
addressEncoding: 2,
220-
proxyBlockProvider: 'NonLocal',
221-
schedulerBlockProvider: 'NonLocal',
222-
asyncBacking: 'Enabled',
223-
feeExtractor: standardFeeExtractor,
224-
},
232+
properties: assetHubProperties(2),
225233
})
226234

235+
// Asset Hub Westend (SS58: 42) — includes PSM and recovery init storages
227236
export const assetHubWestend = defineChain({
228237
name: 'assetHubWestend',
229238
endpoint: endpoints.assetHubWestend,
230239
paraId: 1000,
231240
networkGroup: 'westend',
232241
custom: custom.assetHubWestend,
233-
initStorages: getPsmInitStorages(custom.assetHubWestend),
234-
properties: {
235-
addressEncoding: 42,
236-
proxyBlockProvider: 'NonLocal',
237-
schedulerBlockProvider: 'NonLocal',
238-
asyncBacking: 'Enabled',
239-
feeExtractor: standardFeeExtractor,
240-
},
242+
initStorages: getAhwInitStorages(custom.assetHubWestend),
243+
properties: assetHubProperties(42),
241244
})

packages/shared/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export * from './postAhmFiltering.js'
1414
export * from './preimage.js'
1515
export * from './proxy.js'
1616
export * from './psm.js'
17+
export * from './recovery.js'
1718
export * from './remoteProxy.js'
1819
export * from './scheduler.js'
1920
export * from './setup.js'

0 commit comments

Comments
 (0)