@@ -80,56 +80,53 @@ describe('Verify Constants', function () {
80
80
} ) ;
81
81
82
82
it ( 'has all mainnet markets' , async ( ) => {
83
+ const errors : string [ ] = [ ] ;
84
+ const missingLutAddresses : { type : string ; marketIndex : number ; address : string ; description : string } [ ] = [ ] ;
85
+
83
86
const spotMarkets = mainnetDriftClient . getSpotMarketAccounts ( ) ;
84
87
spotMarkets . sort ( ( a , b ) => a . marketIndex - b . marketIndex ) ;
85
88
86
89
for ( const market of spotMarkets ) {
87
90
const correspondingConfigMarket = MainnetSpotMarkets . find (
88
91
( configMarket ) => configMarket . marketIndex === market . marketIndex
89
92
) ;
90
- assert (
91
- correspondingConfigMarket !== undefined ,
92
- `Market ${
93
- market . marketIndex
94
- } not found in MainnetSpotMarkets. market: ${ market . pubkey . toBase58 ( ) } `
95
- ) ;
96
- assert (
97
- correspondingConfigMarket . oracle . toBase58 ( ) == market . oracle . toBase58 ( ) ,
98
- `Oracle mismatch for mainnet spot market ${
99
- market . marketIndex
100
- } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ correspondingConfigMarket . oracle . toBase58 ( ) } , chain: ${ market . oracle . toBase58 ( ) } `
101
- ) ;
102
- assert (
103
- getVariant ( correspondingConfigMarket . oracleSource ) ===
104
- getVariant ( market . oracleSource ) ,
105
- `Oracle source mismatch for mainnet spot market ${
106
- market . marketIndex
107
- } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ getVariant (
108
- correspondingConfigMarket . oracleSource
109
- ) } , chain: ${ getVariant ( market . oracleSource ) } `
110
- ) ;
111
- assert (
112
- correspondingConfigMarket . mint . toBase58 ( ) === market . mint . toBase58 ( ) ,
113
- `Mint mismatch for mainnet spot market ${
114
- market . marketIndex
115
- } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ correspondingConfigMarket . mint . toBase58 ( ) } , chain: ${ market . mint . toBase58 ( ) } `
116
- ) ;
93
+
94
+ if ( correspondingConfigMarket === undefined ) {
95
+ errors . push ( `Market ${ market . marketIndex } not found in MainnetSpotMarkets. market: ${ market . pubkey . toBase58 ( ) } ` ) ;
96
+ continue ;
97
+ }
98
+
99
+ if ( correspondingConfigMarket . oracle . toBase58 ( ) !== market . oracle . toBase58 ( ) ) {
100
+ errors . push ( `Oracle mismatch for mainnet spot market ${ market . marketIndex } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ correspondingConfigMarket . oracle . toBase58 ( ) } , chain: ${ market . oracle . toBase58 ( ) } ` ) ;
101
+ }
102
+
103
+ if ( getVariant ( correspondingConfigMarket . oracleSource ) !== getVariant ( market . oracleSource ) ) {
104
+ errors . push ( `Oracle source mismatch for mainnet spot market ${ market . marketIndex } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ getVariant ( correspondingConfigMarket . oracleSource ) } , chain: ${ getVariant ( market . oracleSource ) } ` ) ;
105
+ }
106
+
107
+ if ( correspondingConfigMarket . mint . toBase58 ( ) !== market . mint . toBase58 ( ) ) {
108
+ errors . push ( `Mint mismatch for mainnet spot market ${ market . marketIndex } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ correspondingConfigMarket . mint . toBase58 ( ) } , chain: ${ market . mint . toBase58 ( ) } ` ) ;
109
+ }
117
110
118
111
const lutHasMarket = lutAccounts . includes ( market . pubkey . toBase58 ( ) ) ;
119
- assert (
120
- lutHasMarket ,
121
- `Mainnet LUT is missing spot market ${
122
- market . marketIndex
123
- } pubkey ${ market . pubkey . toBase58 ( ) } `
124
- ) ;
112
+ if ( ! lutHasMarket ) {
113
+ missingLutAddresses . push ( {
114
+ type : 'spot' ,
115
+ marketIndex : market . marketIndex ,
116
+ address : market . pubkey . toBase58 ( ) ,
117
+ description : 'market'
118
+ } ) ;
119
+ }
125
120
126
121
const lutHasMarketOracle = lutAccounts . includes ( market . oracle . toBase58 ( ) ) ;
127
- assert (
128
- lutHasMarketOracle ,
129
- `Mainnet LUT is missing spot market ${
130
- market . marketIndex
131
- } oracle ${ market . oracle . toBase58 ( ) } `
132
- ) ;
122
+ if ( ! lutHasMarketOracle ) {
123
+ missingLutAddresses . push ( {
124
+ type : 'spot' ,
125
+ marketIndex : market . marketIndex ,
126
+ address : market . oracle . toBase58 ( ) ,
127
+ description : 'oracle'
128
+ } ) ;
129
+ }
133
130
134
131
if (
135
132
isOneOfVariant ( market . oracleSource , [
@@ -140,7 +137,7 @@ describe('Verify Constants', function () {
140
137
] )
141
138
) {
142
139
if ( ! correspondingConfigMarket . pythFeedId ) {
143
- assert ( false , `spot market ${ market . marketIndex } missing feed id` ) ;
140
+ errors . push ( `spot market ${ market . marketIndex } missing feed id` ) ;
144
141
}
145
142
}
146
143
}
@@ -152,46 +149,39 @@ describe('Verify Constants', function () {
152
149
const correspondingConfigMarket = MainnetPerpMarkets . find (
153
150
( configMarket ) => configMarket . marketIndex === market . marketIndex
154
151
) ;
155
- assert (
156
- correspondingConfigMarket !== undefined ,
157
- `Market ${
158
- market . marketIndex
159
- } not found in MainnetPerpMarkets, market: ${ market . pubkey . toBase58 ( ) } `
160
- ) ;
161
- assert (
162
- correspondingConfigMarket . oracle . toBase58 ( ) ==
163
- market . amm . oracle . toBase58 ( ) ,
164
- `Oracle mismatch for mainnet perp market ${
165
- market . marketIndex
166
- } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ correspondingConfigMarket . oracle . toBase58 ( ) } , chain: ${ market . amm . oracle . toBase58 ( ) } `
167
- ) ;
168
- assert (
169
- getVariant ( correspondingConfigMarket . oracleSource ) ===
170
- getVariant ( market . amm . oracleSource ) ,
171
- `Oracle source mismatch for mainnet perp market ${
172
- market . marketIndex
173
- } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ getVariant (
174
- correspondingConfigMarket . oracleSource
175
- ) } , chain: ${ getVariant ( market . amm . oracleSource ) } `
176
- ) ;
152
+
153
+ if ( correspondingConfigMarket === undefined ) {
154
+ errors . push ( `Market ${ market . marketIndex } not found in MainnetPerpMarkets, market: ${ market . pubkey . toBase58 ( ) } ` ) ;
155
+ continue ;
156
+ }
157
+
158
+ if ( correspondingConfigMarket . oracle . toBase58 ( ) !== market . amm . oracle . toBase58 ( ) ) {
159
+ errors . push ( `Oracle mismatch for mainnet perp market ${ market . marketIndex } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ correspondingConfigMarket . oracle . toBase58 ( ) } , chain: ${ market . amm . oracle . toBase58 ( ) } ` ) ;
160
+ }
161
+
162
+ if ( getVariant ( correspondingConfigMarket . oracleSource ) !== getVariant ( market . amm . oracleSource ) ) {
163
+ errors . push ( `Oracle source mismatch for mainnet perp market ${ market . marketIndex } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ getVariant ( correspondingConfigMarket . oracleSource ) } , chain: ${ getVariant ( market . amm . oracleSource ) } ` ) ;
164
+ }
177
165
178
166
const lutHasMarket = lutAccounts . includes ( market . pubkey . toBase58 ( ) ) ;
179
- assert (
180
- lutHasMarket ,
181
- `Mainnet LUT is missing perp market ${
182
- market . marketIndex
183
- } pubkey ${ market . pubkey . toBase58 ( ) } `
184
- ) ;
167
+ if ( ! lutHasMarket ) {
168
+ missingLutAddresses . push ( {
169
+ type : 'perp' ,
170
+ marketIndex : market . marketIndex ,
171
+ address : market . pubkey . toBase58 ( ) ,
172
+ description : 'market'
173
+ } ) ;
174
+ }
185
175
186
- const lutHasMarketOracle = lutAccounts . includes (
187
- market . amm . oracle . toBase58 ( )
188
- ) ;
189
- assert (
190
- lutHasMarketOracle ,
191
- `Mainnet LUT is missing perp market ${
192
- market . marketIndex
193
- } oracle ${ market . amm . oracle . toBase58 ( ) } `
194
- ) ;
176
+ const lutHasMarketOracle = lutAccounts . includes ( market . amm . oracle . toBase58 ( ) ) ;
177
+ if ( ! lutHasMarketOracle ) {
178
+ missingLutAddresses . push ( {
179
+ type : 'perp' ,
180
+ marketIndex : market . marketIndex ,
181
+ address : market . amm . oracle . toBase58 ( ) ,
182
+ description : 'oracle'
183
+ } ) ;
184
+ }
195
185
196
186
if (
197
187
isOneOfVariant ( market . amm . oracleSource , [
@@ -202,47 +192,63 @@ describe('Verify Constants', function () {
202
192
] )
203
193
) {
204
194
if ( ! correspondingConfigMarket . pythFeedId ) {
205
- assert ( false , `perp market ${ market . marketIndex } missing feed id` ) ;
195
+ errors . push ( `perp market ${ market . marketIndex } missing feed id` ) ;
206
196
}
207
197
}
208
198
}
199
+
200
+ // Print all missing LUT addresses
201
+ if ( missingLutAddresses . length > 0 ) {
202
+ console . log ( '\n=== MISSING LUT ADDRESSES ===' ) ;
203
+ missingLutAddresses . forEach ( ( { type, marketIndex, address, description } ) => {
204
+ console . log ( `${ type . toUpperCase ( ) } Market ${ marketIndex } ${ description } : ${ address } ` ) ;
205
+ } ) ;
206
+ console . log ( `\nTotal missing LUT addresses: ${ missingLutAddresses . length } ` ) ;
207
+ }
208
+
209
+ // Print all errors
210
+ if ( errors . length > 0 ) {
211
+ console . log ( '\n=== VALIDATION ERRORS ===' ) ;
212
+ errors . forEach ( ( error , index ) => {
213
+ console . log ( `${ index + 1 } . ${ error } ` ) ;
214
+ } ) ;
215
+ console . log ( `\nTotal errors: ${ errors . length } ` ) ;
216
+ }
217
+
218
+ // Fail if there are any issues
219
+ const totalIssues = errors . length + missingLutAddresses . length ;
220
+ if ( totalIssues > 0 ) {
221
+ assert ( false , `Found ${ totalIssues } issues (${ errors . length } validation errors, ${ missingLutAddresses . length } missing LUT addresses). See details above.` ) ;
222
+ }
209
223
} ) ;
210
224
211
225
it ( 'has all devnet markets' , async ( ) => {
226
+ const errors : string [ ] = [ ] ;
227
+
212
228
const spotMarkets = devnetDriftClient . getSpotMarketAccounts ( ) ;
213
229
spotMarkets . sort ( ( a , b ) => a . marketIndex - b . marketIndex ) ;
214
230
215
231
for ( const market of spotMarkets ) {
216
232
const correspondingConfigMarket = DevnetSpotMarkets . find (
217
233
( configMarket ) => configMarket . marketIndex === market . marketIndex
218
234
) ;
219
- assert (
220
- correspondingConfigMarket !== undefined ,
221
- `Market ${
222
- market . marketIndex
223
- } not found in DevnetSpotMarkets, market: ${ market . pubkey . toBase58 ( ) } `
224
- ) ;
225
- assert (
226
- correspondingConfigMarket . oracle . toBase58 ( ) == market . oracle . toBase58 ( ) ,
227
- `Oracle mismatch for devnet spot market ${
228
- market . marketIndex
229
- } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ correspondingConfigMarket . oracle . toBase58 ( ) } , chain: ${ market . oracle . toBase58 ( ) } `
230
- ) ;
231
- assert (
232
- getVariant ( correspondingConfigMarket . oracleSource ) ===
233
- getVariant ( market . oracleSource ) ,
234
- `Oracle source mismatch for devnet spot market ${
235
- market . marketIndex
236
- } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ getVariant (
237
- correspondingConfigMarket . oracleSource
238
- ) } , chain: ${ getVariant ( market . oracleSource ) } `
239
- ) ;
240
- assert (
241
- correspondingConfigMarket . mint . toBase58 ( ) === market . mint . toBase58 ( ) ,
242
- `Mint mismatch for devnet spot market ${
243
- market . marketIndex
244
- } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ correspondingConfigMarket . mint . toBase58 ( ) } , chain: ${ market . mint . toBase58 ( ) } `
245
- ) ;
235
+
236
+ if ( correspondingConfigMarket === undefined ) {
237
+ errors . push ( `Market ${ market . marketIndex } not found in DevnetSpotMarkets, market: ${ market . pubkey . toBase58 ( ) } ` ) ;
238
+ continue ;
239
+ }
240
+
241
+ if ( correspondingConfigMarket . oracle . toBase58 ( ) !== market . oracle . toBase58 ( ) ) {
242
+ errors . push ( `Oracle mismatch for devnet spot market ${ market . marketIndex } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ correspondingConfigMarket . oracle . toBase58 ( ) } , chain: ${ market . oracle . toBase58 ( ) } ` ) ;
243
+ }
244
+
245
+ if ( getVariant ( correspondingConfigMarket . oracleSource ) !== getVariant ( market . oracleSource ) ) {
246
+ errors . push ( `Oracle source mismatch for devnet spot market ${ market . marketIndex } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ getVariant ( correspondingConfigMarket . oracleSource ) } , chain: ${ getVariant ( market . oracleSource ) } ` ) ;
247
+ }
248
+
249
+ if ( correspondingConfigMarket . mint . toBase58 ( ) !== market . mint . toBase58 ( ) ) {
250
+ errors . push ( `Mint mismatch for devnet spot market ${ market . marketIndex } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ correspondingConfigMarket . mint . toBase58 ( ) } , chain: ${ market . mint . toBase58 ( ) } ` ) ;
251
+ }
246
252
}
247
253
248
254
const perpMarkets = devnetDriftClient . getPerpMarketAccounts ( ) ;
@@ -252,28 +258,33 @@ describe('Verify Constants', function () {
252
258
const correspondingConfigMarket = DevnetPerpMarkets . find (
253
259
( configMarket ) => configMarket . marketIndex === market . marketIndex
254
260
) ;
255
- assert (
256
- correspondingConfigMarket !== undefined ,
257
- `Market ${
258
- market . marketIndex
259
- } not found in DevnetPerpMarkets, market: ${ market . pubkey . toBase58 ( ) } `
260
- ) ;
261
- assert (
262
- correspondingConfigMarket . oracle . toBase58 ( ) ==
263
- market . amm . oracle . toBase58 ( ) ,
264
- `Oracle mismatch for devnet perp market ${
265
- market . marketIndex
266
- } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ correspondingConfigMarket . oracle . toBase58 ( ) } , chain: ${ market . amm . oracle . toBase58 ( ) } `
267
- ) ;
268
- assert (
269
- getVariant ( correspondingConfigMarket . oracleSource ) ===
270
- getVariant ( market . amm . oracleSource ) ,
271
- `Oracle source mismatch for devnet perp market ${
272
- market . marketIndex
273
- } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ getVariant (
274
- correspondingConfigMarket . oracleSource
275
- ) } , chain: ${ getVariant ( market . amm . oracleSource ) } `
276
- ) ;
261
+
262
+ if ( correspondingConfigMarket === undefined ) {
263
+ errors . push ( `Market ${ market . marketIndex } not found in DevnetPerpMarkets, market: ${ market . pubkey . toBase58 ( ) } ` ) ;
264
+ continue ;
265
+ }
266
+
267
+ if ( correspondingConfigMarket . oracle . toBase58 ( ) !== market . amm . oracle . toBase58 ( ) ) {
268
+ errors . push ( `Oracle mismatch for devnet perp market ${ market . marketIndex } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ correspondingConfigMarket . oracle . toBase58 ( ) } , chain: ${ market . amm . oracle . toBase58 ( ) } ` ) ;
269
+ }
270
+
271
+ if ( getVariant ( correspondingConfigMarket . oracleSource ) !== getVariant ( market . amm . oracleSource ) ) {
272
+ errors . push ( `Oracle source mismatch for devnet perp market ${ market . marketIndex } , market: ${ market . pubkey . toBase58 ( ) } , constants: ${ getVariant ( correspondingConfigMarket . oracleSource ) } , chain: ${ getVariant ( market . amm . oracleSource ) } ` ) ;
273
+ }
274
+ }
275
+
276
+ // Print all errors
277
+ if ( errors . length > 0 ) {
278
+ console . log ( '\n=== DEVNET VALIDATION ERRORS ===' ) ;
279
+ errors . forEach ( ( error , index ) => {
280
+ console . log ( `${ index + 1 } . ${ error } ` ) ;
281
+ } ) ;
282
+ console . log ( `\nTotal devnet errors: ${ errors . length } ` ) ;
283
+ }
284
+
285
+ // Fail if there are any issues
286
+ if ( errors . length > 0 ) {
287
+ assert ( false , `Found ${ errors . length } devnet validation errors. See details above.` ) ;
277
288
}
278
289
} ) ;
279
290
} ) ;
0 commit comments