@@ -10,7 +10,9 @@ use crate::common::{
10
10
} ;
11
11
12
12
/// Query postgres indexer management server's cost models
13
- /// Filter on deployments if it is not empty, otherwise return all cost models
13
+ /// If specific deployments is provided, then global fallback is applied to all
14
+ /// deployments regardless of its presence in the database. Otherwise, all cost
15
+ /// models are returned without merging fields with the global cost model
14
16
pub async fn cost_models (
15
17
pool : & PgPool ,
16
18
deployments : & [ String ] ,
@@ -212,9 +214,9 @@ mod test {
212
214
#[ sqlx:: test]
213
215
#[ ignore]
214
216
async fn success_cost_models ( pool : PgPool ) {
215
- _ = setup_cost_models_table ( & pool) . await ;
217
+ setup_cost_models_table ( & pool) . await ;
216
218
let expected_models = simple_cost_models ( ) ;
217
- _ = add_cost_models ( & pool, expected_models. clone ( ) ) . await ;
219
+ add_cost_models ( & pool, expected_models. clone ( ) ) . await ;
218
220
let res = cost_models (
219
221
& pool,
220
222
& [ "Qmb5Ysp5oCUXhLA8NmxmYKDAX2nCMnh7Vvb5uffb9n5vss" . to_string ( ) ] ,
@@ -255,10 +257,10 @@ mod test {
255
257
async fn global_fallback_cost_models ( pool : PgPool ) {
256
258
let deployment_id =
257
259
"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" . to_string ( ) ;
258
- _ = setup_cost_models_table ( & pool) . await ;
259
- _ = add_cost_models ( & pool, simple_cost_models ( ) ) . await ;
260
+ setup_cost_models_table ( & pool) . await ;
261
+ add_cost_models ( & pool, simple_cost_models ( ) ) . await ;
260
262
let global = global_cost_model ( ) ;
261
- _ = add_cost_models ( & pool, vec ! [ global. clone( ) ] ) . await ;
263
+ add_cost_models ( & pool, vec ! [ global. clone( ) ] ) . await ;
262
264
let res = cost_models ( & pool, & [ ] )
263
265
. await
264
266
. expect ( "Cost models query without deployments filter" ) ;
@@ -306,8 +308,8 @@ mod test {
306
308
async fn success_cost_model ( pool : PgPool ) {
307
309
let deployment_id = "0xbd499f7673ca32ef4a642207a8bebdd0fb03888cf2678b298438e3a1ae5206ea" ;
308
310
let deployment_hash = "Qmb5Ysp5oCUXhLA8NmxmYKDAX2nCMnh7Vvb5uffb9n5vss" . to_string ( ) ;
309
- _ = setup_cost_models_table ( & pool) . await ;
310
- _ = add_cost_models ( & pool, simple_cost_models ( ) ) . await ;
311
+ setup_cost_models_table ( & pool) . await ;
312
+ add_cost_models ( & pool, simple_cost_models ( ) ) . await ;
311
313
let res = cost_model ( & pool, & deployment_hash)
312
314
. await
313
315
. expect ( "Cost model query" )
@@ -320,8 +322,8 @@ mod test {
320
322
#[ ignore]
321
323
async fn global_fallback_cost_model ( pool : PgPool ) {
322
324
let deployment_hash = "Qmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ;
323
- _ = setup_cost_models_table ( & pool) . await ;
324
- _ = add_cost_models ( & pool, simple_cost_models ( ) ) . await ;
325
+ setup_cost_models_table ( & pool) . await ;
326
+ add_cost_models ( & pool, simple_cost_models ( ) ) . await ;
325
327
326
328
let res = cost_model ( & pool, deployment_hash)
327
329
. await
@@ -330,7 +332,7 @@ mod test {
330
332
assert ! ( res. is_none( ) ) ;
331
333
332
334
let global = global_cost_model ( ) ;
333
- _ = add_cost_models ( & pool, vec ! [ global. clone( ) ] ) . await ;
335
+ add_cost_models ( & pool, vec ! [ global. clone( ) ] ) . await ;
334
336
335
337
let res = cost_model ( & pool, deployment_hash)
336
338
. await
0 commit comments