-
Notifications
You must be signed in to change notification settings - Fork 170
/
Copy pathoptions.spec.ts
86 lines (74 loc) · 2.76 KB
/
options.spec.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
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
import { getNetworkPreset, resolveNetwork } from "./options";
import type { NetworkId, Network } from "./options.types";
describe("getNetworkPreset", () => {
it("returns the correct config for 'mainnet' without fallbackRpcUrls", () => {
const networkId: NetworkId = "mainnet";
const network = getNetworkPreset(networkId);
expect(network).toEqual({
networkId,
nodeUrl: "https://rpc.mainnet.near.org",
helperUrl: "https://helper.mainnet.near.org",
explorerUrl: "https://nearblocks.io",
indexerUrl: "https://api.fastnear.com/v0",
});
});
it("returns the correct config for 'mainnet' with fallbackRpcUrls", () => {
const networkId: NetworkId = "mainnet";
const fallbackRpcUrls: Array<string> = [
"https://rpc1.mainnet.near.org",
"https://rpc2.mainnet.near.org",
"https://rpc3.mainnet.near.org",
];
const network = getNetworkPreset(networkId, fallbackRpcUrls);
expect(network).toEqual({
networkId,
nodeUrl: "https://rpc1.mainnet.near.org",
helperUrl: "https://helper.mainnet.near.org",
explorerUrl: "https://nearblocks.io",
indexerUrl: "https://api.fastnear.com/v0",
});
});
it("returns the correct config for 'testnet' without fallbackRpcUrls", () => {
const networkId: NetworkId = "testnet";
const network = getNetworkPreset(networkId);
expect(network).toEqual({
networkId,
nodeUrl: "https://rpc.testnet.near.org",
helperUrl: "https://helper.testnet.near.org",
explorerUrl: "https://testnet.nearblocks.io",
indexerUrl: "https://test.api.fastnear.com/v0",
});
});
it("returns the correct config for 'testnet' with fallbackRpcUrls", () => {
const networkId: NetworkId = "testnet";
const fallbackRpcUrls: Array<string> = [
"https://rpc1.testnet.near.org",
"https://rpc2.testnet.near.org",
"https://rpc3.testnet.near.org",
];
const network = getNetworkPreset(networkId, fallbackRpcUrls);
expect(network).toEqual({
networkId,
nodeUrl: "https://rpc1.testnet.near.org",
helperUrl: "https://helper.testnet.near.org",
explorerUrl: "https://testnet.nearblocks.io",
indexerUrl: "https://test.api.fastnear.com/v0",
});
});
});
describe("resolveNetwork", () => {
it("resolves network presets", () => {
const networkId = "testnet";
expect(resolveNetwork(networkId)).toEqual(getNetworkPreset(networkId));
});
it("resolves custom network configuration", () => {
const network: Network = {
networkId: "localnet",
nodeUrl: "http://127.0.0.1:52993",
helperUrl: "http://127.0.0.1:52997",
explorerUrl: "http://127.0.0.1:53009",
indexerUrl: "http://127.0.0.1:52997",
};
expect(resolveNetwork(network)).toEqual(network);
});
});