Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lifecycle/ci-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,31 @@ async function fundAccount(publicKey: string): Promise<void> {
}
}

async function waitForFriendbot(): Promise<void> {
console.log("[ci-setup] Waiting for Friendbot...");
for (let i = 0; i < 180; i++) {
try {
const res = await fetch(
`${FRIENDBOT_URL}?addr=GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF`,
);
if (res.status === 200 || res.status === 400) {
console.log(" Friendbot is ready.");
return;
}
} catch {
// Not ready yet
}
await new Promise((r) => setTimeout(r, 1000));
}
throw new Error("Friendbot did not become ready after 180s");
}

async function main() {
console.log("[ci-setup] Starting...");
const server = createServer(RPC_URL);

await waitForFriendbot();

const admin = Keypair.random();
const provider = Keypair.random();
const treasury = Keypair.random();
Expand Down
Loading