Adjust endpoints tests (#9113)
This commit is contained in:
parent
74072b9bfd
commit
266d931665
2
.github/workflows/chain-endpoints.yml
vendored
2
.github/workflows/chain-endpoints.yml
vendored
@ -4,7 +4,7 @@ on:
|
|||||||
- cron: '50 0/12 * * *'
|
- cron: '50 0/12 * * *'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
types:
|
endpoints:
|
||||||
if: github.repository == 'polkadot-js/apps'
|
if: github.repository == 'polkadot-js/apps'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
@ -19,6 +19,10 @@ interface DnsResponse {
|
|||||||
|
|
||||||
const TIMEOUT = 60_000;
|
const TIMEOUT = 60_000;
|
||||||
|
|
||||||
|
function noopHandler () {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
describe('check endpoints', (): void => {
|
describe('check endpoints', (): void => {
|
||||||
const checks = createWsEndpoints()
|
const checks = createWsEndpoints()
|
||||||
.filter(({ isDisabled, isUnreachable, value }) =>
|
.filter(({ isDisabled, isUnreachable, value }) =>
|
||||||
@ -39,34 +43,34 @@ describe('check endpoints', (): void => {
|
|||||||
let websocket: WebSocket | null = null;
|
let websocket: WebSocket | null = null;
|
||||||
|
|
||||||
afterEach((): void => {
|
afterEach((): void => {
|
||||||
|
completed++;
|
||||||
|
|
||||||
if (websocket) {
|
if (websocket) {
|
||||||
websocket.onclose = null;
|
websocket.onclose = noopHandler;
|
||||||
websocket.onerror = null;
|
websocket.onerror = noopHandler;
|
||||||
websocket.onopen = null;
|
websocket.onopen = noopHandler;
|
||||||
websocket.onmessage = null;
|
websocket.onmessage = noopHandler;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
websocket.close();
|
websocket.close();
|
||||||
} catch {
|
} catch (e) {
|
||||||
// ignore
|
console.error((e as Error).message);
|
||||||
}
|
}
|
||||||
|
|
||||||
websocket = null;
|
websocket = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
completed++;
|
|
||||||
|
|
||||||
if (completed === checks.length) {
|
if (completed === checks.length) {
|
||||||
process.exit(errored);
|
process.exit(errored);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const { name, ws: endpoint } of checks) {
|
for (const { name, ws: endpoint } of checks) {
|
||||||
it(`${name} @ ${endpoint}`, async (): Promise<unknown> => {
|
it(`${name} @ ${endpoint}`, async (): Promise<void> => {
|
||||||
const [,, hostWithPort] = endpoint.split('/');
|
const [,, hostWithPort] = endpoint.split('/');
|
||||||
const [host] = hostWithPort.split(':');
|
const [host] = hostWithPort.split(':');
|
||||||
|
|
||||||
return fetchJson<DnsResponse>(`https://dns.google/resolve?name=${host}`)
|
await fetchJson<DnsResponse>(`https://dns.google/resolve?name=${host}`)
|
||||||
.then((json) =>
|
.then((json) =>
|
||||||
assert(json && json.Answer, 'No DNS entry')
|
assert(json && json.Answer, 'No DNS entry')
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user