Nightly addrcheck (#63)

This commit is contained in:
Jaco Greeff
2021-01-24 09:55:00 +01:00
committed by GitHub
parent 3fc8908b5e
commit 38c2a9f1b7
6 changed files with 87 additions and 3 deletions
+10
View File
@@ -0,0 +1,10 @@
---
title: Missing address entries
labels: ['ci', '@all.json']
---
cc @polkadot-js/notifications
Additional entries for addresses have been detected.
Check the nightly cron output or run `yarn phishing:addrcheck` locally. The output as found from the test includes:
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: Phishing missing cross-check entries
title: Missing cross-check entries
labels: ['ci', '@all.json']
---
+18 -1
View File
@@ -14,7 +14,6 @@ jobs:
run: |
yarn install --immutable | grep -v 'YN0013'
yarn phishing:crosscheck
- name: issue
if: ${{ failure() }}
uses: JasonEtco/create-an-issue@v2
@@ -22,3 +21,21 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
with:
filename: .github/crosscheck.md
addrcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: check
env:
CI_LOG: 123
run: |
yarn install --immutable | grep -v 'YN0013'
yarn phishing:addrcheck
- name: issue
if: ${{ failure() }}
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
with:
filename: .github/addrcheck.md
+2 -1
View File
@@ -15,9 +15,10 @@
"build:release": "polkadot-ci-ghact-build --skip-beta",
"lint": "polkadot-dev-run-lint",
"clean": "polkadot-dev-clean-build",
"phishing:addrcheck": "polkadot-dev-run-test packages/phishing/src/addrcheck",
"phishing:crosscheck": "polkadot-dev-run-test packages/phishing/src/crosscheck",
"postinstall": "polkadot-dev-yarn-only",
"test": "polkadot-dev-run-test --coverage --runInBand --testPathIgnorePatterns crosscheck"
"test": "polkadot-dev-run-test --coverage --runInBand --testPathIgnorePatterns addrcheck --testPathIgnorePatterns crosscheck"
},
"devDependencies": {
"@babel/core": "^7.12.10",
+55
View File
@@ -0,0 +1,55 @@
// Copyright 2020-2021 @polkadot/phishing authors & contributors
// SPDX-License-Identifier: Apache-2.0
import fs from 'fs';
import { fetch } from '@polkadot/x-fetch';
import { retrieveAddrList } from '.';
function assertAndLog (check: boolean, error: string): void {
if (!check) {
process.env.CI_LOG && fs.appendFileSync('./.github/addrcheck.md', `
${error}
`);
throw new Error(error);
}
}
function delayLoop (): Promise<void> {
return new Promise((resolve): void => {
setTimeout(() => resolve(), 1500);
});
}
describe('addrcheck', (): void => {
let ours: Record<string, string[]>;
beforeAll(async (): Promise<void> => {
jest.setTimeout(120000);
ours = await retrieveAddrList();
});
it('has all entries from polkadot.center', async (): Promise<void> => {
const found: string[] = [];
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)}`);
});
});
+1
View File
@@ -40,6 +40,7 @@ describe('crosscheck', (): void => {
let ours: string[];
beforeAll(async (): Promise<void> => {
jest.setTimeout(120000);
ours = (await retrieveHostList()).deny;
});