1
1
import { expect , test } from "@jest/globals" ;
2
2
3
- import { DEFAULT_NETWORK , CONFIG , chainToPlatform , chains } from "@wormhole-foundation/connect- sdk" ;
3
+ import { DEFAULT_NETWORK , CONFIG , chainToPlatform , chains } from "@wormhole-foundation/sdk-connect " ;
4
4
5
- import { SuiChains , SuiPlatform } from ' ./../../src/index.js' ;
5
+ import { SuiChains , SuiPlatform } from " ./../../src/index.js" ;
6
6
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" ;
9
9
import { SuiClient } from "@mysten/sui.js/client" ;
10
10
11
11
const network = DEFAULT_NETWORK ;
12
12
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 ] ! ;
14
17
const configs = CONFIG [ network ] . chains ;
15
18
16
19
describe ( "Sui Platform Tests" , ( ) => {
17
20
describe ( "Get Token Bridge" , ( ) => {
18
21
test ( "Hardcoded Genesis mock" , async ( ) => {
19
22
const p = new SuiPlatform ( network , {
20
- [ SUI_CHAINS [ 0 ] ] : configs [ SUI_CHAINS [ 0 ] ] ,
23
+ [ suiChain ] : configs [ suiChain ] ,
21
24
} ) ;
22
25
23
- const client = new SuiClient ( { url : configs [ SUI_CHAINS [ 0 ] ] . rpc } ) ;
26
+ const client = new SuiClient ( { url : configs [ suiChain ] ! . rpc } ) ;
24
27
const tb = await p . getProtocol ( "TokenBridge" , client ) ;
25
28
expect ( tb ) . toBeTruthy ( ) ;
26
29
} ) ;
@@ -30,14 +33,14 @@ describe("Sui Platform Tests", () => {
30
33
test ( "No conf" , ( ) => {
31
34
const p = new SuiPlatform ( network , { } ) ;
32
35
expect ( p . config ) . toEqual ( { } ) ;
33
- expect ( ( ) => p . getChain ( SUI_CHAINS [ 0 ] ) ) . toThrow ( ) ;
36
+ expect ( ( ) => p . getChain ( suiChain ) ) . toThrow ( ) ;
34
37
} ) ;
35
38
36
39
test ( "With conf" , ( ) => {
37
40
const p = new SuiPlatform ( network , {
38
- [ SUI_CHAINS [ 0 ] ] : configs [ SUI_CHAINS [ 0 ] ] ,
41
+ [ suiChain ] : configs [ suiChain ] ,
39
42
} ) ;
40
- expect ( ( ) => p . getChain ( SUI_CHAINS [ 0 ] ) ) . not . toThrow ( ) ;
43
+ expect ( ( ) => p . getChain ( suiChain ) ) . not . toThrow ( ) ;
41
44
} ) ;
42
45
} ) ;
43
46
@@ -48,16 +51,16 @@ describe("Sui Platform Tests", () => {
48
51
49
52
// expect getRpc to throw an error since we havent provided
50
53
// 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 ( ) ;
53
56
} ) ;
54
57
55
58
test ( "With conf" , ( ) => {
56
59
const p = new SuiPlatform ( network , {
57
- [ SUI_CHAINS [ 0 ] ] : configs [ SUI_CHAINS [ 0 ] ] ,
60
+ [ suiChain ] : configs [ suiChain ] ,
58
61
} ) ;
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 ( ) ;
61
64
} ) ;
62
65
} ) ;
63
66
} ) ;
0 commit comments