-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathindex.ts
41 lines (38 loc) · 983 Bytes
/
index.ts
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
import {
ChainContext,
Signer,
signSendWait as ssw,
} from "@wormhole-foundation/sdk";
import path from "path";
const TESTFILE_MATCH_PATTERN = /.test.ts$/;
/**
* Skips test file execution if the corresponding environment variable is not set.
*
* eg:- To run `file-name.test.ts`, `FILE_NAME` environment variable should be set
*/
export const handleTestSkip = (filename: string) => {
const testName = path.basename(filename).replace(TESTFILE_MATCH_PATTERN, "");
const envVar = testName.replaceAll("-", "_").toUpperCase();
const shouldRun = process.env[envVar];
if (!shouldRun) {
test.only("Skipping all tests", () => {});
}
};
export const signSendWait = async (
chain: ChainContext<any, any, any>,
txs: AsyncGenerator<any>,
signer: Signer,
shouldLog = true,
shouldThrow = false
) => {
try {
await ssw(chain, txs, signer);
} catch (e) {
if (shouldLog) {
console.error(e);
}
if (shouldThrow) {
throw e;
}
}
};