Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 24x 24x 24x 1x 1x 1x 1x 63x 63x 1x 1x 1x 1x 1x 1x 1x 1x 108x 108x 108x 108x 108x 108x 112x 112x 106x 112x 6x 6x 1x 1x 1x 6x 5x 5x 5x 1x 1x 5x 4x 4x 4x 5x 6x 112x 108x 108x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import fs from "fs" import path from "path"; import zlib from "zlib"; export const FAUCET_PRIVATEKEY = process.env.FAUCET_PRIVATEKEY || "MISSING_GITHUB_SECRET"; export const INFURA_APIKEY = process.env.INFURA_APIKEY || ""; // Find the package root (based on the nyc output/ folder) const root = (function() { let root = process.cwd(); while (true) { if (fs.existsSync(path.join(root, "output"))) { return root; } const parent = path.join(root, ".."); if (parent === root) { break; } root = parent; } throw new Error("could not find root"); })(); // Load the tests export function loadTests<T>(tag: string): Array<T> { const filename = path.resolve(root, "testcases", tag + ".json.gz"); return JSON.parse(zlib.gunzipSync(fs.readFileSync(filename)).toString()); } export function log(context: any, text: string): void { if (context && context.test && typeof(context.test._ethersLog) === "function") { context.test._ethersLog(text); } else { console.log(text); } } export async function stall(duration: number): Promise<void> { return new Promise((resolve) => { setTimeout(resolve, duration); }); } export interface MochaRunnable { timeout: (value: number) => void; skip: () => void; } const ATTEMPTS = 5; export async function retryIt(name: string, func: (this: MochaRunnable) => Promise<void>): Promise<void> { //const errors: Array<Error> = [ ]; it(name, async function() { this.timeout(ATTEMPTS * 5000); for (let i = 0; i < ATTEMPTS; i++) { try { await func.call(this); return; } catch (error: any) { if (error.message === "sync skip; aborting execution") { // Skipping a test; let mocha handle it throw error; } else if (error.code === "ERR_ASSERTION") { // Assertion error; let mocha scold us throw error; } else { //errors.push(error); if (i === ATTEMPTS - 1) { throw error; //stats.pushRetry(i, name, error); } else { await stall(500 * (1 << i)); //stats.pushRetry(i, name, null); } } } } // All hope is lost. throw new Error(`Failed after ${ ATTEMPTS } attempts; ${ name }`); }); } /* export interface StatSet { name: string; retries: Array<{ message: string, error: null | Error }>; } const _guard = { }; export class Stats { // #stats: Array<StatSet>; constructor(guard: any) { if (guard !== _guard) { throw new Error("private constructor"); } // this.#stats = [ ]; } #currentStats(): StatSet { if (this.#stats.length === 0) { throw new Error("no active stats"); } return this.#stats[this.#stats.length - 1]; } pushRetry(attempt: number, line: string, error: null | Error): void { const { retries } = this.#currentStats(); if (attempt > 0) { retries.pop(); } if (retries.length < 100) { retries.push({ message: `${ attempt + 1 } failures: ${ line }`, error }); } } start(name: string): void { this.#stats.push({ name, retries: [ ] }); } end(context?: any): void { let log = console.log.bind(console); if (context && typeof(context._ethersLog) === "function") { log = context._ethersLog; } const { name, retries } = this.#currentStats(); if (retries.length === 0) { return; } log(`Warning: The following tests required retries (${ name })`); retries.forEach(({ error, message }) => { log(" " + message); if (error) { log(error); } }); } } export const stats = new Stats(_guard); */ |