Skip to content

Commit 452568b

Browse files
committed
fix: update tests to use pythnet/pythtest
1 parent 70eced3 commit 452568b

File tree

8 files changed

+27
-23
lines changed

8 files changed

+27
-23
lines changed

src/__tests__/Anchor.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import { AnchorProvider, Wallet } from '@coral-xyz/anchor'
22
import { Connection, Keypair, PublicKey } from '@solana/web3.js'
33
import { BN } from 'bn.js'
4+
import { getPythClusterApiUrl } from '../cluster'
45
import { getPythProgramKeyForCluster, pythOracleProgram, pythOracleCoder } from '../index'
56

67
test('Anchor', (done) => {
78
jest.setTimeout(60000)
89
const provider = new AnchorProvider(
9-
new Connection('https://api.mainnet-beta.solana.com'),
10+
new Connection(getPythClusterApiUrl('pythnet')),
1011
new Wallet(new Keypair()),
1112
AnchorProvider.defaultOptions(),
1213
)
13-
const pythOracle = pythOracleProgram(getPythProgramKeyForCluster('mainnet-beta'), provider)
14+
const pythOracle = pythOracleProgram(getPythProgramKeyForCluster('pythnet'), provider)
1415
pythOracle.methods
1516
.initMapping()
1617
.accounts({ fundingAccount: PublicKey.unique(), freshMappingAccount: PublicKey.unique() })

src/__tests__/Example.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { clusterApiUrl, Connection, PublicKey } from '@solana/web3.js'
2-
import { parseMappingData, parsePriceData, parseProductData } from '../index'
1+
import { Connection, PublicKey } from '@solana/web3.js'
2+
import { getPythClusterApiUrl, parseMappingData, parsePriceData, parseProductData } from '../index'
33

4-
const SOLANA_CLUSTER_URL = clusterApiUrl('devnet')
4+
const SOLANA_CLUSTER_URL = getPythClusterApiUrl('pythtest-crosschain')
55
const ORACLE_MAPPING_PUBLIC_KEY = 'BmA9Z6FjioHJPpjT39QazZyhDRUdZy2ezwx4GiDdE2u2'
66

77
test('Mapping', (done) => {

src/__tests__/Mapping.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { clusterApiUrl, Connection, PublicKey } from '@solana/web3.js'
2-
import { parseMappingData, Magic, Version } from '../index'
1+
import { Connection, PublicKey } from '@solana/web3.js'
2+
import { parseMappingData, Magic, Version, getPythClusterApiUrl } from '../index'
33

44
test('Mapping', (done) => {
55
jest.setTimeout(60000)
6-
const url = clusterApiUrl('devnet')
6+
const url = getPythClusterApiUrl('pythtest-crosschain')
77
const oraclePublicKey = 'BmA9Z6FjioHJPpjT39QazZyhDRUdZy2ezwx4GiDdE2u2'
88
const connection = new Connection(url)
99
const publicKey = new PublicKey(oraclePublicKey)

src/__tests__/Price.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { clusterApiUrl, Connection, PublicKey } from '@solana/web3.js'
1+
import { Connection, PublicKey } from '@solana/web3.js'
22
import {
3+
getPythClusterApiUrl,
34
Magic,
45
MAX_SLOT_DIFFERENCE,
56
parseMappingData,
@@ -11,7 +12,7 @@ import {
1112

1213
test('Price', (done) => {
1314
jest.setTimeout(60000)
14-
const url = clusterApiUrl('devnet')
15+
const url = getPythClusterApiUrl('pythtest-crosschain')
1516
const oraclePublicKey = 'BmA9Z6FjioHJPpjT39QazZyhDRUdZy2ezwx4GiDdE2u2'
1617
const connection = new Connection(url)
1718
const publicKey = new PublicKey(oraclePublicKey)

src/__tests__/Product.ETH.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { clusterApiUrl, Connection, PublicKey } from '@solana/web3.js'
2-
import { Magic, parseProductData, Version } from '../index'
1+
import { Connection, PublicKey } from '@solana/web3.js'
2+
import { getPythClusterApiUrl, Magic, parseProductData, Version } from '../index'
33

44
test('Product', (done) => {
55
jest.setTimeout(60000)
6-
const url = clusterApiUrl('devnet')
6+
const url = getPythClusterApiUrl('pythtest-crosschain')
77
const ethProductKey = '2ciUuGZiee5macAMeQ7bHGTJtwcYTgnt6jdmQnnKZrfu'
88
const connection = new Connection(url)
99
const publicKey = new PublicKey(ethProductKey)

src/__tests__/Product.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { clusterApiUrl, Connection, PublicKey } from '@solana/web3.js'
1+
import { Connection, PublicKey } from '@solana/web3.js'
2+
import { getPythClusterApiUrl } from '../cluster'
23
import { parseMappingData, parseProductData, Magic, Version } from '../index'
34

45
test('Product', (done) => {
56
jest.setTimeout(60000)
6-
const url = clusterApiUrl('devnet')
7+
const url = getPythClusterApiUrl('pythtest-crosschain')
78
const oraclePublicKey = 'BmA9Z6FjioHJPpjT39QazZyhDRUdZy2ezwx4GiDdE2u2'
89
const connection = new Connection(url)
910
const publicKey = new PublicKey(oraclePublicKey)

src/__tests__/PythNetworkRestClient.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { clusterApiUrl, Connection, PublicKey, SystemProgram } from '@solana/web3.js'
1+
import { Connection, PublicKey, SystemProgram } from '@solana/web3.js'
22
import { getPythProgramKeyForCluster, parseProductData, PythHttpClient } from '..'
3+
import { getPythClusterApiUrl } from '../cluster'
34

45
test('PythHttpClientCall: getData', (done) => {
5-
jest.setTimeout(20000)
6+
jest.setTimeout(60000)
67
try {
7-
const programKey = getPythProgramKeyForCluster('testnet')
8-
const currentConnection = new Connection(clusterApiUrl('testnet'))
8+
const programKey = getPythProgramKeyForCluster('pythtest-conformance')
9+
const currentConnection = new Connection(getPythClusterApiUrl('pythtest-conformance'))
910
const pyth_client = new PythHttpClient(currentConnection, programKey)
1011
pyth_client.getData().then(
1112
(result) => {
@@ -30,7 +31,7 @@ test('PythHttpClientCall: getAssetPricesFromAccounts for one account', (done) =>
3031
const solUSDKey = new PublicKey('7VJsBtJzgTftYzEeooSDYyjKXvYRWJHdwvbwfBvTg9K')
3132
try {
3233
const programKey = getPythProgramKeyForCluster('testnet')
33-
const currentConnection = new Connection(clusterApiUrl('testnet'))
34+
const currentConnection = new Connection(getPythClusterApiUrl('pythtest-conformance'))
3435
const pyth_client = new PythHttpClient(currentConnection, programKey)
3536
pyth_client
3637
.getAssetPricesFromAccounts([solUSDKey])
@@ -66,7 +67,7 @@ test('PythHttpClientCall: getAssetPricesFromAccounts for multiple accounts', (do
6667

6768
try {
6869
const programKey = getPythProgramKeyForCluster('testnet')
69-
const currentConnection = new Connection(clusterApiUrl('testnet'))
70+
const currentConnection = new Connection(getPythClusterApiUrl('pythtest-conformance'))
7071
const pyth_client = new PythHttpClient(currentConnection, programKey)
7172
pyth_client
7273
.getAssetPricesFromAccounts([solUSDKey, bonkUSDKey, usdcUSDKey])
@@ -106,7 +107,7 @@ test('PythHttpClientCall: getAssetPricesFromAccounts should throw for invalid ac
106107

107108
try {
108109
const programKey = getPythProgramKeyForCluster('testnet')
109-
const currentConnection = new Connection(clusterApiUrl('testnet'))
110+
const currentConnection = new Connection(getPythClusterApiUrl('pythtest-conformance'))
110111
const pyth_client = new PythHttpClient(currentConnection, programKey)
111112
pyth_client
112113
.getAssetPricesFromAccounts([solUSDKey, systemProgram, usdcUSDKey])

src/cluster.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function getPythClusterApiUrl(cluster: PythCluster): string {
3232
if (cluster === 'pythtest-conformance' || cluster === 'pythtest-crosschain') {
3333
return 'https://api.pythtest.pyth.network'
3434
} else if (cluster === 'pythnet') {
35-
return 'https://pythnet.rpcpool.com'
35+
return 'https://api2.pythnet.pyth.network'
3636
} else if (cluster === 'localnet') {
3737
return 'http://localhost:8899'
3838
} else {

0 commit comments

Comments
 (0)