Skip to content

Commit 568d525

Browse files
committed
Hoist people relay client to suite scope
addRegistrarViaRelayAsRoot was creating its own ephemeral relay+people pair via createNetworks on every invocation, ignoring the peopleClient already provisioned by basePeopleChainE2ETests's beforeAll. Move relay creation to suite-level beforeAll, restore both via captureSnapshot(peopleClient, relayClient) in beforeEach, and tear both down in afterAll. The function now takes the suite-shared (relayClient, peopleClient) directly. Verified: peoplePolkadot.e2e (5/5 pass).
1 parent 17377f8 commit 568d525

1 file changed

Lines changed: 12 additions & 16 deletions

File tree

packages/shared/src/people.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -587,15 +587,8 @@ export async function addRegistrarViaRelayAsRoot<
587587
TCustom extends Record<string, unknown> | undefined,
588588
TInitStoragesRelay extends Record<string, Record<string, any>> | undefined,
589589
TInitStoragesPara extends Record<string, Record<string, any>> | undefined,
590-
>(relayChain: Chain<TCustom, TInitStoragesRelay>, sharedPeopleClient: Client<TCustom, TInitStoragesPara>) {
591-
const addressEncoding = sharedPeopleClient.config.properties.addressEncoding
592-
const [relayClient, peopleClient] = await createNetworks(relayChain, sharedPeopleClient.config)
593-
const teardownExtras = async () => {
594-
await relayClient.api.disconnect().catch(() => {})
595-
await relayClient.teardown().catch(() => {})
596-
await peopleClient.api.disconnect().catch(() => {})
597-
await peopleClient.teardown().catch(() => {})
598-
}
590+
>(relayClient: Client<TCustom, TInitStoragesRelay>, peopleClient: Client<TCustom, TInitStoragesPara>) {
591+
const addressEncoding = peopleClient.config.properties.addressEncoding
599592

600593
/**
601594
* Executing extrinsic with wrong origin
@@ -710,8 +703,6 @@ export async function addRegistrarViaRelayAsRoot<
710703
registrars,
711704
'Registrars after parachain chain block differ from expected',
712705
)
713-
714-
await teardownExtras()
715706
}
716707

717708
/**
@@ -734,22 +725,27 @@ export function basePeopleChainE2ETests<
734725
testConfig: { testSuiteName: string },
735726
): RootTestTree {
736727
let peopleClient!: Client<TCustom, TInitStoragesPara>
728+
let relayClient!: Client<TCustom, TInitStoragesRelay>
737729
let restoreSnapshot: () => Promise<void>
738730
return {
739731
kind: 'describe',
740732
label: testConfig.testSuiteName,
741733
beforeAll: async () => {
742-
;[peopleClient] = await createNetworks(peopleChain)
743-
restoreSnapshot = captureSnapshot(peopleClient)
734+
;[relayClient, peopleClient] = await createNetworks(relayChain, peopleChain)
735+
restoreSnapshot = captureSnapshot(peopleClient, relayClient)
744736
},
745737
beforeEach: async () => {
746738
await restoreSnapshot()
747-
const blockNumber = (await peopleClient.api.rpc.chain.getHeader()).number.toNumber()
748-
await peopleClient.dev.setHead(blockNumber)
739+
const peopleBlock = (await peopleClient.api.rpc.chain.getHeader()).number.toNumber()
740+
await peopleClient.dev.setHead(peopleBlock)
741+
const relayBlock = (await relayClient.api.rpc.chain.getHeader()).number.toNumber()
742+
await relayClient.dev.setHead(relayBlock)
749743
},
750744
afterAll: async () => {
751745
await peopleClient.api.disconnect().catch(() => {})
752746
await peopleClient.teardown().catch(() => {})
747+
await relayClient.api.disconnect().catch(() => {})
748+
await relayClient.teardown().catch(() => {})
753749
},
754750
children: [
755751
{
@@ -778,7 +774,7 @@ export function basePeopleChainE2ETests<
778774
{
779775
kind: 'test',
780776
label: 'adding a registrar as root from the relay chain works',
781-
testFn: async () => await addRegistrarViaRelayAsRoot(relayChain, peopleClient),
777+
testFn: async () => await addRegistrarViaRelayAsRoot(relayClient, peopleClient),
782778
},
783779
],
784780
}

0 commit comments

Comments
 (0)