Skip to content

Commit 0763aea

Browse files
authored
Merge pull request #177 from sr-gi/202403-clippy
Adds clippy to gh actions and fixes clippy issues
2 parents 028c647 + 1a5e9a0 commit 0763aea

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ stop-docker:
3434
docker stop sim-ln
3535

3636
check-code:
37-
cargo fmt --check --all
38-
cargo clippy --all-features
37+
cargo fmt --verbose --check --all -- --color always
38+
cargo clippy --all-features --all-targets --color always -- -D warnings
3939

4040
stable-output:
4141
@if [ -n "$$(git status --porcelain)" ]; then \

sim-lib/src/sim_node.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ mod tests {
11391139
// Add a few HTLCs to our internal state and assert that balances are as expected. We'll test
11401140
// `check_outgoing_addition` in more detail in another test, so we just assert that we can add the htlc in
11411141
// this test.
1142-
let hash_1 = PaymentHash { 0: [1; 32] };
1142+
let hash_1 = PaymentHash([1; 32]);
11431143
let htlc_1 = Htlc {
11441144
amount_msat: 1000,
11451145
cltv_expiry: 40,
@@ -1161,7 +1161,7 @@ mod tests {
11611161
));
11621162

11631163
// Add a second, distinct htlc to our in-flight state.
1164-
let hash_2 = PaymentHash { 0: [2; 32] };
1164+
let hash_2 = PaymentHash([2; 32]);
11651165
let htlc_2 = Htlc {
11661166
amount_msat: 1000,
11671167
cltv_expiry: 40,
@@ -1267,7 +1267,7 @@ mod tests {
12671267
));
12681268

12691269
// Add two large htlcs so that we will start to run into our in-flight total amount limit.
1270-
let hash_1 = PaymentHash { 0: [1; 32] };
1270+
let hash_1 = PaymentHash([1; 32]);
12711271
let htlc_1 = Htlc {
12721272
amount_msat: channel_state.policy.max_in_flight_msat / 2,
12731273
cltv_expiry: channel_state.policy.cltv_expiry_delta,
@@ -1276,7 +1276,7 @@ mod tests {
12761276
assert!(channel_state.check_outgoing_addition(&htlc_1).is_ok());
12771277
assert!(channel_state.add_outgoing_htlc(hash_1, htlc_1).is_ok());
12781278

1279-
let hash_2 = PaymentHash { 0: [2; 32] };
1279+
let hash_2 = PaymentHash([2; 32]);
12801280
let htlc_2 = Htlc {
12811281
amount_msat: channel_state.policy.max_in_flight_msat / 2,
12821282
cltv_expiry: channel_state.policy.cltv_expiry_delta,
@@ -1301,9 +1301,7 @@ mod tests {
13011301

13021302
// Now we're going to add many htlcs so that we hit our in-flight count limit (unique payment hash per htlc).
13031303
for i in 0..channel_state.policy.max_htlc_count {
1304-
let hash = PaymentHash {
1305-
0: [i.try_into().unwrap(); 32],
1306-
};
1304+
let hash = PaymentHash([i.try_into().unwrap(); 32]);
13071305
assert!(channel_state.check_outgoing_addition(&htlc).is_ok());
13081306
assert!(channel_state.add_outgoing_htlc(hash, htlc).is_ok());
13091307
}
@@ -1321,15 +1319,13 @@ mod tests {
13211319

13221320
// Resolve all in-flight htlcs.
13231321
for i in 0..channel_state.policy.max_htlc_count {
1324-
let hash = PaymentHash {
1325-
0: [i.try_into().unwrap(); 32],
1326-
};
1322+
let hash = PaymentHash([i.try_into().unwrap(); 32]);
13271323
assert!(channel_state.remove_outgoing_htlc(&hash).is_ok());
13281324
channel_state.settle_outgoing_htlc(htlc.amount_msat, true)
13291325
}
13301326

13311327
// Add and settle another htlc to move more liquidity away from our local balance.
1332-
let hash_4 = PaymentHash { 0: [1; 32] };
1328+
let hash_4 = PaymentHash([1; 32]);
13331329
let htlc_4 = Htlc {
13341330
amount_msat: channel_state.policy.max_htlc_size_msat,
13351331
cltv_expiry: channel_state.policy.cltv_expiry_delta,
@@ -1367,7 +1363,7 @@ mod tests {
13671363
};
13681364

13691365
// Assert that we're not able to send a htlc over node_2 -> node_1 (no liquidity).
1370-
let hash_1 = PaymentHash { 0: [1; 32] };
1366+
let hash_1 = PaymentHash([1; 32]);
13711367
let htlc_1 = Htlc {
13721368
amount_msat: node_2.policy.min_htlc_size_msat,
13731369
cltv_expiry: node_1.policy.cltv_expiry_delta,
@@ -1379,7 +1375,7 @@ mod tests {
13791375
));
13801376

13811377
// Assert that we can send a htlc over node_1 -> node_2.
1382-
let hash_2 = PaymentHash { 0: [1; 32] };
1378+
let hash_2 = PaymentHash([1; 32]);
13831379
let htlc_2 = Htlc {
13841380
amount_msat: node_1.policy.max_htlc_size_msat,
13851381
cltv_expiry: node_2.policy.cltv_expiry_delta,
@@ -1484,7 +1480,7 @@ mod tests {
14841480
panic!("unknown mocked receiver");
14851481
};
14861482

1487-
let _ = sender.send(Ok(result)).unwrap();
1483+
sender.send(Ok(result)).unwrap();
14881484
},
14891485
);
14901486

@@ -1589,7 +1585,7 @@ mod tests {
15891585

15901586
let (sender, receiver) = oneshot::channel();
15911587
self.graph
1592-
.dispatch_payment(source, route.clone(), PaymentHash { 0: [1; 32] }, sender);
1588+
.dispatch_payment(source, route.clone(), PaymentHash([1; 32]), sender);
15931589

15941590
// Assert that we receive from the channel or fail.
15951591
assert!(timeout(Duration::from_millis(10), receiver).await.is_ok());

0 commit comments

Comments
 (0)