Skip to content

Commit 2ced85c

Browse files
authored
Refactor liquidity tests for future runtime upgrades (#418)
* Update liquidity restriction test expectations * Update comment for liquidity restriction test * Create accounts-test-specific config * Use new acc cfg to refactor AH balances E2E tests * Add missing negation to lock action filtering in AH * Improve default account tests' cfg object * Apply lint * Remove leftover `console.log`
1 parent 6451da7 commit 2ced85c

11 files changed

+348
-178
lines changed

packages/kusama/src/__snapshots__/assetHubKusama.accounts.e2e.test.ts.snap

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction erro
191191
]
192192
`;
193193

194+
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via manual reserve and manual lock, triggered via referendum submission > liquidity restricted action events 1`] = `[]`;
195+
194196
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via manual reserve and manual lock, triggered via referendum submission > liquidity restriction test skipped 1`] = `"Skipping test - required pallets not available: deposit=referendum submission"`;
195197

196198
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via manual reserve and vested transfer, triggered via multisig creation > liquidity restriction test skipped 1`] = `"Skipping test - required pallets not available: lock=vested transfer"`;
@@ -199,10 +201,16 @@ exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction erro
199201

200202
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via manual reserve and vested transfer, triggered via referendum submission > liquidity restriction test skipped 1`] = `"Skipping test - required pallets not available: lock=vested transfer, deposit=referendum submission"`;
201203

204+
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via nomination pool and manual lock, triggered via multisig creation > liquidity restricted action events 1`] = `[]`;
205+
202206
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via nomination pool and manual lock, triggered via multisig creation > liquidity restriction test skipped 1`] = `"Skipping test - required pallets not available: reserve=nomination pool"`;
203207

208+
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via nomination pool and manual lock, triggered via proxy addition > liquidity restricted action events 1`] = `[]`;
209+
204210
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via nomination pool and manual lock, triggered via proxy addition > liquidity restriction test skipped 1`] = `"Skipping test - required pallets not available: reserve=nomination pool"`;
205211

212+
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via nomination pool and manual lock, triggered via referendum submission > liquidity restricted action events 1`] = `[]`;
213+
206214
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via nomination pool and manual lock, triggered via referendum submission > liquidity restriction test skipped 1`] = `"Skipping test - required pallets not available: reserve=nomination pool, deposit=referendum submission"`;
207215

208216
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via nomination pool and vested transfer, triggered via multisig creation > liquidity restriction test skipped 1`] = `"Skipping test - required pallets not available: reserve=nomination pool, lock=vested transfer"`;
@@ -211,10 +219,29 @@ exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction erro
211219

212220
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via nomination pool and vested transfer, triggered via referendum submission > liquidity restriction test skipped 1`] = `"Skipping test - required pallets not available: reserve=nomination pool, lock=vested transfer, deposit=referendum submission"`;
213221

222+
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via staking bond and manual lock, triggered via multisig creation > deposit action success events 1`] = `
223+
[
224+
{
225+
"data": {
226+
"amount": "(rounded 6700000000)",
227+
"who": "D8ew585BL5H1ALhn4kmJoxhgqcgKDZLPc6xunJNv4mmrBns",
228+
},
229+
"method": "Reserved",
230+
"section": "balances",
231+
},
232+
]
233+
`;
234+
235+
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via staking bond and manual lock, triggered via multisig creation > liquidity restricted action events 1`] = `[]`;
236+
214237
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via staking bond and manual lock, triggered via multisig creation > liquidity restriction test skipped 1`] = `"Skipping test - required pallets not available: reserve=staking bond"`;
215238

239+
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via staking bond and manual lock, triggered via proxy addition > liquidity restricted action events 1`] = `[]`;
240+
216241
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via staking bond and manual lock, triggered via proxy addition > liquidity restriction test skipped 1`] = `"Skipping test - required pallets not available: reserve=staking bond"`;
217242

