@@ -26,120 +26,141 @@ test('Anchor', (done) => {
26
26
. accounts ( { fundingAccount : PublicKey . unique ( ) , curMapping : PublicKey . unique ( ) , nextMapping : PublicKey . unique ( ) } )
27
27
. instruction ( )
28
28
. then ( ( instruction ) => {
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 )
31
- expect ( decoded ?. name ) . toBe ( 'addMapping' )
32
- expect ( decoded ?. data ) . toStrictEqual ( { } )
33
- } )
34
- pythOracle . methods
35
- . updProduct ( )
36
- . accounts ( { fundingAccount : PublicKey . unique ( ) , productAccount : PublicKey . unique ( ) } )
37
- . instruction ( )
38
- . then ( ( instruction ) => {
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 )
41
- expect ( decoded ?. name ) . toBe ( 'updProduct' )
42
- expect ( decoded ?. data ) . toStrictEqual ( { } )
43
- } ) ;
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 )
31
+ expect ( decoded ?. name ) . toBe ( 'addMapping' )
32
+ expect ( decoded ?. data ) . toStrictEqual ( { } )
33
+ } )
34
+ pythOracle . methods
35
+ . updProduct ( )
36
+ . accounts ( { fundingAccount : PublicKey . unique ( ) , productAccount : PublicKey . unique ( ) } )
37
+ . instruction ( )
38
+ . then ( ( instruction ) => {
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 )
41
+ expect ( decoded ?. name ) . toBe ( 'updProduct' )
42
+ expect ( decoded ?. data ) . toStrictEqual ( { } )
43
+ } )
44
44
45
- pythOracle . methods
46
- . addPrice ( 1 , 1 )
45
+ pythOracle . methods
46
+ . addPrice ( 1 , 1 )
47
47
. accounts ( { fundingAccount : PublicKey . unique ( ) , productAccount : PublicKey . unique ( ) } )
48
48
. instruction ( )
49
49
. then ( ( instruction ) => {
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 )
52
- expect ( decoded ?. name ) . toBe ( 'addPrice' )
53
- expect ( decoded ?. data ) . toStrictEqual ( { expo : 1 , pType : 1 } )
54
- } ) ;
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 )
52
+ expect ( decoded ?. name ) . toBe ( 'addPrice' )
53
+ expect ( decoded ?. data ) . toStrictEqual ( { expo : 1 , pType : 1 } )
54
+ } )
55
55
56
- pythOracle . methods
56
+ pythOracle . methods
57
57
. addPublisher ( new PublicKey ( 5 ) )
58
58
. accounts ( { fundingAccount : PublicKey . unique ( ) , priceAccount : PublicKey . unique ( ) } )
59
59
. instruction ( )
60
60
. then ( ( instruction ) => {
61
- expect ( instruction . data ) . toStrictEqual ( Buffer . from ( [ 2 , 0 , 0 , 0 , 5 , 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 , 0 , 0 , 0 , 0 , 5 ]
62
- ) )
63
- const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
64
- expect ( decoded ?. name ) . toBe ( 'addPublisher' )
65
- expect ( decoded ?. data . pub . equals ( new PublicKey ( 5 ) ) ) . toBeTruthy ( )
66
- } ) ;
61
+ expect ( instruction . data ) . toStrictEqual (
62
+ Buffer . from ( [
63
+ 2 , 0 , 0 , 0 , 5 , 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 , 0 , 0 ,
64
+ 0 , 0 , 5 ,
65
+ ] ) ,
66
+ )
67
+ const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
68
+ expect ( decoded ?. name ) . toBe ( 'addPublisher' )
69
+ expect ( decoded ?. data . pub . equals ( new PublicKey ( 5 ) ) ) . toBeTruthy ( )
70
+ } )
67
71
68
- pythOracle . methods
69
- . updPrice ( 1 , 0 , new BN ( 42 ) , new BN ( 9 ) , new BN ( 1 ) )
72
+ pythOracle . methods
73
+ . updPrice ( 1 , 0 , new BN ( 42 ) , new BN ( 9 ) , new BN ( 1 ) )
70
74
. accounts ( { fundingAccount : PublicKey . unique ( ) , priceAccount : PublicKey . unique ( ) } )
71
75
. instruction ( )
72
76
. then ( ( instruction ) => {
73
- expect ( instruction . data ) . toStrictEqual ( Buffer . from ( [ 2 , 0 , 0 , 0 , 7 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 42 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 9 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ]
74
- ) )
75
- const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
76
- expect ( decoded ?. name ) . toBe ( 'updPrice' )
77
- expect ( decoded ?. data . status === 1 ) . toBeTruthy ( )
78
- expect ( decoded ?. data . price . eq ( new BN ( 42 ) ) ) . toBeTruthy ( )
79
- expect ( decoded ?. data . conf . eq ( new BN ( 9 ) ) ) . toBeTruthy ( )
80
- expect ( decoded ?. data . pubSlot . eq ( new BN ( 1 ) ) ) . toBeTruthy ( )
81
- } ) ;
77
+ expect ( instruction . data ) . toStrictEqual (
78
+ Buffer . from ( [
79
+ 2 , 0 , 0 , 0 , 7 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 42 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 9 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 ,
80
+ 0 , 0 , 0 , 0 ,
81
+ ] ) ,
82
+ )
83
+ const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
84
+ expect ( decoded ?. name ) . toBe ( 'updPrice' )
85
+ expect ( decoded ?. data . status === 1 ) . toBeTruthy ( )
86
+ expect ( decoded ?. data . price . eq ( new BN ( 42 ) ) ) . toBeTruthy ( )
87
+ expect ( decoded ?. data . conf . eq ( new BN ( 9 ) ) ) . toBeTruthy ( )
88
+ expect ( decoded ?. data . pubSlot . eq ( new BN ( 1 ) ) ) . toBeTruthy ( )
89
+ } )
82
90
83
- pythOracle . methods
84
- . updPriceNoFailOnError ( 1 , 0 , new BN ( 42 ) , new BN ( 9 ) , new BN ( 1 ) )
91
+ pythOracle . methods
92
+ . updPriceNoFailOnError ( 1 , 0 , new BN ( 42 ) , new BN ( 9 ) , new BN ( 1 ) )
85
93
. accounts ( { fundingAccount : PublicKey . unique ( ) , priceAccount : PublicKey . unique ( ) } )
86
94
. instruction ( )
87
95
. then ( ( instruction ) => {
88
- expect ( instruction . data ) . toStrictEqual ( Buffer . from ( [ 2 , 0 , 0 , 0 , 13 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 42 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 9 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ]
89
- ) )
90
- const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
91
- expect ( decoded ?. name ) . toBe ( 'updPriceNoFailOnError' )
92
- expect ( decoded ?. data . status === 1 ) . toBeTruthy ( )
93
- expect ( decoded ?. data . price . eq ( new BN ( 42 ) ) ) . toBeTruthy ( )
94
- expect ( decoded ?. data . conf . eq ( new BN ( 9 ) ) ) . toBeTruthy ( )
95
- expect ( decoded ?. data . pubSlot . eq ( new BN ( 1 ) ) ) . toBeTruthy ( )
96
- } ) ;
96
+ expect ( instruction . data ) . toStrictEqual (
97
+ Buffer . from ( [
98
+ 2 , 0 , 0 , 0 , 13 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 42 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 9 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 ,
99
+ 0 , 0 , 0 , 0 ,
100
+ ] ) ,
101
+ )
102
+ const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
103
+ expect ( decoded ?. name ) . toBe ( 'updPriceNoFailOnError' )
104
+ expect ( decoded ?. data . status === 1 ) . toBeTruthy ( )
105
+ expect ( decoded ?. data . price . eq ( new BN ( 42 ) ) ) . toBeTruthy ( )
106
+ expect ( decoded ?. data . conf . eq ( new BN ( 9 ) ) ) . toBeTruthy ( )
107
+ expect ( decoded ?. data . pubSlot . eq ( new BN ( 1 ) ) ) . toBeTruthy ( )
108
+ } )
97
109
98
- pythOracle . methods
99
- . aggPrice ( 1 , 0 , new BN ( 42 ) , new BN ( 9 ) , new BN ( 1 ) )
110
+ pythOracle . methods
111
+ . aggPrice ( 1 , 0 , new BN ( 42 ) , new BN ( 9 ) , new BN ( 1 ) )
100
112
. accounts ( { fundingAccount : PublicKey . unique ( ) , priceAccount : PublicKey . unique ( ) } )
101
113
. instruction ( )
102
114
. then ( ( instruction ) => {
103
- expect ( instruction . data ) . toStrictEqual ( Buffer . from ( [ 2 , 0 , 0 , 0 , 8 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 42 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 9 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ]
104
- ) )
105
- const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
106
- expect ( decoded ?. name ) . toBe ( 'aggPrice' )
107
- expect ( decoded ?. data . status === 1 ) . toBeTruthy ( )
108
- expect ( decoded ?. data . price . eq ( new BN ( 42 ) ) ) . toBeTruthy ( )
109
- expect ( decoded ?. data . conf . eq ( new BN ( 9 ) ) ) . toBeTruthy ( )
110
- expect ( decoded ?. data . pubSlot . eq ( new BN ( 1 ) ) ) . toBeTruthy ( )
111
- } ) ;
115
+ expect ( instruction . data ) . toStrictEqual (
116
+ Buffer . from ( [
117
+ 2 , 0 , 0 , 0 , 8 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 42 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 9 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 ,
118
+ 0 , 0 , 0 , 0 ,
119
+ ] ) ,
120
+ )
121
+ const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
122
+ expect ( decoded ?. name ) . toBe ( 'aggPrice' )
123
+ expect ( decoded ?. data . status === 1 ) . toBeTruthy ( )
124
+ expect ( decoded ?. data . price . eq ( new BN ( 42 ) ) ) . toBeTruthy ( )
125
+ expect ( decoded ?. data . conf . eq ( new BN ( 9 ) ) ) . toBeTruthy ( )
126
+ expect ( decoded ?. data . pubSlot . eq ( new BN ( 1 ) ) ) . toBeTruthy ( )
127
+ } )
112
128
113
- pythOracle . methods
114
- . setMinPub ( 5 , [ 0 , 0 , 0 ] )
129
+ pythOracle . methods
130
+ . setMinPub ( 5 , [ 0 , 0 , 0 ] )
115
131
. accounts ( { fundingAccount : PublicKey . unique ( ) , priceAccount : PublicKey . unique ( ) } )
116
132
. instruction ( )
117
133
. then ( ( instruction ) => {
118
- expect ( instruction . data ) . toStrictEqual ( Buffer . from ( [ 2 , 0 , 0 , 0 , 12 , 0 , 0 , 0 , 5 , 0 , 0 , 0 ]
119
- ) )
120
- const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
121
- expect ( decoded ?. name ) . toBe ( 'setMinPub' )
122
- expect ( decoded ?. data . minPub === 5 ) . toBeTruthy ( )
123
- } ) ;
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 )
136
+ expect ( decoded ?. name ) . toBe ( 'setMinPub' )
137
+ expect ( decoded ?. data . minPub === 5 ) . toBeTruthy ( )
138
+ } )
124
139
125
- pythOracle . methods
140
+ pythOracle . methods
126
141
. updPermissions ( new PublicKey ( 6 ) , new PublicKey ( 7 ) , new PublicKey ( 8 ) )
127
- . accounts ( { upgradeAuthority : PublicKey . unique ( ) , programAccount : PublicKey . unique ( ) , programDataAccount : PublicKey . unique ( ) } )
142
+ . accounts ( {
143
+ upgradeAuthority : PublicKey . unique ( ) ,
144
+ programAccount : PublicKey . unique ( ) ,
145
+ programDataAccount : PublicKey . unique ( ) ,
146
+ } )
128
147
. instruction ( )
129
148
. then ( ( instruction ) => {
130
- const expectedPda = PublicKey . findProgramAddressSync ( [ Buffer . from ( "permissions" ) ] , pythOracle . programId ) [ 0 ] ;
131
- expect ( expectedPda . equals ( instruction . keys [ 3 ] . pubkey ) ) ;
132
- expect ( instruction . data ) . toStrictEqual ( Buffer . from ( [ 2 , 0 , 0 , 0 , 17 , 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 , 0 , 0 , 0 , 0 , 6 , 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 , 0 , 7 , 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 , 0 , 8 ] ) )
133
- const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
134
- expect ( decoded ?. name ) . toBe ( 'updPermissions' )
135
- expect ( decoded ?. data . masterAuthority . equals ( new PublicKey ( 6 ) ) ) . toBeTruthy ( )
136
- expect ( decoded ?. data . dataCurationAuthority . equals ( new PublicKey ( 7 ) ) ) . toBeTruthy ( )
137
- expect ( decoded ?. data . securityAuthority . equals ( new PublicKey ( 8 ) ) ) . toBeTruthy ( )
138
- } ) ;
139
-
140
-
141
-
149
+ const expectedPda = PublicKey . findProgramAddressSync ( [ Buffer . from ( 'permissions' ) ] , pythOracle . programId ) [ 0 ]
150
+ expect ( expectedPda . equals ( instruction . keys [ 3 ] . pubkey ) )
151
+ expect ( instruction . data ) . toStrictEqual (
152
+ Buffer . from ( [
153
+ 2 , 0 , 0 , 0 , 17 , 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 , 0 ,
154
+ 0 , 0 , 0 , 6 , 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 , 0 , 7 , 0 ,
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
+ ] ) ,
157
+ )
158
+ const decoded = ( pythOracle . coder as PythOracleCoder ) . instruction . decode ( instruction . data )
159
+ expect ( decoded ?. name ) . toBe ( 'updPermissions' )
160
+ expect ( decoded ?. data . masterAuthority . equals ( new PublicKey ( 6 ) ) ) . toBeTruthy ( )
161
+ expect ( decoded ?. data . dataCurationAuthority . equals ( new PublicKey ( 7 ) ) ) . toBeTruthy ( )
162
+ expect ( decoded ?. data . securityAuthority . equals ( new PublicKey ( 8 ) ) ) . toBeTruthy ( )
163
+ } )
142
164
143
-
144
165
done ( )
145
166
} )
0 commit comments