@@ -275,9 +275,9 @@ pub async fn get_spender_limits_axum<C: Locked + 'static>(
275
275
) -> Result < Json < SpenderResponse > , ResponseError > {
276
276
let channel = & channel_context. context ;
277
277
278
- let spender = params. get ( "addr" ) . ok_or_else ( || ResponseError :: BadRequest (
279
- "Invalid spender address" . to_string ( ) ,
280
- ) ) ?;
278
+ let spender = params
279
+ . get ( "addr" )
280
+ . ok_or_else ( || ResponseError :: BadRequest ( "Invalid spender address" . to_string ( ) ) ) ?;
281
281
let spender = Address :: from_str ( spender) ?;
282
282
283
283
let latest_spendable = fetch_spendable ( app. pool . clone ( ) , & spender, & channel. id ( ) ) . await ?;
@@ -493,13 +493,13 @@ pub async fn add_spender_leaf<C: Locked + 'static>(
493
493
///
494
494
/// Internally to make the validator worker add a spender leaf in `NewState` we'll just update `Accounting`
495
495
pub async fn add_spender_leaf_axum < C : Locked + ' static > (
496
- Path ( params) : Path < HashMap < String , String > > ,
497
496
Extension ( app) : Extension < Arc < Application < C > > > ,
498
497
Extension ( channel) : Extension < ChainOf < Channel > > ,
498
+ Path ( params) : Path < HashMap < String , String > > ,
499
499
) -> Result < Json < SpenderResponse > , ResponseError > {
500
- let spender = params. get ( "addr" ) . ok_or_else ( || ResponseError :: BadRequest (
501
- "Invalid spender address" . to_string ( ) ,
502
- ) ) ?;
500
+ let spender = params
501
+ . get ( "addr" )
502
+ . ok_or_else ( || ResponseError :: BadRequest ( "Invalid spender address" . to_string ( ) ) ) ?;
503
503
let spender = Address :: from_str ( spender) ?;
504
504
505
505
update_accounting (
@@ -1310,7 +1310,9 @@ mod test {
1310
1310
1311
1311
#[ tokio:: test]
1312
1312
async fn adds_and_retrieves_spender_leaf ( ) {
1313
- let app = setup_dummy_app ( ) . await ;
1313
+ let app_guard = setup_dummy_app ( ) . await ;
1314
+
1315
+ let app = Extension ( Arc :: new ( app_guard. app . clone ( ) ) ) ;
1314
1316
1315
1317
let channel_context = app
1316
1318
. config
@@ -1335,23 +1337,19 @@ mod test {
1335
1337
. body ( Body :: empty ( ) )
1336
1338
. expect ( "Should build Request" )
1337
1339
} ;
1338
- let add_spender_request = |channel_context : & ChainOf < Channel > | {
1339
- let param = RouteParams ( vec ! [
1340
- channel_context. context. id( ) . to_string( ) ,
1341
- CREATOR . to_string( ) ,
1342
- ] ) ;
1343
- Request :: builder ( )
1344
- . extension ( channel_context. clone ( ) )
1345
- . extension ( param)
1346
- . body ( Body :: empty ( ) )
1347
- . expect ( "Should build Request" )
1348
- } ;
1340
+
1341
+ let mut params: HashMap < String , String > = HashMap :: new ( ) ;
1342
+ params. insert ( "id" . to_string ( ) , channel_context. context . id ( ) . to_string ( ) ) ;
1343
+ params. insert ( "addr" . to_string ( ) , CREATOR . to_string ( ) ) ;
1349
1344
1350
1345
// Calling with non existent accounting
1351
- let res = add_spender_leaf ( add_spender_request ( & channel_context) , & app)
1352
- . await
1353
- . expect ( "Should add" ) ;
1354
- assert_eq ! ( StatusCode :: OK , res. status( ) ) ;
1346
+ let res = add_spender_leaf_axum (
1347
+ app. clone ( ) ,
1348
+ Extension ( channel_context. clone ( ) ) ,
1349
+ Path ( params. clone ( ) ) ,
1350
+ )
1351
+ . await ;
1352
+ assert ! ( res. is_ok( ) ) ;
1355
1353
1356
1354
let res = get_accounting_for_channel ( get_accounting_request ( & channel_context) , & app)
1357
1355
. await
@@ -1390,10 +1388,13 @@ mod test {
1390
1388
1391
1389
assert_eq ! ( balances, accounting_response. balances) ;
1392
1390
1393
- let res = add_spender_leaf ( add_spender_request ( & channel_context) , & app)
1394
- . await
1395
- . expect ( "Should add" ) ;
1396
- assert_eq ! ( StatusCode :: OK , res. status( ) ) ;
1391
+ let res = add_spender_leaf_axum (
1392
+ app. clone ( ) ,
1393
+ Extension ( channel_context. clone ( ) ) ,
1394
+ Path ( params) ,
1395
+ )
1396
+ . await ;
1397
+ assert ! ( res. is_ok( ) ) ;
1397
1398
1398
1399
let res = get_accounting_for_channel ( get_accounting_request ( & channel_context) , & app)
1399
1400
. await
0 commit comments