Skip to content

Commit c23da44

Browse files
authored
Create E2E test suite for accounts and balances (#377)
* Init balances e2e tests (wip) * Rework initial tests for clarity Most of them were written with recourse to Cursor, and were just not very useful. * Refactor `transfer_allow_death` test It scrutinizes the extrinsic's events and their inner data. * Recreate tests for all Polkadot/Kusama relay/SPs * Rework networks that run `transferAllowDeath` test Now, at the calling site of the test tree creation function, chains can signal whether their ED is too low to run the basic `transferAllowDeath` test. * Scrutinize more events in `transferAllowDeath` test * Test non-destructive `transfer_allow_death` * Test `force_transfer` with account reaping * Test to `force_transfer` reaping * Test `transfer_allow_death` below ED * Test `force_transfer` below ED * Test overtransferring account * Update comments and snapshots * Test `force_transfer` with insufficient funds * Test self `transfer_allow_death` of near-entire balance * Update snapshots * Update accounts tests after merge from `master` PR #384 required some additional fixes that auto-merge could not perform. * Update snapshots * Fund new test account on Bridge Hub * Revert change to Polkadot AH multisig suite name * Create test to liquidity restrictions bug See paritytech/polkadot-sdk#9560 and paritytech/polkadot-sdk#8108. TL;DR proxy and multisig pallets are using the old `Currency` trait and not the new fungible traits, it is possible for an operation that is permissible to an account at a given point in time and state to fail. See #401 * Test liquidity restrictions when creating proxy * Parametrize deposit-requiring action liquidity restriction test The `balances.LiquidityRestrictions` error can occur is different contexts, as multiple pallets still use the old `Currency::reserve` operation. This commit parametrizes the test to allow for different kinds of actions to be tested, not just proxy addition. * Extend liquidity restriction tests to cover more cases The test now combinatorially covers several cases: 1. Reserve action can vary between staking bond and nomination pool creation 2. Lock action is always vested transfer (for now) 3. Deposit action can vary between proxy creation, referendum submission and staking bond * Test manual reserve/lock in liquidity restriction tests This adds the possibility of manually set reserve/locks to the reserve/ lock actions used to combinatorially generate tests to liquidity restrictions. This is needed because some chains have no vesting or staking, but the behavior should still be tested. * Fix manual reserve/lock actions in liq. restriction tests Fees were not being accounted for correctly when performing checks on free/frozen balances. * Update snapshots and accounts E2E test tree call sites * Filter vesting as locking action on Asset Hubs ... while the AHM is pending - vesting operations are filtered, and thus cannot be used. * Add more comments to liquidity restriction test Especially the action interfaces. * Add more comments to liquidity restriction tests * Remove leftover debug code from self-transfer test * Fix Asset Hub test suites' use of relay chain An invalid argument was being passed to the `scheduleInlineCallWithOrigin` function: the base's chains block provider, instead of the relay chain's, which is always `Local`. * Snapshot skipped liquidity restriction tests ... instead of logging a message. Logs add some noise to CI test output. * Apply lint fixes * Update block numbers * Change lock identifier used * Remove unstable `Transfer` event from snapshots * Update snapshots * Simplify liquidity restriction tests The `Balance.locks` storage is no longer modified - Polkadot Relay is failing for an undetermined reason. * Use nonces when setting storage * Test `transfer_allow_death` with reserve * Add test to `transfer_all` with reserve * Add `force_transfer` with reserve test * Add origin check tests for gated extrinsics * Add tests to transfer functions with insufficient funds * Test `transfer_all` with `keepAlive = true` * Correct previous transfer all test snapshot * Test `transfer_all` with `keep_alive = false` * Correct snapshots of accounts tests * Test `transfer_keep_alive` with source left below ED * Split `transfer_keep_alive` tests ... into two separate tests: 1. one for chains with low ED (below a typical transfer fee) 2. one for chains with normal ED * Test `force_adjust_total_issuance` with zero delta * Test total issuance changes * Test `force_unreserve` no-op cases * Update accounts E2E test snapshots * Update liquidity restriction test snapshots for AHs * Test forceful unreservation of funds * Add more self-transfer tests * Add self-transfer test to `force_transfer` * Add tests to `force_set_balance` * Refactor `burn` tests into low/normal ED tests * Update snapshots with new `burn` tests * Test burning from account with consumer reference * Add test to burning of entire balance (or more than it) * Update snapshots to remove obsolete data * Improve documentation and `README`
1 parent c4d79f1 commit c23da44

29 files changed

+8357
-42
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,31 @@ LOG_LEVEL=info # General logging (error/warn/info/debug/trace)
8383
This repository contains E2E tests for the Polkadot/Kusama networks.
8484

8585
These include:
86+
- E2E suite for accounts and currency-related operations:
87+
- tests for transfer functions: `transfer_allow_death`, `transfer_keep_alive`, `transfer_all`
88+
- these tests include scenarios for successful transfers, transfers from accounts with insufficient funds,
89+
transfers of values below ED, account reaping, and self-transfers
90+
- tests for privileged functions: `force_transfer`, `force_unreserve`, `force_set_balance`, `force_adjust_total_issuance`
91+
- these include cover both successful operations and insufficient priviledge failures
92+
- in the case of `force_transfer`, they include cases similar to those of signed transfer operations
93+
- `force_set_balance` tests include reaping checks when a balance below the chain's ED is set
94+
- tests to `burn` check the proper modification of total issuance, as well as burns that can cause reaping
95+
- tests to liquidity restrictions arising from the mixing of `Currency` and `Fungible` traits
96+
- these tests combinatorially generate accounts with reserves and freezes from pallets that use the new `Fungible`
97+
trait, and then attempts to create a reserve with an operation using the deprecated `Currency::reserve` functions.
98+
- these tests currently expect the operation to fail, but will gradually start passing as networks' runtimes are
99+
upgraded
100+
- the actions used to trigger this bug are `proxy::add_proxy`, `multisig::as_multi`, and `referenda::submit`, althout
101+
any pallet using `Currency::reserve` is at risk
102+
- see https://github.com/paritytech/polkadot-sdk/pull/8108, and https://github.com/paritytech/polkadot-sdk/pull/9560/
103+
for the fixes
86104
- E2E suite for proxy accounts:
87105
- proxy account creation, removal
88106
- pure proxy account creation, removal
89107
- execution of proxy calls
90108
- test delay in proxy actions, as well as announcement/removal, and executing of announced action
91-
- proxy call filtering works both positively and negatively; in particular, for every proxy type in Polkadot/Kusama relay and system parachains, it is checked that:
109+
- proxy call filtering works both positively and negatively; in particular, for every proxy type in Polkadot/Kusama
110+
relay and system parachains, it is checked that:
92111
- a proxy of a given type can always execute calls which that proxy type is allowed to execute
93112
- a proxy of a given type can never execute calls that its proxy type disallowws it from running
94113
- see the section below for more
Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`Kusama Asset Hub Accounts > \`burn\` > burning funds from account works > events when Alice self-burns funds 1`] = `
4+
[
5+
{
6+
"data": {
7+
"amount": "(rounded 1700000000)",
8+
"who": "D8ew585BL5H1ALhn4kmJoxhgqcgKDZLPc6xunJNv4mmrBns",
9+
},
10+
"method": "Burned",
11+
"section": "balances",
12+
},
13+
]
14+
`;
15+
16+
exports[`Kusama Asset Hub Accounts > \`force_adjust_total_issuance\` > successful adjustments increase and decrease total issuance > events for first issuance change 1`] = `
17+
[
18+
{
19+
"data": {
20+
"new_": "(rounded 160000000000000000)",
21+
"old": "(rounded 160000000000000000)",
22+
},
23+
"method": "TotalIssuanceForced",
24+
"section": "balances",
25+
},
26+
]
27+
`;
28+
29+
exports[`Kusama Asset Hub Accounts > \`force_adjust_total_issuance\` > successful adjustments increase and decrease total issuance > events for second issuance change 1`] = `
30+
[
31+
{
32+
"data": {
33+
"new_": "(rounded 160000000000000000)",
34+
"old": "(rounded 160000000000000000)",
35+
},
36+
"method": "TotalIssuanceForced",
37+
"section": "balances",
38+
},
39+
]
40+
`;
41+
42+
exports[`Kusama Asset Hub Accounts > \`force_transfer\` > force transferring origin below ED can kill it > events of \`force_transfer\` from Alice to Bob 1`] = `
43+
[
44+
{
45+
"data": {
46+
"account": "D8ew585BL5H1ALhn4kmJoxhgqcgKDZLPc6xunJNv4mmrBns",
47+
},
48+
"method": "KilledAccount",
49+
"section": "system",
50+
},
51+
{
52+
"data": {
53+
"account": "D8ew585BL5H1ALhn4kmJoxhgqcgKDZLPc6xunJNv4mmrBns",
54+
"amount": "(rounded 1100000)",
55+
},
56+
"method": "DustLost",
57+
"section": "balances",
58+
},
59+
{
60+
"data": {
61+
"account": "EvvS4HELEC1nxVHsjYUsPvypd2kXeu78AguyiSN7kV2pTnk",
62+
},
63+
"method": "NewAccount",
64+
"section": "system",
65+
},
66+
{
67+
"data": {
68+
"account": "EvvS4HELEC1nxVHsjYUsPvypd2kXeu78AguyiSN7kV2pTnk",
69+
"freeBalance": "(rounded 3300000)",
70+
},
71+
"method": "Endowed",
72+
"section": "balances",
73+
},
74+
]
75+
`;
76+
77+
exports[`Kusama Asset Hub Accounts > \`transfer_all\` > account with reserves cannot transfer all funds > events when Alice with reserve transfers all to Bob 1`] = `
78+
[
79+
{
80+
"data": {
81+
"account": "EvvS4HELEC1nxVHsjYUsPvypd2kXeu78AguyiSN7kV2pTnk",
82+
},
83+
"method": "NewAccount",
84+
"section": "system",
85+
},
86+
{
87+
"data": {
88+
"account": "EvvS4HELEC1nxVHsjYUsPvypd2kXeu78AguyiSN7kV2pTnk",
89+
"freeBalance": "(rounded 170000000)",
90+
},
91+
"method": "Endowed",
92+
"section": "balances",
93+
},
94+
]
95+
`;
96+
97+
exports[`Kusama Asset Hub Accounts > \`transfer_all\` > transfer all with keepAlive false kills sender > events when Alice transfers all to Bob with \`keepAlive = false\` 1`] = `
98+
[
99+
{
100+
"data": {
101+
"account": "D8ew585BL5H1ALhn4kmJoxhgqcgKDZLPc6xunJNv4mmrBns",
102+
},
103+
"method": "KilledAccount",
104+
"section": "system",
105+
},
106+
{
107+
"data": {
108+
"account": "EvvS4HELEC1nxVHsjYUsPvypd2kXeu78AguyiSN7kV2pTnk",
109+
},
110+
"method": "NewAccount",
111+
"section": "system",
112+
},
113+
{
114+
"data": {
115+
"account": "EvvS4HELEC1nxVHsjYUsPvypd2kXeu78AguyiSN7kV2pTnk",
116+
"freeBalance": "(rounded 240000000)",
117+
},
118+
"method": "Endowed",
119+
"section": "balances",
120+
},
121+
]
122+
`;
123+
124+
exports[`Kusama Asset Hub Accounts > \`transfer_all\` > transfer all with keepAlive true leaves 1 ED > events when Alice transfers all to Bob with \`keepAlive = true\` 1`] = `
125+
[
126+
{
127+
"data": {
128+
"account": "EvvS4HELEC1nxVHsjYUsPvypd2kXeu78AguyiSN7kV2pTnk",
129+
},
130+
"method": "NewAccount",
131+
"section": "system",
132+
},
133+
{
134+
"data": {
135+
"account": "EvvS4HELEC1nxVHsjYUsPvypd2kXeu78AguyiSN7kV2pTnk",
136+
"freeBalance": "(rounded 230000000)",
137+
},
138+
"method": "Endowed",
139+
"section": "balances",
140+
},
141+
]
142+
`;
143+
144+
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via manual reserve and manual lock, triggered via multisig creation > liquidity restricted action events 1`] = `
145+
[
146+
{
147+
"data": {
148+
"dispatchError": {
149+
"Module": {
150+
"error": "0x01000000",
151+
"index": 10,
152+
},
153+
},
154+
"dispatchInfo": {
155+
"class": "Normal",
156+
"paysFee": "Yes",
157+
"weight": {
158+
"proofSize": "(rounded 20000)",
159+
"refTime": "(rounded 900000000)",
160+
},
161+
},
162+
},
163+
"method": "ExtrinsicFailed",
164+
"section": "system",
165+
},
166+
]
167+
`;
168+
169+
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via manual reserve and manual lock, triggered via proxy addition > liquidity restricted action events 1`] = `
170+
[
171+
{
172+
"data": {
173+
"dispatchError": {
174+
"Module": {
175+
"error": "0x01000000",
176+
"index": 10,
177+
},
178+
},
179+
"dispatchInfo": {
180+
"class": "Normal",
181+
"paysFee": "Yes",
182+
"weight": {
183+
"proofSize": "(rounded 10000)",
184+
"refTime": "(rounded 800000000)",
185+
},
186+
},
187+
},
188+
"method": "ExtrinsicFailed",
189+
"section": "system",
190+
},
191+
]
192+
`;
193+
194+
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"`;
195+
196+
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"`;
197+
198+
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via manual reserve and vested transfer, triggered via proxy addition > liquidity restriction test skipped 1`] = `"Skipping test - required pallets not available: lock=vested transfer"`;
199+
200+
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"`;
201+
202+
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"`;
203+
204+
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"`;
205+
206+
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"`;
207+
208+
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"`;
209+
210+
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via nomination pool and vested transfer, triggered via proxy addition > liquidity restriction test skipped 1`] = `"Skipping test - required pallets not available: reserve=nomination pool, lock=vested transfer"`;
211+
212+
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"`;
213+
214+
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"`;
215+
216+
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"`;
217+
218+
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"`;
219+
220+
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"`;
221+
222+
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via staking bond and vested transfer, triggered via proxy addition > liquidity restriction test skipped 1`] = `"Skipping test - required pallets not available: reserve=staking bond, lock=vested transfer"`;
223+
224+
exports[`Kusama Asset Hub Accounts > currency tests > liquidity restriction error: funds locked via staking bond and vested transfer, triggered via referendum submission > liquidity restriction test skipped 1`] = `"Skipping test - required pallets not available: reserve=staking bond, lock=vested transfer, deposit=referendum submission"`;
225+
226+
exports[`Kusama Asset Hub Accounts > transfer_allow_death > transfer of some funds does not kill sender account > events when Alice transfers 1 ED to Bob with sufficient balance 1`] = `
227+
[
228+
{
229+
"data": {
230+
"account": "EvvS4HELEC1nxVHsjYUsPvypd2kXeu78AguyiSN7kV2pTnk",
231+
},
232+
"method": "NewAccount",
233+
"section": "system",
234+
},
235+
{
236+
"data": {
237+
"account": "EvvS4HELEC1nxVHsjYUsPvypd2kXeu78AguyiSN7kV2pTnk",
238+
"freeBalance": "(rounded 3300000)",
239+
},
240+
"method": "Endowed",
241+
"section": "balances",
242+
},
243+
]
244+
`;

0 commit comments

Comments
 (0)