Skip to content

Commit

Permalink
ci: setupPeer per chain in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-gray committed Dec 4, 2024
1 parent a80ba8a commit 69a2d17
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions sdk/__tests__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,29 +140,34 @@ export async function link(chainInfos: Ctx[]) {
const registrations: [string, string, VAA<"Ntt:TransceiverRegistration">][] =
[];

for (const targetInfo of chainInfos) {
const toRegister = chainInfos.filter(
(peerInfo) => peerInfo.context.chain !== targetInfo.context.chain
);

console.log(
"Registering peers for ",
targetInfo.context.chain,
": ",
toRegister.map((x) => x.context.chain)
);

for (const peerInfo of toRegister) {
const vaa = await setupPeer(targetInfo, peerInfo);
if (!vaa) throw new Error("No VAA found");
// Add to registrations by PEER chain so we can register hub first
registrations.push([
targetInfo.context.chain,
peerInfo.context.chain,
vaa,
]);
}
}
// register each chain in parallel
await Promise.all(
chainInfos.map((targetInfo) =>
(async () => {
const toRegister = chainInfos.filter(
(peerInfo) => peerInfo.context.chain !== targetInfo.context.chain
);

console.log(
"Registering peers for ",
targetInfo.context.chain,
": ",
toRegister.map((x) => x.context.chain)
);

for (const peerInfo of toRegister) {
const vaa = await setupPeer(targetInfo, peerInfo);
if (!vaa) throw new Error("No VAA found");
// Add to registrations by PEER chain so we can register hub first
registrations.push([
targetInfo.context.chain,
peerInfo.context.chain,
vaa,
]);
}
})()
)
);

// Push Hub to Spoke registrations
const hubToSpokeRegistrations = registrations.filter(
Expand Down

0 comments on commit 69a2d17

Please sign in to comment.