243+
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via staking bond and manual lock, triggered via referendum submission > liquidity restricted action events 1`] = `[]`;
244+
218245
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via staking bond and manual lock, triggered via referendum submission > liquidity restriction test skipped 1`] = `"Skipping test - required pallets not available: reserve=staking bond, deposit=referendum submission"`;
219246

220247
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via staking bond and vested transfer, triggered via multisig creation > liquidity restriction test skipped 1`] = `"Skipping test - required pallets not available: reserve=staking bond, lock=vested transfer"`;

packages/kusama/src/__snapshots__/coretimeKusama.accounts.e2e.test.ts.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ exports[`Kusama Coretime Accounts > \`transfer_all\` > transfer all with keepAli
141141
]
142142
`;
143143

144+
exports[`Kusama Coretime Accounts > currency tests > liquidity restriction error: funds locked via manual reserve and manual lock, triggered via multisig creation > deposit action success events 1`] = `[]`;
145+
144146
exports[`Kusama Coretime Accounts > currency tests > liquidity restriction error: funds locked via manual reserve and manual lock, triggered via multisig creation > liquidity restricted action events 1`] = `
145147
[
146148
{
@@ -166,6 +168,8 @@ exports[`Kusama Coretime Accounts > currency tests > liquidity restriction error
166168
]
167169
`;
168170

171+
exports[`Kusama Coretime Accounts > currency tests > liquidity restriction error: funds locked via manual reserve and manual lock, triggered via proxy addition > deposit action success events 1`] = `[]`;
172+
169173
exports[`Kusama Coretime Accounts > currency tests > liquidity restriction error: funds locked via manual reserve and manual lock, triggered via proxy addition > liquidity restricted action events 1`] = `
170174
[
171175
{
Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
import { assetHubKusama, kusama } from '@e2e-test/networks/chains'
2-
import { accountsE2ETests, registerTestTree } from '@e2e-test/shared'
2+
import {
3+
accountsE2ETests,
4+
createAccountsConfig,
5+
createDefaultDepositActions,
6+
createDefaultLockActions,
7+
createDefaultReserveActions,
8+
registerTestTree,
9+
type TestConfig,
10+
} from '@e2e-test/shared'
311

4-
registerTestTree(
5-
accountsE2ETests(
6-
assetHubKusama,
7-
{
8-
testSuiteName: 'Kusama Asset Hub Accounts',
9-
addressEncoding: 2,
10-
blockProvider: 'NonLocal',
11-
asyncBacking: 'Enabled',
12-
chainEd: 'LowEd',
13-
},
14-
kusama,
15-
),
16-
)
12+
const testCfg: TestConfig = {
13+
testSuiteName: 'Kusama Asset Hub Accounts',
14+
addressEncoding: 2,
15+
blockProvider: 'NonLocal',
16+
asyncBacking: 'Enabled',
17+
chainEd: 'LowEd',
18+
}
19+
20+
// When testing liquidity restrictions on Asset Hubs, to simulate frozen funds, vesting is skipped due to AHM.
21+
const lockActions = createDefaultLockActions().filter((action) => !action.name.includes('vest'))
22+
23+
const accountsCfg = createAccountsConfig({
24+
relayChain: kusama,
25+
actions: {
26+
reserveActions: createDefaultReserveActions(),
27+
lockActions,
28+
depositActions: createDefaultDepositActions(),
29+
},
30+
})
31+
32+
registerTestTree(accountsE2ETests(assetHubKusama, testCfg, accountsCfg))
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { bridgeHubKusama, kusama } from '@e2e-test/networks/chains'
2-
import { accountsE2ETests, registerTestTree } from '@e2e-test/shared'
2+
import { accountsE2ETests, createAccountsConfig, registerTestTree, type TestConfig } from '@e2e-test/shared'
33

4-
registerTestTree(
5-
accountsE2ETests(
6-
bridgeHubKusama,
7-
{
8-
testSuiteName: 'Kusama Bridge Hub Accounts',
9-
addressEncoding: 2,
10-
blockProvider: 'Local',
11-
chainEd: 'LowEd',
12-
},
13-
kusama,
14-
),
15-
)
4+
const testCfg: TestConfig = {
5+
testSuiteName: 'Kusama Bridge Hub Accounts',
6+
addressEncoding: 2,
7+
blockProvider: 'Local',
8+
chainEd: 'LowEd',
9+
}
10+
11+
const accountsCfg = createAccountsConfig({
12+
relayChain: kusama,
13+
})
14+
15+
registerTestTree(accountsE2ETests(bridgeHubKusama, testCfg, accountsCfg))
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { coretimeKusama, kusama } from '@e2e-test/networks/chains'
2-
import { accountsE2ETests, registerTestTree } from '@e2e-test/shared'
2+
import { accountsE2ETests, createAccountsConfig, registerTestTree, type TestConfig } from '@e2e-test/shared'
33

4-
registerTestTree(
5-
accountsE2ETests(
6-
coretimeKusama,
7-
{
8-
testSuiteName: 'Kusama Coretime Accounts',
9-
addressEncoding: 2,
10-
blockProvider: 'Local',
11-
chainEd: 'LowEd',
12-
},
13-
kusama,
14-
),
15-
)
4+
const testCfg: TestConfig = {
5+
testSuiteName: 'Kusama Coretime Accounts',
6+
addressEncoding: 2,
7+
blockProvider: 'Local',
8+
chainEd: 'LowEd',
9+
}
10+
11+
const accountsCfg = createAccountsConfig({
12+
relayChain: kusama,
13+
})
14+
15+
registerTestTree(accountsE2ETests(coretimeKusama, testCfg, accountsCfg))
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { kusama, peopleKusama } from '@e2e-test/networks/chains'
2-
import { accountsE2ETests, registerTestTree } from '@e2e-test/shared'
2+
import { accountsE2ETests, createAccountsConfig, registerTestTree, type TestConfig } from '@e2e-test/shared'
33

4-
registerTestTree(
5-
accountsE2ETests(
6-
peopleKusama,
7-
{
8-
testSuiteName: 'Kusama People Chain Accounts',
9-
addressEncoding: 2,
10-
blockProvider: 'Local',
11-
chainEd: 'LowEd',
12-
},
13-
kusama,
14-
),
15-
)
4+
const testCfg: TestConfig = {
5+
testSuiteName: 'Kusama People Chain Accounts',
6+
addressEncoding: 2,
7+
blockProvider: 'Local',
8+
chainEd: 'LowEd',
9+
}
10+
11+
const accountsCfg = createAccountsConfig({
12+
relayChain: kusama,
13+
})
14+
15+
registerTestTree(accountsE2ETests(peopleKusama, testCfg, accountsCfg))
Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
import { assetHubPolkadot, polkadot } from '@e2e-test/networks/chains'
2-
import { accountsE2ETests, registerTestTree } from '@e2e-test/shared'
2+
import {
3+
accountsE2ETests,
4+
createAccountsConfig,
5+
createDefaultDepositActions,
6+
createDefaultLockActions,
7+
createDefaultReserveActions,
8+
registerTestTree,
9+
type TestConfig,
10+
} from '@e2e-test/shared'
311

4-
registerTestTree(
5-
accountsE2ETests(
6-
assetHubPolkadot,
7-
{
8-
testSuiteName: 'Polkadot Asset Hub Accounts',
9-
addressEncoding: 0,
10-
blockProvider: 'NonLocal',
11-
asyncBacking: 'Enabled',
12-
chainEd: 'Normal',
13-
},
14-
polkadot,
15-
),
16-
)
12+
const testCfg: TestConfig = {
13+
testSuiteName: 'Polkadot Asset Hub Accounts',
14+
addressEncoding: 0,
15+
blockProvider: 'NonLocal',
16+
asyncBacking: 'Enabled',
17+
chainEd: 'Normal',
18+
}
19+
20+
// When testing liquidity restrictions on Asset Hubs, to simulate frozen funds, vesting is skipped due to AHM.
21+
const lockActions = createDefaultLockActions().filter((action) => !action.name.includes('vest'))
22+
23+
const accountsCfg = createAccountsConfig({
24+
relayChain: polkadot,
25+
actions: {
26+
reserveActions: createDefaultReserveActions(),
27+
lockActions,
28+
depositActions: createDefaultDepositActions(),
29+
},
30+
})
31+
32+
registerTestTree(accountsE2ETests(assetHubPolkadot, testCfg, accountsCfg))
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { bridgeHubPolkadot, polkadot } from '@e2e-test/networks/chains'
2-
import { accountsE2ETests, registerTestTree } from '@e2e-test/shared'
2+
import { accountsE2ETests, createAccountsConfig, registerTestTree, type TestConfig } from '@e2e-test/shared'
33

4-
registerTestTree(
5-
accountsE2ETests(
6-
bridgeHubPolkadot,
7-
{
8-
testSuiteName: 'Polkadot Bridge Hub Accounts',
9-
blockProvider: 'Local',
10-
addressEncoding: 0,
11-
chainEd: 'Normal',
12-
},
13-
polkadot,
14-
),
15-
)
4+
const testCfg: TestConfig = {
5+
testSuiteName: 'Polkadot Bridge Hub Accounts',
6+
blockProvider: 'Local',
7+
addressEncoding: 0,
8+
chainEd: 'Normal',
9+
}
10+
11+
const accountsCfg = createAccountsConfig({
12+
relayChain: polkadot,
13+
})
14+
15+
registerTestTree(accountsE2ETests(bridgeHubPolkadot, testCfg, accountsCfg))
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { coretimePolkadot, polkadot } from '@e2e-test/networks/chains'
2-
import { accountsE2ETests, registerTestTree } from '@e2e-test/shared'
2+
import { accountsE2ETests, createAccountsConfig, registerTestTree, type TestConfig } from '@e2e-test/shared'
33

4-
registerTestTree(
5-
accountsE2ETests(
6-
coretimePolkadot,
7-
{
8-
testSuiteName: 'Polkadot Coretime Accounts',
9-
addressEncoding: 0,
10-
blockProvider: 'Local',
11-
asyncBacking: 'Enabled',
12-
chainEd: 'Normal',
13-
},
14-
polkadot,
15-
),
16-
)
4+
const testCfg: TestConfig = {
5+
testSuiteName: 'Polkadot Coretime Accounts',
6+
addressEncoding: 0,
7+
blockProvider: 'Local',
8+
asyncBacking: 'Enabled',
9+
chainEd: 'Normal',
10+
}
11+
12+
const accountsCfg = createAccountsConfig({
13+
relayChain: polkadot,
14+
})
15+
16+
registerTestTree(accountsE2ETests(coretimePolkadot, testCfg, accountsCfg))
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { peoplePolkadot, polkadot } from '@e2e-test/networks/chains'
2-
import { accountsE2ETests, registerTestTree } from '@e2e-test/shared'
2+
import { accountsE2ETests, createAccountsConfig, registerTestTree, type TestConfig } from '@e2e-test/shared'
33

4-
registerTestTree(
5-
accountsE2ETests(
6-
peoplePolkadot,
7-
{
8-
testSuiteName: 'Polkadot People Chain Accounts',
9-
addressEncoding: 0,
10-
blockProvider: 'Local',
11-
chainEd: 'Normal',
12-
},
13-
polkadot,
14-
),
15-
)
4+
const testCfg: TestConfig = {
5+
testSuiteName: 'Polkadot People Chain Accounts',
6+
addressEncoding: 0,
7+
blockProvider: 'Local',
8+
chainEd: 'Normal',
9+
}
10+
11+
const accountsCfg = createAccountsConfig({
12+
relayChain: polkadot,
13+
})
14+
15+
registerTestTree(accountsE2ETests(peoplePolkadot, testCfg, accountsCfg))

0 commit comments

Comments
 (0)