|
1 |
| -import { Network, Stellar, TatumSDK } from '../../../service' |
| 1 | +import process from 'process' |
| 2 | +import { ApiVersion, Network, Stellar, TatumSDK } from '../../../service' |
2 | 3 | import { e2eUtil } from '../../e2e.util'
|
3 | 4 |
|
4 |
| -const getStellarRpc = async () => |
| 5 | +const getStellarRpc = async (testnet?: boolean) => |
5 | 6 | await TatumSDK.init<Stellar>({
|
6 |
| - network: Network.STELLAR, |
| 7 | + network: testnet ? Network.STELLAR_TESTNET : Network.STELLAR, |
7 | 8 | verbose: e2eUtil.isVerbose,
|
| 9 | + ...(testnet && { apiKey: { v3: process.env.V3_API_KEY_TESTNET } }), |
| 10 | + ...(!testnet && { apiKey: { v4: process.env.V4_API_KEY_MAINNET } }), |
| 11 | + version: testnet ? ApiVersion.V3 : ApiVersion.V4, |
8 | 12 | })
|
9 | 13 |
|
10 | 14 | describe('Stellar', () => {
|
11 | 15 | let tatum: Stellar
|
12 | 16 |
|
13 |
| - beforeEach(async () => { |
14 |
| - tatum = await getStellarRpc() |
15 |
| - }) |
| 17 | + describe('mainnet', () => { |
| 18 | + beforeEach(async () => { |
| 19 | + tatum = await getStellarRpc(false) |
| 20 | + }) |
16 | 21 |
|
17 |
| - afterEach(async () => { |
18 |
| - await tatum.destroy() |
19 |
| - }) |
| 22 | + afterEach(async () => { |
| 23 | + await tatum.destroy() |
| 24 | + }) |
20 | 25 |
|
21 |
| - it('should get accounts', async () => { |
22 |
| - const response = await tatum.rpc.getAccounts({ |
23 |
| - asset: 'USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN', |
| 26 | + it('should get accounts', async () => { |
| 27 | + const response = await tatum.rpc.getAccounts({ |
| 28 | + asset: 'USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN', |
| 29 | + }) |
| 30 | + expect(response).toBeDefined() |
24 | 31 | })
|
25 |
| - expect(response).toBeDefined() |
26 |
| - }) |
27 | 32 |
|
28 |
| - it('should get account detail', async () => { |
29 |
| - const response = await tatum.rpc.getAccount({ |
30 |
| - accountId: 'GA2224DCGO3WHC4EALA2PR2BZEMAYZPBPTHS243ZYYWQMBWRPJSZH5A6', |
| 33 | + it('should get account detail', async () => { |
| 34 | + const response = await tatum.rpc.getAccount({ |
| 35 | + accountId: 'GA2224DCGO3WHC4EALA2PR2BZEMAYZPBPTHS243ZYYWQMBWRPJSZH5A6', |
| 36 | + }) |
| 37 | + expect(response).toBeDefined() |
31 | 38 | })
|
32 |
| - expect(response).toBeDefined() |
33 |
| - }) |
34 | 39 |
|
35 |
| - it('should get fee stats', async () => { |
36 |
| - const response = await tatum.rpc.getFeeStats() |
37 |
| - expect(response).toBeDefined() |
38 |
| - }) |
| 40 | + it('should get fee stats', async () => { |
| 41 | + const response = await tatum.rpc.getFeeStats() |
| 42 | + expect(response).toBeDefined() |
| 43 | + }) |
39 | 44 |
|
40 |
| - it('should get ledger', async () => { |
41 |
| - const response = await tatum.rpc.getLedger({ |
42 |
| - sequence: 49750265, |
| 45 | + it('should get ledger', async () => { |
| 46 | + const response = await tatum.rpc.getLedger({ |
| 47 | + sequence: 49750265, |
| 48 | + }) |
| 49 | + expect(response).toBeDefined() |
43 | 50 | })
|
44 |
| - expect(response).toBeDefined() |
45 |
| - }) |
46 | 51 |
|
47 |
| - it('should get offers', async () => { |
48 |
| - const response = await tatum.rpc.getOffers({}) |
49 |
| - expect(response).toBeDefined() |
50 |
| - }) |
| 52 | + it('should get offers', async () => { |
| 53 | + const response = await tatum.rpc.getOffers() |
| 54 | + expect(response).toBeDefined() |
| 55 | + }) |
51 | 56 |
|
52 |
| - describe('should get strict send', () => { |
53 |
| - it('destinationAccount', async () => { |
54 |
| - const response = await tatum.rpc.getStrictSendPaymentPaths({ |
55 |
| - sourceAssetType: 'native', |
56 |
| - sourceAmount: '1', |
57 |
| - destinationAccount: 'GB3LIKQ6GOJ6D4EYKVS47L2SBY66SJO4MN4CZCMUPNBUJ2L3PF62ECBA', |
| 57 | + describe('should get strict send', () => { |
| 58 | + it('destinationAccount', async () => { |
| 59 | + const response = await tatum.rpc.getStrictSendPaymentPaths({ |
| 60 | + sourceAssetType: 'native', |
| 61 | + sourceAmount: '1', |
| 62 | + destinationAccount: 'GB3LIKQ6GOJ6D4EYKVS47L2SBY66SJO4MN4CZCMUPNBUJ2L3PF62ECBA', |
| 63 | + }) |
| 64 | + expect(response).toBeDefined() |
| 65 | + }) |
| 66 | + |
| 67 | + it('destinationAssets', async () => { |
| 68 | + const response = await tatum.rpc.getStrictSendPaymentPaths({ |
| 69 | + sourceAssetType: 'native', |
| 70 | + sourceAmount: '1', |
| 71 | + sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'], |
| 72 | + destinationAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'], |
| 73 | + }) |
| 74 | + expect(response).toBeDefined() |
58 | 75 | })
|
59 |
| - expect(response).toBeDefined() |
60 | 76 | })
|
61 | 77 |
|
62 |
| - it('destinationAssets', async () => { |
63 |
| - const response = await tatum.rpc.getStrictSendPaymentPaths({ |
64 |
| - sourceAssetType: 'native', |
65 |
| - sourceAmount: '1', |
66 |
| - sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'], |
67 |
| - destinationAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'], |
| 78 | + describe('should get strict receive', () => { |
| 79 | + it('sourceAssets', async () => { |
| 80 | + const response = await tatum.rpc.getStrictReceivePaymentPaths({ |
| 81 | + destinationAssetType: 'native', |
| 82 | + destinationAmount: '1', |
| 83 | + sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'], |
| 84 | + }) |
| 85 | + expect(response).toBeDefined() |
| 86 | + }) |
| 87 | + |
| 88 | + it('sourceAccount', async () => { |
| 89 | + const response = await tatum.rpc.getStrictReceivePaymentPaths({ |
| 90 | + destinationAssetType: 'native', |
| 91 | + destinationAmount: '1', |
| 92 | + sourceAccount: 'GB3LIKQ6GOJ6D4EYKVS47L2SBY66SJO4MN4CZCMUPNBUJ2L3PF62ECBA', |
| 93 | + }) |
| 94 | + expect(response).toBeDefined() |
68 | 95 | })
|
69 |
| - expect(response).toBeDefined() |
70 | 96 | })
|
71 | 97 | })
|
72 | 98 |
|
73 |
| - describe('should get strict receive', () => { |
74 |
| - it('sourceAssets', async () => { |
75 |
| - const response = await tatum.rpc.getStrictReceivePaymentPaths({ |
76 |
| - destinationAssetType: 'native', |
77 |
| - destinationAmount: '1', |
78 |
| - sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'], |
| 99 | + describe('testnet', () => { |
| 100 | + beforeEach(async () => { |
| 101 | + tatum = await getStellarRpc(true) |
| 102 | + }) |
| 103 | + |
| 104 | + afterEach(async () => { |
| 105 | + await tatum.destroy() |
| 106 | + }) |
| 107 | + |
| 108 | + it('should get accounts', async () => { |
| 109 | + const response = await tatum.rpc.getAccounts({ |
| 110 | + asset: 'USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN', |
79 | 111 | })
|
80 | 112 | expect(response).toBeDefined()
|
81 | 113 | })
|
82 | 114 |
|
83 |
| - it('sourceAccount', async () => { |
84 |
| - const response = await tatum.rpc.getStrictReceivePaymentPaths({ |
85 |
| - destinationAssetType: 'native', |
86 |
| - destinationAmount: '1', |
87 |
| - sourceAccount: 'GB3LIKQ6GOJ6D4EYKVS47L2SBY66SJO4MN4CZCMUPNBUJ2L3PF62ECBA', |
| 115 | + it('should get account detail', async () => { |
| 116 | + const response = await tatum.rpc.getAccount({ |
| 117 | + accountId: 'GDNTXNPBK4YLQKBGPCZ5CAHUGQIXKKGSJAWQGO5XR73TQCAYSWQOCCFP', |
88 | 118 | })
|
89 | 119 | expect(response).toBeDefined()
|
90 | 120 | })
|
| 121 | + |
| 122 | + it('should get fee stats', async () => { |
| 123 | + const response = await tatum.rpc.getFeeStats() |
| 124 | + expect(response).toBeDefined() |
| 125 | + }) |
| 126 | + |
| 127 | + it('should get ledger', async () => { |
| 128 | + const response = await tatum.rpc.getLedgers() |
| 129 | + expect(response).toBeDefined() |
| 130 | + }) |
| 131 | + |
| 132 | + it('should get offers', async () => { |
| 133 | + const response = await tatum.rpc.getOffers() |
| 134 | + expect(response).toBeDefined() |
| 135 | + }) |
| 136 | + |
| 137 | + describe('should get strict send', () => { |
| 138 | + it('destinationAccount', async () => { |
| 139 | + const response = await tatum.rpc.getStrictSendPaymentPaths({ |
| 140 | + sourceAssetType: 'native', |
| 141 | + sourceAmount: '1', |
| 142 | + destinationAccount: 'GB3LIKQ6GOJ6D4EYKVS47L2SBY66SJO4MN4CZCMUPNBUJ2L3PF62ECBA', |
| 143 | + }) |
| 144 | + expect(response).toBeDefined() |
| 145 | + }) |
| 146 | + |
| 147 | + it('destinationAssets', async () => { |
| 148 | + const response = await tatum.rpc.getStrictSendPaymentPaths({ |
| 149 | + sourceAssetType: 'native', |
| 150 | + sourceAmount: '1', |
| 151 | + sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'], |
| 152 | + destinationAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'], |
| 153 | + }) |
| 154 | + expect(response).toBeDefined() |
| 155 | + }) |
| 156 | + }) |
| 157 | + |
| 158 | + describe('should get strict receive', () => { |
| 159 | + it('sourceAssets', async () => { |
| 160 | + const response = await tatum.rpc.getStrictReceivePaymentPaths({ |
| 161 | + destinationAssetType: 'native', |
| 162 | + destinationAmount: '1', |
| 163 | + sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'], |
| 164 | + }) |
| 165 | + expect(response).toBeDefined() |
| 166 | + }) |
| 167 | + |
| 168 | + it('sourceAccount', async () => { |
| 169 | + const response = await tatum.rpc.getStrictReceivePaymentPaths({ |
| 170 | + destinationAssetType: 'native', |
| 171 | + destinationAmount: '1', |
| 172 | + sourceAccount: 'GDNTXNPBK4YLQKBGPCZ5CAHUGQIXKKGSJAWQGO5XR73TQCAYSWQOCCFP', |
| 173 | + }) |
| 174 | + expect(response).toBeDefined() |
| 175 | + }) |
| 176 | + }) |
91 | 177 | })
|
92 | 178 | })
|
0 commit comments