Skip to content

Commit f4a7fe0

Browse files
committed
f Remove verify_claimable_balances
1 parent 463e07c commit f4a7fe0

File tree

1 file changed

+43
-47
lines changed

1 file changed

+43
-47
lines changed

lightning/src/ln/monitor_tests.rs

Lines changed: 43 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,6 @@ fn sorted_vec<T: Ord>(mut v: Vec<T>) -> Vec<T> {
346346
v
347347
}
348348

349-
fn verify_claimable_balances(mut balances_1: Vec<Balance>, mut balances_2: Vec<Balance>) {
350-
balances_1.sort();
351-
balances_2.sort();
352-
assert_eq!(balances_1, balances_2);
353-
}
354-
355349
/// Asserts that `a` and `b` are close, but maybe off by up to 5.
356350
/// This is useful when checking fees and weights on transactions as things may vary by a few based
357351
/// on signature size and signature size estimation being non-exact.
@@ -1356,31 +1350,33 @@ fn do_test_revoked_counterparty_commitment_balances(anchors: bool, confirm_htlc_
13561350

13571351
// Prior to channel closure, B considers the preimage HTLC as its own, and otherwise only
13581352
// lists the two on-chain timeout-able HTLCs as claimable balances.
1359-
verify_claimable_balances(
1360-
vec![Balance::ClaimableOnChannelClose {
1361-
amount_satoshis: 100_000 - 5_000 - 4_000 - 3 - 2_000 + 3_000 - 1 /* rounded up msat parts of HTLCs */,
1362-
transaction_fee_satoshis: 0,
1363-
outbound_payment_htlc_rounded_msat: 3200,
1364-
outbound_forwarded_htlc_rounded_msat: 0,
1365-
inbound_claiming_htlc_rounded_msat: 100,
1366-
inbound_htlc_rounded_msat: 0,
1367-
}, Balance::MaybeTimeoutClaimableHTLC {
1368-
amount_satoshis: 2_000,
1369-
claimable_height: missing_htlc_cltv_timeout,
1370-
payment_hash: missing_htlc_payment_hash,
1371-
outbound_payment: true,
1372-
}, Balance::MaybeTimeoutClaimableHTLC {
1373-
amount_satoshis: 4_000,
1374-
claimable_height: htlc_cltv_timeout,
1375-
payment_hash: timeout_payment_hash,
1376-
outbound_payment: true,
1377-
}, Balance::MaybeTimeoutClaimableHTLC {
1378-
amount_satoshis: 5_000,
1379-
claimable_height: live_htlc_cltv_timeout,
1380-
payment_hash: live_payment_hash,
1381-
outbound_payment: true,
1382-
}],
1383-
nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances(),
1353+
assert_eq!(
1354+
sorted_vec(vec![
1355+
Balance::ClaimableOnChannelClose {
1356+
amount_satoshis: 100_000 - 5_000 - 4_000 - 3 - 2_000 + 3_000 - 1 /* rounded up msat parts of HTLCs */,
1357+
transaction_fee_satoshis: 0,
1358+
outbound_payment_htlc_rounded_msat: 3200,
1359+
outbound_forwarded_htlc_rounded_msat: 0,
1360+
inbound_claiming_htlc_rounded_msat: 100,
1361+
inbound_htlc_rounded_msat: 0,
1362+
}, Balance::MaybeTimeoutClaimableHTLC {
1363+
amount_satoshis: 2_000,
1364+
claimable_height: missing_htlc_cltv_timeout,
1365+
payment_hash: missing_htlc_payment_hash,
1366+
outbound_payment: true,
1367+
}, Balance::MaybeTimeoutClaimableHTLC {
1368+
amount_satoshis: 4_000,
1369+
claimable_height: htlc_cltv_timeout,
1370+
payment_hash: timeout_payment_hash,
1371+
outbound_payment: true,
1372+
}, Balance::MaybeTimeoutClaimableHTLC {
1373+
amount_satoshis: 5_000,
1374+
claimable_height: live_htlc_cltv_timeout,
1375+
payment_hash: live_payment_hash,
1376+
outbound_payment: true,
1377+
},
1378+
]),
1379+
sorted_vec(nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances()),
13841380
);
13851381

13861382
mine_transaction(&nodes[1], &as_revoked_txn[0]);
@@ -1427,15 +1423,15 @@ fn do_test_revoked_counterparty_commitment_balances(anchors: bool, confirm_htlc_
14271423

14281424
// Once the channel has been closed by A, B now considers all of the commitment transactions'
14291425
// outputs as `CounterpartyRevokedOutputClaimable`.
1430-
verify_claimable_balances(
1431-
vec![
1426+
assert_eq!(
1427+
sorted_vec(vec![
14321428
to_remote_balance.clone(),
14331429
to_self_unclaimed_balance.clone(),
14341430
htlc_unclaimed_balance(3_000),
14351431
htlc_unclaimed_balance(4_000),
14361432
htlc_unclaimed_balance(5_000),
1437-
],
1438-
nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances(),
1433+
]),
1434+
sorted_vec(nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances()),
14391435
);
14401436

14411437
if confirm_htlc_spend_first {
@@ -1461,24 +1457,24 @@ fn do_test_revoked_counterparty_commitment_balances(anchors: bool, confirm_htlc_
14611457
};
14621458

14631459
if confirm_htlc_spend_first {
1464-
verify_claimable_balances(
1465-
vec![
1460+
assert_eq!(
1461+
sorted_vec(vec![
14661462
to_remote_balance.clone(),
14671463
pinnable_claimed_balance.clone(),
14681464
to_self_unclaimed_balance.clone(),
1469-
],
1470-
nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances(),
1465+
]),
1466+
sorted_vec(nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances()),
14711467
);
14721468
} else {
1473-
verify_claimable_balances(
1474-
vec![
1469+
assert_eq!(
1470+
sorted_vec(vec![
14751471
to_remote_balance.clone(),
14761472
unpinnable_claimed_balance.clone(),
14771473
htlc_unclaimed_balance(3_000),
14781474
htlc_unclaimed_balance(4_000),
14791475
htlc_unclaimed_balance(5_000),
1480-
],
1481-
nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances(),
1476+
]),
1477+
sorted_vec(nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances()),
14821478
);
14831479
}
14841480

@@ -1487,13 +1483,13 @@ fn do_test_revoked_counterparty_commitment_balances(anchors: bool, confirm_htlc_
14871483
} else {
14881484
mine_transaction(&nodes[1], &claim_txn[0]);
14891485
}
1490-
verify_claimable_balances(
1491-
vec![
1486+
assert_eq!(
1487+
sorted_vec(vec![
14921488
to_remote_balance.clone(),
14931489
pinnable_claimed_balance.clone(),
14941490
unpinnable_claimed_balance.clone(),
1495-
],
1496-
nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances(),
1491+
]),
1492+
sorted_vec(nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances()),
14971493
);
14981494

14991495
connect_blocks(&nodes[1], 3);

0 commit comments

Comments
 (0)