Skip to content

Commit c0e8325

Browse files
authored
Read both delegator and collator migration storage (#1695)
* Read both delegator and collator migration storage * prettier
1 parent 4d605c8 commit c0e8325

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

tests/smoke-tests/test-balances-consistency.ts

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ describeSmokeSuite(`Verify balances consistency`, { wssUrl, relayWssUrl }, (cont
8686
localAssetDeposits,
8787
namedReserves,
8888
locks,
89-
stakingMigrations,
89+
delegatorStakingMigrations,
90+
collatorStakingMigrations,
9091
] = await Promise.all([
9192
apiAt.query.proxy.proxies.entries(),
9293
apiAt.query.proxy.announcements.entries(),
@@ -109,14 +110,30 @@ describeSmokeSuite(`Verify balances consistency`, { wssUrl, relayWssUrl }, (cont
109110
specVersion >= 1700 && specVersion < 1800
110111
? apiAt.query.parachainStaking.delegatorReserveToLockMigrations.entries()
111112
: [],
113+
specVersion >= 1700 && specVersion < 1800
114+
? apiAt.query.parachainStaking.collatorReserveToLockMigrations.entries()
115+
: [],
112116
]);
113117

114-
const stakingMigrationAccounts = stakingMigrations.reduce((p, migration: any) => {
115-
if (migration[1].isTrue) {
116-
p[`0x${migration[0].toHex().slice(-40)}`] = true;
117-
}
118-
return p;
119-
}, {} as any) as { [account: string]: boolean };
118+
const delegatorStakingMigrationAccounts = delegatorStakingMigrations.reduce(
119+
(p, migration: any) => {
120+
if (migration[1].isTrue) {
121+
p[`0x${migration[0].toHex().slice(-40)}`] = true;
122+
}
123+
return p;
124+
},
125+
{} as any
126+
) as { [account: string]: boolean };
127+
128+
const collatorStakingMigrationAccounts = collatorStakingMigrations.reduce(
129+
(p, migration: any) => {
130+
if (migration[1].isTrue) {
131+
p[`0x${migration[0].toHex().slice(-40)}`] = true;
132+
}
133+
return p;
134+
},
135+
{} as any
136+
) as { [account: string]: boolean };
120137

121138
const expectedReserveByAccount: {
122139
[accountId: string]: { total: bigint; reserved: { [key: string]: bigint } };
@@ -148,7 +165,8 @@ describeSmokeSuite(`Verify balances consistency`, { wssUrl, relayWssUrl }, (cont
148165
candidateInfo
149166
.map((candidate) =>
150167
// Support the case of the migration in 1700
151-
specVersion < 1700 || !stakingMigrationAccounts[`0x${candidate[0].toHex().slice(-40)}`]
168+
specVersion < 1700 ||
169+
!collatorStakingMigrationAccounts[`0x${candidate[0].toHex().slice(-40)}`]
152170
? {
153171
accountId: `0x${candidate[0].toHex().slice(-40)}`,
154172
reserved: {
@@ -162,7 +180,8 @@ describeSmokeSuite(`Verify balances consistency`, { wssUrl, relayWssUrl }, (cont
162180
delegatorState
163181
.map((delegator) =>
164182
// Support the case of the migration in 1700
165-
specVersion < 1700 || !stakingMigrationAccounts[`0x${delegator[0].toHex().slice(-40)}`]
183+
specVersion < 1700 ||
184+
!delegatorStakingMigrationAccounts[`0x${delegator[0].toHex().slice(-40)}`]
166185
? {
167186
accountId: `0x${delegator[0].toHex().slice(-40)}`,
168187
reserved: {
@@ -313,7 +332,8 @@ describeSmokeSuite(`Verify balances consistency`, { wssUrl, relayWssUrl }, (cont
313332
candidateInfo
314333
.map((candidate) =>
315334
// Support the case of the migration in 1700
316-
specVersion >= 1800 || stakingMigrationAccounts[`0x${candidate[0].toHex().slice(-40)}`]
335+
specVersion >= 1800 ||
336+
collatorStakingMigrationAccounts[`0x${candidate[0].toHex().slice(-40)}`]
317337
? {
318338
accountId: `0x${candidate[0].toHex().slice(-40)}`,
319339
locks: {
@@ -327,7 +347,8 @@ describeSmokeSuite(`Verify balances consistency`, { wssUrl, relayWssUrl }, (cont
327347
delegatorState
328348
.map((delegator) =>
329349
// Support the case of the migration in 1700
330-
specVersion >= 1800 || stakingMigrationAccounts[`0x${delegator[0].toHex().slice(-40)}`]
350+
specVersion >= 1800 ||
351+
delegatorStakingMigrationAccounts[`0x${delegator[0].toHex().slice(-40)}`]
331352
? {
332353
accountId: `0x${delegator[0].toHex().slice(-40)}`,
333354
locks: {

0 commit comments

Comments
 (0)