Skip to content

Commit

Permalink
Expand HumanObjectPeerTest to cover get_claimable_balances
Browse files Browse the repository at this point in the history
Memory leaks during tests are unchanged
  • Loading branch information
TheBlueMatt committed Sep 27, 2021
1 parent f6c75b1 commit c0ae06e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/test/java/org/ldk/HumanObjectPeerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,13 @@ void do_test_message_handler_b(TestState state) throws InterruptedException {
Thread.sleep(100);
}

if (state.peer1.chain_monitor != null) {
Balance[] peer1_balances = state.peer1.chain_monitor.get_claimable_balances(state.peer1.chan_manager.list_channels());
assert peer1_balances.length == 0;
Balance[] peer2_balances = state.peer2.chain_monitor.get_claimable_balances(state.peer2.chan_manager.list_channels());
assert peer2_balances.length == 0;
}

ChannelDetails[] peer1_chans = state.peer1.chan_manager.list_channels();

if (nice_close) {
Expand Down Expand Up @@ -851,7 +858,25 @@ void do_test_message_handler_b(TestState state) throws InterruptedException {

assert state.peer1.broadcast_set.size() == 1;
assert state.peer2.broadcast_set.size() == 1;
}

if (state.peer1.chain_monitor != null) {
Balance[] peer1_balances = state.peer1.chain_monitor.get_claimable_balances(state.peer1.chan_manager.list_channels());
assert peer1_balances.length == 1;
for (Balance bal : peer1_balances) {
assert bal instanceof Balance.ClaimableOnChannelClose;
long expected_tx_fee = 183;
assert ((Balance.ClaimableOnChannelClose) bal).claimable_amount_satoshis == 100000 - 1 - 10000 - expected_tx_fee;
}
Balance[] peer2_balances = state.peer2.chain_monitor.get_claimable_balances(state.peer2.chan_manager.list_channels());
assert peer2_balances.length == 1;
for (Balance bal : peer2_balances) {
assert bal instanceof Balance.ClaimableOnChannelClose;
assert ((Balance.ClaimableOnChannelClose) bal).claimable_amount_satoshis == 10000 + 1;
}
}

if (!nice_close) {
NetworkParameters bitcoinj_net = NetworkParameters.fromID(NetworkParameters.ID_MAINNET);
Transaction tx = new Transaction(bitcoinj_net, state.peer1.broadcast_set.getFirst());
Block b = new Block(bitcoinj_net, 2, state.best_blockhash, Sha256Hash.ZERO_HASH, 42, 0, 0,
Expand Down

0 comments on commit c0ae06e

Please sign in to comment.