Skip to content

Commit ad7cfab

Browse files
authored
Merge pull request #542 from AmbireTech/sentry-accounting-last-approved-axum
Sentry accounting last approved axum
2 parents e7979da + bf81108 commit ad7cfab

File tree

2 files changed

+26
-40
lines changed

2 files changed

+26
-40
lines changed

sentry/src/routes/channel.rs

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,12 +1269,10 @@ mod test {
12691269

12701270
// Testing for no accounting yet
12711271
{
1272-
let res =
1272+
let accounting_response =
12731273
get_accounting_for_channel_axum(app.clone(), Extension(channel_context.clone()))
1274-
.await;
1275-
assert!(res.is_ok());
1276-
1277-
let accounting_response = res.unwrap();
1274+
.await
1275+
.expect("shoul get accounting");
12781276

12791277
assert_eq!(accounting_response.balances.earners.len(), 0);
12801278
assert_eq!(accounting_response.balances.spenders.len(), 0);
@@ -1297,12 +1295,10 @@ mod test {
12971295
.await
12981296
.expect("should spend");
12991297

1300-
let res =
1298+
let accounting_response =
13011299
get_accounting_for_channel_axum(app.clone(), Extension(channel_context.clone()))
1302-
.await;
1303-
assert!(res.is_ok());
1304-
1305-
let accounting_response = res.unwrap();
1300+
.await
1301+
.expect("should get accounting");
13061302

13071303
assert_eq!(balances, accounting_response.balances);
13081304
}
@@ -1333,12 +1329,10 @@ mod test {
13331329
.await
13341330
.expect("should spend");
13351331

1336-
let res =
1332+
let accounting_response =
13371333
get_accounting_for_channel_axum(app.clone(), Extension(channel_context.clone()))
1338-
.await;
1339-
assert!(res.is_ok());
1340-
1341-
let accounting_response = res.unwrap();
1334+
.await
1335+
.expect("shoul get accounting");
13421336

13431337
assert_eq!(balances, accounting_response.balances)
13441338
}
@@ -1395,14 +1389,13 @@ mod test {
13951389
Extension(channel_context.clone()),
13961390
Path((channel_context.context.id(), *CREATOR)),
13971391
)
1398-
.await;
1399-
assert!(res.is_ok());
1400-
1401-
let res =
1402-
get_accounting_for_channel_axum(app.clone(), Extension(channel_context.clone())).await;
1403-
assert!(res.is_ok());
1392+
.await
1393+
.expect("should get spender leaf");
14041394

1405-
let accounting_response = res.unwrap();
1395+
let accounting_response =
1396+
get_accounting_for_channel_axum(app.clone(), Extension(channel_context.clone()))
1397+
.await
1398+
.expect("should get accounting");
14061399

14071400
// Making sure a new entry has been created
14081401
assert_eq!(
@@ -1425,11 +1418,10 @@ mod test {
14251418
.await
14261419
.expect("should spend");
14271420

1428-
let res =
1429-
get_accounting_for_channel_axum(app.clone(), Extension(channel_context.clone())).await;
1430-
assert!(res.is_ok());
1431-
1432-
let accounting_response = res.unwrap();
1421+
let accounting_response =
1422+
get_accounting_for_channel_axum(app.clone(), Extension(channel_context.clone()))
1423+
.await
1424+
.expect("should get accounting");
14331425

14341426
assert_eq!(balances, accounting_response.balances);
14351427

@@ -1441,11 +1433,10 @@ mod test {
14411433
.await;
14421434
assert!(res.is_ok());
14431435

1444-
let res =
1445-
get_accounting_for_channel_axum(app.clone(), Extension(channel_context.clone())).await;
1446-
assert!(res.is_ok());
1447-
1448-
let accounting_response = res.unwrap();
1436+
let accounting_response =
1437+
get_accounting_for_channel_axum(app.clone(), Extension(channel_context.clone()))
1438+
.await
1439+
.expect("should get accounting");
14491440

14501441
// Balances shouldn't change
14511442
assert_eq!(

sentry/src/routes/routers.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,10 @@ pub fn channels_router_axum<C: Locked + 'static>() -> Router {
138138
let spender_routes = Router::new()
139139
.route(
140140
"/:addr",
141-
get(get_spender_limits_axum::<C>)
142-
.post(add_spender_leaf_axum::<C>)
143-
.route_layer(middleware::from_fn(authentication_required::<C, _>)),
141+
get(get_spender_limits_axum::<C>).post(add_spender_leaf_axum::<C>),
144142
)
145-
.route(
146-
"/all",
147-
get(get_all_spender_limits_axum::<C>)
148-
.route_layer(middleware::from_fn(authentication_required::<C, _>)),
149-
);
143+
.route("/all", get(get_all_spender_limits_axum::<C>))
144+
.layer(middleware::from_fn(authentication_required::<C, _>));
150145

151146
let channel_routes = Router::new()
152147
.route(

0 commit comments

Comments
 (0)