X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Fldk%2FHumanObjectPeerTest.java;fp=src%2Ftest%2Fjava%2Forg%2Fldk%2FHumanObjectPeerTest.java;h=a0879869ff8355c8b1d80c8b8d710315ec0cdc94;hb=f8c25e52ce878136043ddc4dbfac6c6640f1d4f6;hp=cc67cfe877005cc9f75d7ee87a08293c509e98bf;hpb=bbc02b4a3cfdb5f32cdd650fdcd4dc4e55ca1517;p=ldk-java diff --git a/src/test/java/org/ldk/HumanObjectPeerTest.java b/src/test/java/org/ldk/HumanObjectPeerTest.java index cc67cfe8..a0879869 100644 --- a/src/test/java/org/ldk/HumanObjectPeerTest.java +++ b/src/test/java/org/ldk/HumanObjectPeerTest.java @@ -174,6 +174,7 @@ class HumanObjectPeerTestInstance { final HashMap monitors; // Wow I forgot just how terrible Java is - we can't put a byte array here. byte[] node_id; final LinkedList broadcast_set = new LinkedList<>(); + GcCheck obj = new GcCheck(); private TwoTuple test_mon_roundtrip(ChannelMonitor mon) { // Because get_funding_txo() returns an OutPoint in a tuple that is a reference to an OutPoint inside the @@ -267,7 +268,7 @@ class HumanObjectPeerTestInstance { } Peer(byte seed) { this(null, seed); - this.chan_manager = ChannelManager.constructor_new(FeeEstimator.new_impl(confirmation_target -> 0), chain_watch, tx_broadcaster, logger, this.keys_interface, UserConfig.constructor_default(), LDKNetwork.LDKNetwork_Bitcoin, new byte[32], 1); + this.chan_manager = ChannelManager.constructor_new(FeeEstimator.new_impl(confirmation_target -> 0), chain_watch, tx_broadcaster, logger, this.keys_interface, UserConfig.constructor_default(), LDKNetwork.LDKNetwork_Bitcoin, new byte[32], 0); this.node_id = chan_manager.get_our_node_id(); this.chan_manager_events = chan_manager.as_EventsProvider(); @@ -351,7 +352,7 @@ class HumanObjectPeerTestInstance { txn = new TwoTuple[]{txp}; } else txn = new TwoTuple[0]; - chan_manager.block_connected(header, txn, height); + chan_manager.as_Listen().block_connected(b.bitcoinSerialize(), height); if (chain_monitor != null) { chain_monitor.block_connected(header, txn, height); } else { @@ -616,8 +617,8 @@ class HumanObjectPeerTestInstance { System.runFinalization(); } connect_peers(state.peer1, state.peer2); - wait_events_processed(state.peer1, state.peer2); } + wait_events_processed(state.peer1, state.peer2); Event[] events = state.peer2.chan_manager_events.get_and_clear_pending_events(); assert events.length == 1; @@ -656,7 +657,7 @@ class HumanObjectPeerTestInstance { 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, Arrays.asList(new Transaction[]{tx})); - TwoTuple[]>[] watch_outputs = state.peer2.connect_block(b, 1, 1); + TwoTuple[]>[] watch_outputs = state.peer2.connect_block(b, 10, 1); if (watch_outputs != null) { // We only process watch_outputs manually when we use a manually-build Watch impl assert watch_outputs.length == 1; assert Arrays.equals(watch_outputs[0].a, tx.getTxId().getReversedBytes()); @@ -683,11 +684,13 @@ class HumanObjectPeerTestInstance { } java.util.LinkedList> must_free_objs = new java.util.LinkedList(); - boolean gc_ran = false; + int gc_count = 0; + int gc_exp_count = 0; class GcCheck { + GcCheck() { gc_exp_count += 1; } @Override protected void finalize() throws Throwable { - gc_ran = true; + gc_count += 1; super.finalize(); } } @@ -701,7 +704,7 @@ public class HumanObjectPeerTest { } void do_test(boolean nice_close, boolean use_km_wrapper, boolean use_manual_watch, boolean reload_peers, boolean break_cross_peer_refs, boolean nio_peer_handler) throws InterruptedException { HumanObjectPeerTestInstance instance = do_test_run(nice_close, use_km_wrapper, use_manual_watch, reload_peers, break_cross_peer_refs, nio_peer_handler); - while (!instance.gc_ran) { + while (instance.gc_count != instance.gc_exp_count) { System.gc(); System.runFinalization(); }