1
1
import { AnchorProvider , Wallet } from '@coral-xyz/anchor'
2
2
import { Connection , Keypair , PublicKey } from '@solana/web3.js'
3
3
import { BN } from 'bn.js'
4
- import { getPythProgramKeyForCluster , pythOracleProgram , PythOracleCoder } from '../index'
4
+ import { getPythProgramKeyForCluster , pythOracleProgram , pythOracleCoder } from '../index'
5
5
6
6
test ( 'Anchor' , ( done ) => {
7
7
jest . setTimeout ( 60000 )
@@ -17,7 +17,7 @@ test('Anchor', (done) => {
17
17
. instruction ( )
18
18
. then ( ( instruction ) => {
19
19
expect ( instruction . data ) . toStrictEqual ( Buffer . from ( [ 2 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ) )
20
- const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
20
+ const decoded = pythOracleCoder ( ) . instruction . decode ( instruction . data )
21
21
expect ( decoded ?. name ) . toBe ( 'initMapping' )
22
22
expect ( decoded ?. data ) . toStrictEqual ( { } )
23
23
} )
@@ -27,7 +27,7 @@ test('Anchor', (done) => {
27
27
. instruction ( )
28
28
. then ( ( instruction ) => {
29
29
expect ( instruction . data ) . toStrictEqual ( Buffer . from ( [ 2 , 0 , 0 , 0 , 1 , 0 , 0 , 0 ] ) )
30
- const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
30
+ const decoded = pythOracleCoder ( ) . instruction . decode ( instruction . data )
31
31
expect ( decoded ?. name ) . toBe ( 'addMapping' )
32
32
expect ( decoded ?. data ) . toStrictEqual ( { } )
33
33
} )
@@ -37,7 +37,7 @@ test('Anchor', (done) => {
37
37
. instruction ( )
38
38
. then ( ( instruction ) => {
39
39
expect ( instruction . data ) . toStrictEqual ( Buffer . from ( [ 2 , 0 , 0 , 0 , 3 , 0 , 0 , 0 ] ) )
40
- const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
40
+ const decoded = pythOracleCoder ( ) . instruction . decode ( instruction . data )
41
41
expect ( decoded ?. name ) . toBe ( 'updProduct' )
42
42
expect ( decoded ?. data ) . toStrictEqual ( { } )
43
43
} )
@@ -48,7 +48,7 @@ test('Anchor', (done) => {
48
48
. instruction ( )
49
49
. then ( ( instruction ) => {
50
50
expect ( instruction . data ) . toStrictEqual ( Buffer . from ( [ 2 , 0 , 0 , 0 , 4 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 ] ) )
51
- const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
51
+ const decoded = pythOracleCoder ( ) . instruction . decode ( instruction . data )
52
52
expect ( decoded ?. name ) . toBe ( 'addPrice' )
53
53
expect ( decoded ?. data ) . toStrictEqual ( { expo : 1 , pType : 1 } )
54
54
} )
@@ -64,7 +64,7 @@ test('Anchor', (done) => {
64
64
0 , 0 , 5 ,
65
65
] ) ,
66
66
)
67
- const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
67
+ const decoded = pythOracleCoder ( ) . instruction . decode ( instruction . data )
68
68
expect ( decoded ?. name ) . toBe ( 'addPublisher' )
69
69
expect ( decoded ?. data . pub . equals ( new PublicKey ( 5 ) ) ) . toBeTruthy ( )
70
70
} )
@@ -80,7 +80,7 @@ test('Anchor', (done) => {
80
80
0 , 0 , 0 , 0 ,
81
81
] ) ,
82
82
)
83
- const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
83
+ const decoded = pythOracleCoder ( ) . instruction . decode ( instruction . data )
84
84
expect ( decoded ?. name ) . toBe ( 'updPrice' )
85
85
expect ( decoded ?. data . status === 1 ) . toBeTruthy ( )
86
86
expect ( decoded ?. data . price . eq ( new BN ( 42 ) ) ) . toBeTruthy ( )
@@ -99,7 +99,7 @@ test('Anchor', (done) => {
99
99
0 , 0 , 0 , 0 ,
100
100
] ) ,
101
101
)
102
- const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
102
+ const decoded = pythOracleCoder ( ) . instruction . decode ( instruction . data )
103
103
expect ( decoded ?. name ) . toBe ( 'updPriceNoFailOnError' )
104
104
expect ( decoded ?. data . status === 1 ) . toBeTruthy ( )
105
105
expect ( decoded ?. data . price . eq ( new BN ( 42 ) ) ) . toBeTruthy ( )
@@ -118,7 +118,7 @@ test('Anchor', (done) => {
118
118
0 , 0 , 0 , 0 ,
119
119
] ) ,
120
120
)
121
- const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
121
+ const decoded = pythOracleCoder ( ) . instruction . decode ( instruction . data )
122
122
expect ( decoded ?. name ) . toBe ( 'aggPrice' )
123
123
expect ( decoded ?. data . status === 1 ) . toBeTruthy ( )
124
124
expect ( decoded ?. data . price . eq ( new BN ( 42 ) ) ) . toBeTruthy ( )
@@ -132,7 +132,7 @@ test('Anchor', (done) => {
132
132
. instruction ( )
133
133
. then ( ( instruction ) => {
134
134
expect ( instruction . data ) . toStrictEqual ( Buffer . from ( [ 2 , 0 , 0 , 0 , 12 , 0 , 0 , 0 , 5 , 0 , 0 , 0 ] ) )
135
- const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
135
+ const decoded = pythOracleCoder ( ) . instruction . decode ( instruction . data )
136
136
expect ( decoded ?. name ) . toBe ( 'setMinPub' )
137
137
expect ( decoded ?. data . minPub === 5 ) . toBeTruthy ( )
138
138
} )
@@ -155,7 +155,7 @@ test('Anchor', (done) => {
155
155
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 8 ,
156
156
] ) ,
157
157
)
158
- const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
158
+ const decoded = pythOracleCoder ( ) . instruction . decode ( instruction . data )
159
159
expect ( decoded ?. name ) . toBe ( 'updPermissions' )
160
160
expect ( decoded ?. data . masterAuthority . equals ( new PublicKey ( 6 ) ) ) . toBeTruthy ( )
161
161
expect ( decoded ?. data . dataCurationAuthority . equals ( new PublicKey ( 7 ) ) ) . toBeTruthy ( )
0 commit comments