-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest-setup.ts
57 lines (47 loc) · 1.19 KB
/
test-setup.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import Arlocal from 'arlocal';
import Blockweave from 'blockweave';
import Arweave from 'arweave';
import { JWKInterface } from "blockweave/dist/faces/lib/wallet";
export let port: number;
export let wallet: JWKInterface;
export let arWallet: JWKInterface;
export let blockweave: Blockweave;
export let arweave: Arweave;
export let arlocal: Arlocal;
let fn: any;
jest.setTimeout(30000);
beforeEach(async () => {
// start arlocal
port = Math.floor(Math.random() * (9000 - 5000 + 1) + 5000);
arlocal = new Arlocal(port, true);
await arlocal.start();
blockweave = new Blockweave({
host: 'localhost',
port,
protocol: 'http',
timeout: 20000,
logging: true,
});
arweave = new Arweave({
host: 'localhost',
port,
protocol: 'http',
timeout: 20000,
logging: true,
});
// generate wallet
wallet = await blockweave.wallets.generate();
// generate ar wallet
arWallet = await arweave.wallets.generate();
fn = jest.spyOn(console, 'error').mockImplementation(() => null);
});
afterEach(async () => {
// stop arlocal
await arlocal.stop();
port = null;
arlocal = null;
blockweave = null;
arweave = null;
wallet = null;
fn.mockRestore();
});