This repository was archived by the owner on Feb 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathconnections.spec.ts
72 lines (55 loc) · 1.7 KB
/
connections.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
import fs from "fs";
import test from "ava";
import sinon from "sinon";
import { testutils } from "../../../lib";
import { Link } from "../../../lib/link";
import { Logger } from "../../create-logger";
import { signingClient } from "../../utils/signing-client";
import { gaiaChain, wasmdChain } from "./chains";
import { Options, run } from "./connections";
const { TestLogger } = testutils;
const fsReadFileSync = sinon.stub(fs, "readFileSync");
const consoleLog = sinon.stub(console, "log");
const mnemonic =
"enlist hip relief stomach skate base shallow young switch frequent cry park";
const registryYaml = `
version: 1
chains:
local_wasm:
chain_id: testing
prefix: wasm
gas_price: 0.025ucosm
rpc:
- http://localhost:26659
local_gaia:
chain_id: gaia-testing
prefix: cosmos
gas_price: 0.025uatom
rpc:
- http://localhost:26655`;
test.beforeEach(() => {
sinon.reset();
});
test.serial("lists connections", async (t) => {
const logger = new TestLogger();
const ibcClientGaia = await signingClient(gaiaChain, mnemonic);
const ibcClientWasm = await signingClient(wasmdChain, mnemonic);
const link = await Link.createWithNewConnections(
ibcClientGaia,
ibcClientWasm,
);
const options: Options = {
home: "/home/user",
mnemonic,
chain: "local_gaia",
};
fsReadFileSync.returns(registryYaml);
await run(options, logger as unknown as Logger);
const tableRow = [link.endA.connectionID, link.endA.clientID, 0, "Open"];
const match = new RegExp(tableRow.join("\\s+"));
t.assert(consoleLog.getCall(-1).calledWithMatch(match));
});
// TODO: #130
// test.serial('logs a message when no connections are found', async (t) => {
// //
// });