New address checks (#67)

This commit is contained in:
Jaco Greeff
2021-01-25 11:03:13 +01:00
committed by GitHub
parent 29ea5330cd
commit fb41046abe
2 changed files with 36 additions and 17 deletions
+5
View File
@@ -17,6 +17,11 @@
"polkadot-airdrop.org": [
"14BFcanA3zYTpbCmzKGXVEnFe9WoBCq3JdPQdnsiEgEhXSA2"
],
"polkadot-event.com": [
"124QZBBTZtPDGPS4GqK6w8y5rPUC7EydLka9Gk3qCTDemGTN",
"13DW6RWgjUPcZ9mwwEMcb8qBcakQyzpxNw8ic32QXAEfGLxW",
"15GhxqrycWiRe9PePtN5CppTk8g63dXgM5vm9a9gwRMbPjRZ"
],
"polkadot.center": [
"12nNSFLEJU2HiuSidgd3c1bzSNn82SNpobnGso5GXF43eme6",
"12sGH82aAENExuio8BpNqXGxaXgrxMS88Qm9bfSJrav9Nito",
+31 -17
View File
@@ -24,6 +24,33 @@ function delayLoop (): Promise<void> {
});
}
// shared between polkadot.center & polkadot-event.com (addresses are also the same on first run)
async function checkGetWallet (ours: Record<string, string[]>, site: string): Promise<void> {
const all = Object.values(ours).reduce((all: string[], addrs: string[]): string[] => {
all.push(...addrs);
return all;
}, []);
const found: string[] = [];
for (let i = 0; i < 25; i++) {
const result = await (await fetch(`https://${site}/get_wallet.php`)).json() as Record<string, string>;
const wallet = result.wallet.replace('\r', '');
if (!found.includes(wallet)) {
found.push(wallet);
}
await delayLoop();
}
console.log(site, JSON.stringify(found));
const missing = found.filter((a) => !all.includes(a));
assertAndLog(missing.length === 0, `Missing entries found for ${site}: ${JSON.stringify(missing)}`);
}
describe('addrcheck', (): void => {
let ours: Record<string, string[]>;
@@ -33,23 +60,10 @@ describe('addrcheck', (): void => {
});
it('has all entries from polkadot.center', async (): Promise<void> => {
const found: string[] = [];
await checkGetWallet(ours, 'polkadot.center');
});
for (let i = 0; i < 25; i++) {
const result = await (await fetch('https://polkadot.center/get_wallet.php')).json() as Record<string, string>;
const wallet = result.wallet.replace('\r', '');
if (!found.includes(wallet)) {
found.push(wallet);
}
await delayLoop();
}
console.log('polkadot.center', JSON.stringify(found));
const missing = found.filter((a) => !ours['polkadot.center'].includes(a));
assertAndLog(missing.length === 0, `Missing entries found for polkadot.center: ${JSON.stringify(missing)}`);
it('has all entries from polkadot-event.com', async (): Promise<void> => {
await checkGetWallet(ours, 'polkadot-event.com');
});
});