Skip to content

Commit bc7a83a

Browse files
committed
Sui: fix unit tests
1 parent 932d4c7 commit bc7a83a

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

platforms/sui/__tests__/integration/tokenBridge.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { utils } from "@wormhole-foundation/sdk-definitions/testing";
44
import { SuiChains, SuiPlatform } from "./../../src/index.js";
55
import { SUI_COIN } from "../../src/constants.js";
66

7-
import "@wormhole-foundation/connect-sdk-sui-core";
8-
import "@wormhole-foundation/connect-sdk-sui-tokenbridge";
7+
import "@wormhole-foundation/sdk-sui-core";
8+
import "@wormhole-foundation/sdk-sui-tokenbridge";
99

1010
import nock from "nock";
1111
import path from "path";
+18-15
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
import { expect, test } from "@jest/globals";
22

3-
import { DEFAULT_NETWORK, CONFIG, chainToPlatform, chains } from "@wormhole-foundation/connect-sdk";
3+
import { DEFAULT_NETWORK, CONFIG, chainToPlatform, chains } from "@wormhole-foundation/sdk-connect";
44

5-
import { SuiChains, SuiPlatform } from './../../src/index.js';
5+
import { SuiChains, SuiPlatform } from "./../../src/index.js";
66

7-
import "@wormhole-foundation/connect-sdk-sui-core";
8-
import "@wormhole-foundation/connect-sdk-sui-tokenbridge";
7+
import "@wormhole-foundation/sdk-sui-core";
8+
import "@wormhole-foundation/sdk-sui-tokenbridge";
99
import { SuiClient } from "@mysten/sui.js/client";
1010

1111
const network = DEFAULT_NETWORK;
1212

13-
const SUI_CHAINS = chains.filter((c) => chainToPlatform(c) === SuiPlatform._platform) as string[];
13+
const SUI_CHAINS = chains.filter(
14+
(c) => chainToPlatform(c) === SuiPlatform._platform,
15+
) as SuiChains[];
16+
const suiChain = SUI_CHAINS[0]!;
1417
const configs = CONFIG[network].chains;
1518

1619
describe("Sui Platform Tests", () => {
1720
describe("Get Token Bridge", () => {
1821
test("Hardcoded Genesis mock", async () => {
1922
const p = new SuiPlatform(network, {
20-
[SUI_CHAINS[0]]: configs[SUI_CHAINS[0]],
23+
[suiChain]: configs[suiChain],
2124
});
2225

23-
const client = new SuiClient({ url: configs[SUI_CHAINS[0]].rpc });
26+
const client = new SuiClient({ url: configs[suiChain]!.rpc });
2427
const tb = await p.getProtocol("TokenBridge", client);
2528
expect(tb).toBeTruthy();
2629
});
@@ -30,14 +33,14 @@ describe("Sui Platform Tests", () => {
3033
test("No conf", () => {
3134
const p = new SuiPlatform(network, {});
3235
expect(p.config).toEqual({});
33-
expect(() => p.getChain(SUI_CHAINS[0])).toThrow();
36+
expect(() => p.getChain(suiChain)).toThrow();
3437
});
3538

3639
test("With conf", () => {
3740
const p = new SuiPlatform(network, {
38-
[SUI_CHAINS[0]]: configs[SUI_CHAINS[0]],
41+
[suiChain]: configs[suiChain],
3942
});
40-
expect(() => p.getChain(SUI_CHAINS[0])).not.toThrow();
43+
expect(() => p.getChain(suiChain)).not.toThrow();
4144
});
4245
});
4346

@@ -48,16 +51,16 @@ describe("Sui Platform Tests", () => {
4851

4952
// expect getRpc to throw an error since we havent provided
5053
// the conf to figure out how to connect
51-
expect(() => p.getRpc(SUI_CHAINS[0])).toThrow();
52-
expect(() => p.getChain(SUI_CHAINS[0])).toThrow();
54+
expect(() => p.getRpc(suiChain)).toThrow();
55+
expect(() => p.getChain(suiChain)).toThrow();
5356
});
5457

5558
test("With conf", () => {
5659
const p = new SuiPlatform(network, {
57-
[SUI_CHAINS[0]]: configs[SUI_CHAINS[0]],
60+
[suiChain]: configs[suiChain],
5861
});
59-
expect(() => p.getRpc(SUI_CHAINS[0])).not.toThrow();
60-
expect(() => p.getChain(SUI_CHAINS[0]).getRpc()).not.toThrow();
62+
expect(() => p.getRpc(suiChain)).not.toThrow();
63+
expect(() => p.getChain(suiChain).getRpc()).not.toThrow();
6164
});
6265
});
6366
});

0 commit comments

Comments
 (0)