if (use_chan_manager_constructor) {
this.constructor = new ChannelManagerConstructor(Network.LDKNetwork_Bitcoin, get_config(), new byte[32], 0,
this.explicit_keys_manager, this.fee_estimator, this.chain_monitor, this.net_graph,
- ProbabilisticScoringParameters.with_default(), this.tx_broadcaster, this.logger);
+ ProbabilisticScoringParameters.with_default(), (ChannelManagerConstructor.RouterWrapper)
+ (payer_node_id, route_params, first_hops, inflight_htlcs, payment_hash, payment_id, default_router) -> {
+ assert payment_hash != null && payment_id != null;
+ Router r = default_router.as_Router();
+ must_free_objs.add(new WeakReference<>(r));
+ return r.find_route_with_id(payer_node_id, route_params, first_hops, inflight_htlcs, payment_hash, payment_id);
+ },
+ this.tx_broadcaster, this.logger);
constructor.chain_sync_completed(new ChannelManagerConstructor.EventHandler() {
@Override public void handle_event(Event event) {
synchronized (pending_manager_events) {
}
this.constructor = new ChannelManagerConstructor(serialized, monitors, get_config(),
this.explicit_keys_manager, this.fee_estimator, this.chain_monitor, filter_nullable,
- serialized_graph, ProbabilisticScoringParameters.with_default(), serialized_scorer,
+ serialized_graph, ProbabilisticScoringParameters.with_default(), serialized_scorer, null,
this.tx_broadcaster, this.logger);
try {
// Test that ChannelManagerConstructor correctly rejects duplicate ChannelMonitors
monitors_dupd[1] = monitors[0];
ChannelManagerConstructor constr = new ChannelManagerConstructor(serialized, monitors_dupd, get_config(),
this.explicit_keys_manager, this.fee_estimator, this.chain_monitor, filter_nullable,
- serialized_graph, ProbabilisticScoringParameters.with_default(), serialized_scorer,
+ serialized_graph, ProbabilisticScoringParameters.with_default(), serialized_scorer, null,
this.tx_broadcaster, this.logger);
assert false;
} catch (ChannelManagerConstructor.InvalidSerializedDataException e) {}
this.best_blockhash = best_blockhash;
}
}
- void do_test_message_handler_b(TestState state) throws InterruptedException {
+ void do_test_message_handler_b(TestState state) throws Exception {
GcCheck obj = new GcCheck();
if (state.ref_block != null) {
// Ensure the original peers get freed before we move on. Note that we have to be in a different function
assert upd_msg instanceof Result_ChannelUpdateDecodeErrorZ.Result_ChannelUpdateDecodeErrorZ_OK;
assert ((Result_ChannelUpdateDecodeErrorZ.Result_ChannelUpdateDecodeErrorZ_OK) upd_msg).res.get_contents().get_htlc_maximum_msat() == 0xdeadbeef42424242L;
Option_NetworkUpdateZ upd = Option_NetworkUpdateZ.some(NetworkUpdate.channel_update_message(((Result_ChannelUpdateDecodeErrorZ.Result_ChannelUpdateDecodeErrorZ_OK) upd_msg).res));
+
+ if (use_chan_manager_constructor) {
+ // Lock the scorer twice back-to-back to check that the try-with-resources AutoCloseable on the scorer works.
+ try (ChannelManagerConstructor.ScorerWrapper score = state.peer1.constructor.get_locked_scorer()) {
+ score.prob_scorer.debug_log_liquidity_stats();
+ }
+ try (ChannelManagerConstructor.ScorerWrapper score = state.peer1.constructor.get_locked_scorer()) {
+ score.prob_scorer.clear_manual_penalties();
+ }
+ }
}
java.util.LinkedList<WeakReference<Object>> must_free_objs = new java.util.LinkedList();
}
}
public class HumanObjectPeerTest {
- static HumanObjectPeerTestInstance do_test_run(boolean nice_close, boolean use_km_wrapper, boolean use_manual_watch, boolean reload_peers, boolean break_cross_peer_refs, boolean nio_peer_handler, boolean use_ignoring_routing_handler, boolean use_chan_manager_constructor, boolean use_invoice_payer) throws InterruptedException {
+ static HumanObjectPeerTestInstance do_test_run(boolean nice_close, boolean use_km_wrapper, boolean use_manual_watch, boolean reload_peers, boolean break_cross_peer_refs, boolean nio_peer_handler, boolean use_ignoring_routing_handler, boolean use_chan_manager_constructor, boolean use_invoice_payer) throws Exception {
HumanObjectPeerTestInstance instance = new HumanObjectPeerTestInstance(nice_close, use_km_wrapper, use_manual_watch, reload_peers, break_cross_peer_refs, nio_peer_handler, !nio_peer_handler, use_ignoring_routing_handler, use_chan_manager_constructor, use_invoice_payer);
HumanObjectPeerTestInstance.TestState state = instance.do_test_message_handler();
instance.do_test_message_handler_b(state);
return instance;
}
- static 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, boolean use_ignoring_routing_handler, boolean use_chan_manager_constructor, boolean use_invoice_payer) throws InterruptedException {
+ static 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, boolean use_ignoring_routing_handler, boolean use_chan_manager_constructor, boolean use_invoice_payer) throws Exception {
HumanObjectPeerTestInstance instance = do_test_run(nice_close, use_km_wrapper, use_manual_watch, reload_peers, break_cross_peer_refs, nio_peer_handler, use_ignoring_routing_handler, use_chan_manager_constructor, use_invoice_payer);
while (instance.gc_count != instance.gc_exp_count) {
System.gc();
assert o.get() == null;
}
public static final int TEST_ITERATIONS = (1 << 9);
- public static void do_test_message_handler(IntConsumer statusFunction) throws InterruptedException {
+ public static void do_test_message_handler(IntConsumer statusFunction) throws Exception {
Thread gc_thread = new Thread(() -> {
while (true) {
System.gc();
gc_thread.join();
}
@Test
- public void test_message_handler() throws InterruptedException {
+ public void test_message_handler() throws Exception {
do_test_message_handler(i -> System.err.println("Running test with flags " + i));
}