mirror of
https://github.com/pezkuwichain/phishing.git
synced 2026-04-29 02:08:01 +00:00
Adjust addrcheck timeouts (jest 27) (#353)
This commit is contained in:
@@ -114,6 +114,7 @@
|
||||
"polkadot-wallet.org": [
|
||||
"12nGrKnQprcq19X8zdVevfXZPNgD4AoDnsAwxs6FoEeThudY",
|
||||
"13dJM2sNwVQc8jsEazupzaqaFjTNJo492qL6RSVuT41SLLAY",
|
||||
"14wHn5YYdrfeBibctXsctFAyDCWM6A9t38JyYVsnJGExmR5P",
|
||||
"15izdazFKpSYg8ihRoS8opxWn5UA19UAQYdwRCodJ4Q9JNEd",
|
||||
"15Mudzn4no9pY24o3mhbT4Gw3v5WYxMbzXre4MhVRPMFhcLX",
|
||||
"15Y9gquGY3dWENabfYRcWo4Bt45dPvUDhJy97dM1iR6DqrDp",
|
||||
|
||||
@@ -11,5 +11,6 @@ module.exports = {
|
||||
'<rootDir>/packages/phishing/build'
|
||||
],
|
||||
testEnvironment: 'jsdom',
|
||||
testTimeout: 2 * 60 * 1000,
|
||||
transformIgnorePatterns: ['/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/)']
|
||||
};
|
||||
|
||||
+3
-3
@@ -16,10 +16,10 @@
|
||||
"build:release:ipfs": "node scripts/ipfsUpload.mjs",
|
||||
"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",
|
||||
"phishing:addrcheck": "polkadot-dev-run-test --runInBand --detectOpenHandles packages/phishing/src/addrcheck",
|
||||
"phishing:crosscheck": "polkadot-dev-run-test --runInBand --detectOpenHandles packages/phishing/src/crosscheck",
|
||||
"postinstall": "polkadot-dev-yarn-only",
|
||||
"test": "polkadot-dev-run-test --coverage --runInBand --testPathIgnorePatterns addrcheck --testPathIgnorePatterns crosscheck"
|
||||
"test": "polkadot-dev-run-test --coverage --runInBand --detectOpenHandles --testPathIgnorePatterns addrcheck --testPathIgnorePatterns crosscheck"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.14.3",
|
||||
|
||||
@@ -31,7 +31,12 @@ async function loopSome (site: string, matcher: () => Promise<string[] | null>):
|
||||
// console.error(error);
|
||||
}
|
||||
|
||||
await new Promise<boolean>((resolve) => setTimeout(() => resolve(true), Math.floor((Math.random() * 750) + 1000)));
|
||||
await new Promise<boolean>((resolve) =>
|
||||
setTimeout(
|
||||
() => resolve(true),
|
||||
Math.floor((Math.random() * 750) + 1000)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return [site, found];
|
||||
|
||||
@@ -6,10 +6,25 @@ import { fetch } from '@polkadot/x-fetch';
|
||||
// a fetch with a 2s timeout
|
||||
export async function fetchWithTimeout (url: string, timeout = 2000): Promise<Response> {
|
||||
const controller = new AbortController();
|
||||
const id = setTimeout(() => controller.abort(), timeout);
|
||||
const response = await fetch(url, { signal: controller.signal });
|
||||
let isAborted = false;
|
||||
const id = setTimeout((): void => {
|
||||
console.log(`Timeout on ${url}`);
|
||||
|
||||
clearTimeout(id);
|
||||
isAborted = true;
|
||||
controller.abort();
|
||||
}, timeout);
|
||||
|
||||
return response;
|
||||
try {
|
||||
const response = await fetch(url, { signal: controller.signal });
|
||||
|
||||
clearTimeout(id);
|
||||
|
||||
return response;
|
||||
} catch (error) {
|
||||
if (!isAborted) {
|
||||
clearTimeout(id);
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user