Skip to content

Commit a5d641b

Browse files
committed
fixed starship tests and delete srcback
1 parent d44fcd4 commit a5d641b

24 files changed

+41
-3948
lines changed

networks/solana/rpc/query-client.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ const CLIENT_OPTIONS = {
4444
timeout: 30000,
4545
headers: {
4646
'User-Agent': 'InterchainJS-SolanaQueryClient-Test/1.0.0'
47-
},
48-
retries: 1,
49-
retryDelayMs: 500,
50-
maxRetryDelayMs: 5000
47+
}
5148
};
5249

5350
async function withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T> {

networks/solana/src/__tests__/integration.test.ts

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ import { createSolanaQueryClient } from '../client-factory';
66
import { GetHealthRequest, GetVersionRequest } from '../types/requests';
77
import { SolanaProtocolVersion } from '../types/protocol';
88

9-
// Mock HttpRpcClient for integration tests
10-
jest.mock('@interchainjs/utils', () => ({
11-
HttpRpcClient: jest.fn().mockImplementation((endpoint, _options) => ({
9+
function defaultHttpRpcClientImplementation(endpoint: any, _options: any) {
10+
return {
1211
endpoint: typeof endpoint === 'string' ? endpoint : endpoint.url,
1312
connect: jest.fn(),
1413
disconnect: jest.fn(),
1514
isConnected: jest.fn().mockReturnValue(true),
16-
call: jest.fn().mockImplementation((method, _params) => {
15+
call: jest.fn().mockImplementation((method: string) => {
1716
switch (method) {
1817
case 'getHealth':
1918
return Promise.resolve('ok');
@@ -26,9 +25,24 @@ jest.mock('@interchainjs/utils', () => ({
2625
return Promise.reject(new Error(`Unknown method: ${method}`));
2726
}
2827
})
29-
}))
28+
};
29+
}
30+
31+
// Mock HttpRpcClient for integration tests
32+
jest.mock('@interchainjs/utils', () => ({
33+
HttpRpcClient: jest.fn().mockImplementation(defaultHttpRpcClientImplementation)
3034
}));
3135

36+
const resetHttpRpcClientMock = () => {
37+
const { HttpRpcClient } = require('@interchainjs/utils');
38+
HttpRpcClient.mockImplementation(defaultHttpRpcClientImplementation);
39+
};
40+
41+
afterEach(() => {
42+
jest.clearAllMocks();
43+
resetHttpRpcClientMock();
44+
});
45+
3246
describe('Solana Integration Tests', () => {
3347
const testEndpoint = 'https://api.mainnet-beta.solana.com';
3448

@@ -94,6 +108,8 @@ describe('Solana Integration Tests', () => {
94108
it('should handle errors gracefully', async () => {
95109
// Mock error response
96110
const { HttpRpcClient } = require('@interchainjs/utils');
111+
const originalImplementation = defaultHttpRpcClientImplementation;
112+
97113
HttpRpcClient.mockImplementation((endpoint: any, _options: any) => ({
98114
endpoint: typeof endpoint === 'string' ? endpoint : endpoint.url,
99115
connect: jest.fn().mockResolvedValue(undefined),
@@ -102,12 +118,16 @@ describe('Solana Integration Tests', () => {
102118
call: jest.fn().mockRejectedValue(new Error('Network error'))
103119
}));
104120

105-
const client = await createSolanaQueryClient(testEndpoint, {
106-
protocolVersion: SolanaProtocolVersion.SOLANA_1_18
107-
});
121+
try {
122+
const client = await createSolanaQueryClient(testEndpoint, {
123+
protocolVersion: SolanaProtocolVersion.SOLANA_1_18
124+
});
108125

109-
const healthRequest: GetHealthRequest = {};
110-
await expect(client.getHealth(healthRequest)).rejects.toThrow('Network error');
126+
const healthRequest: GetHealthRequest = {};
127+
await expect(client.getHealth(healthRequest)).rejects.toThrow('Network error');
128+
} finally {
129+
HttpRpcClient.mockImplementation(originalImplementation);
130+
}
111131
});
112132
});
113133

networks/solana/src/client-factory.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ export interface SolanaClientOptions {
1414
protocolVersion?: SolanaProtocolVersion;
1515
timeout?: number;
1616
headers?: Record<string, string>;
17-
retries?: number;
18-
retryDelayMs?: number;
19-
maxRetryDelayMs?: number;
2017
}
2118

2219
export interface SolanaWebSocketClientOptions extends SolanaClientOptions {
@@ -76,10 +73,7 @@ export class SolanaClientFactory {
7673
): Promise<ISolanaQueryClient> {
7774
const rpcClient = new HttpRpcClient(endpoint, {
7875
timeout: options.timeout,
79-
headers: options.headers,
80-
retries: options.retries,
81-
retryDelayMs: options.retryDelayMs,
82-
maxRetryDelayMs: options.maxRetryDelayMs
76+
headers: options.headers
8377
});
8478

8579
const adapter = await this.getProtocolAdapter(endpoint, options);
@@ -107,10 +101,7 @@ export class SolanaClientFactory {
107101

108102
const httpRpcClient = new HttpRpcClient(httpEndpoint, {
109103
timeout: options.timeout,
110-
headers: options.headers,
111-
retries: options.retries,
112-
retryDelayMs: options.retryDelayMs,
113-
maxRetryDelayMs: options.maxRetryDelayMs
104+
headers: options.headers
114105
});
115106

116107
const wsRpcClient = new WebSocketRpcClient(wsEndpoint, {

networks/solana/src/types/responses/__tests__/multiple-accounts-responses.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ describe('MultipleAccountsResponse', () => {
1414
executable: false,
1515
lamports: 88849814690250,
1616
owner: '11111111111111111111111111111111',
17-
rentEpoch: 18446744073709551615,
17+
rentEpoch: '18446744073709551615',
1818
space: 0
1919
},
2020
{
2121
data: ['', 'base58'],
2222
executable: false,
2323
lamports: 998763433,
2424
owner: '2WRuhE4GJFoE23DYzp2ij6ZnuQ8p9mJeU6gDgfsjR4or',
25-
rentEpoch: 18446744073709551615,
25+
rentEpoch: '18446744073709551615',
2626
space: 0
2727
}
2828
]
@@ -65,7 +65,7 @@ describe('MultipleAccountsResponse', () => {
6565
executable: false,
6666
lamports: 88849814690250,
6767
owner: '11111111111111111111111111111111',
68-
rentEpoch: 18446744073709551615,
68+
rentEpoch: '18446744073709551615',
6969
space: 0
7070
},
7171
null // Non-existent account

networks/solana/src/types/responses/__tests__/transaction-responses.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ describe('Transaction Response Codecs', () => {
1515
const data = 12345;
1616
const result = createTransactionCountResponse(data);
1717

18-
expect(result).toBe(12345);
18+
expect(result).toBe(12345n);
1919
});
2020

2121
it('should create transaction count response from string', () => {
2222
const data = "12345";
2323
const result = createTransactionCountResponse(data);
2424

25-
expect(result).toBe(12345);
25+
expect(result).toBe(12345n);
2626
});
2727

2828
it('should return 0 for null/undefined data', () => {
29-
expect(createTransactionCountResponse(null)).toBe(0);
30-
expect(createTransactionCountResponse(undefined)).toBe(0);
29+
expect(createTransactionCountResponse(null)).toBe(0n);
30+
expect(createTransactionCountResponse(undefined)).toBe(0n);
3131
});
3232
});
3333

networks/solana/srcbak/associated-token-account.ts.bak

Lines changed: 0 additions & 107 deletions
This file was deleted.

0 commit comments

Comments
 (0)