]> git.bitcoin.ninja Git - ldk-java/commitdiff
[Java] Update batteries and tests to 0.0.108
authorMatt Corallo <git@bluematt.me>
Mon, 27 Jun 2022 19:36:44 +0000 (19:36 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 29 Jun 2022 19:08:49 +0000 (19:08 +0000)
This is mostly pretty obvious changes to keep up with the latest
API, though it also includes a change to make `PeerTest` work
correctly in a world where `PeerManager` supports multithreaded
parallel access.

src/main/java/org/ldk/batteries/ChannelManagerConstructor.java
src/test/java/org/ldk/HumanObjectPeerTest.java
src/test/java/org/ldk/ManualMsgHandlingPeerTest.java
src/test/java/org/ldk/PeerTest.java

index 6a9b9be69e48f8c49d369b3b07e077b3c8952db4..109acbe39f505afa9cf1c272a9ef08b4e039511b 100644 (file)
@@ -72,7 +72,7 @@ public class ChannelManagerConstructor {
      * given explicitly to the new-object constructor.
      */
     @Nullable public final NetworkGraph net_graph;
-    @Nullable private final NetGraphMsgHandler graph_msg_handler;
+    @Nullable private final P2PGossipSync graph_msg_handler;
     private final Logger logger;
 
     private final byte[] router_rand_bytes;
@@ -115,7 +115,7 @@ public class ChannelManagerConstructor {
         this.logger = logger;
         byte[] random_data = keys_interface.get_secure_random_bytes();
         if (net_graph_serialized != null) {
-            Result_NetworkGraphDecodeErrorZ graph_res = NetworkGraph.read(net_graph_serialized);
+            Result_NetworkGraphDecodeErrorZ graph_res = NetworkGraph.read(net_graph_serialized, logger);
             if (!graph_res.is_ok()) {
                 throw new InvalidSerializedDataException("Serialized Network Graph was corrupt");
             }
@@ -127,7 +127,7 @@ public class ChannelManagerConstructor {
         assert node_secret.is_ok();
         if (net_graph != null) {
             //TODO: We really need to expose the Access here to let users prevent DoS issues
-            this.graph_msg_handler = NetGraphMsgHandler.of(net_graph, Option_AccessZ.none(), logger);
+            this.graph_msg_handler = P2PGossipSync.of(net_graph, Option_AccessZ.none(), logger);
             this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(),
                     graph_msg_handler.as_RoutingMessageHandler(),
                     ((Result_SecretKeyNoneZ.Result_SecretKeyNoneZ_OK)node_secret).res,
@@ -174,7 +174,7 @@ public class ChannelManagerConstructor {
         assert node_secret.is_ok();
         if (net_graph != null) {
             //TODO: We really need to expose the Access here to let users prevent DoS issues
-            this.graph_msg_handler = NetGraphMsgHandler.of(net_graph, Option_AccessZ.none(), logger);
+            this.graph_msg_handler = P2PGossipSync.of(net_graph, Option_AccessZ.none(), logger);
             this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(),
                     graph_msg_handler.as_RoutingMessageHandler(),
                     ((Result_SecretKeyNoneZ.Result_SecretKeyNoneZ_OK)node_secret).res,
@@ -203,6 +203,7 @@ public class ChannelManagerConstructor {
         void handle_event(Event events);
         void persist_manager(byte[] channel_manager_bytes);
         void persist_network_graph(byte[] network_graph);
+        void persist_scorer(byte[] scorer_bytes);
     }
 
     BackgroundProcessor background_processor = null;
@@ -222,11 +223,17 @@ public class ChannelManagerConstructor {
         org.ldk.structs.EventHandler ldk_handler = org.ldk.structs.EventHandler.new_impl(event_handler::handle_event);
         if (this.net_graph != null && scorer != null) {
             Router router = DefaultRouter.of(net_graph, logger, router_rand_bytes).as_Router();
-            this.payer = InvoicePayer.of(this.channel_manager.as_Payer(), router, scorer, this.logger, ldk_handler, RetryAttempts.of(3));
+            this.payer = InvoicePayer.of(this.channel_manager.as_Payer(), router, scorer, this.logger, ldk_handler, Retry.attempts(3));
 assert this.payer != null;
             ldk_handler = this.payer.as_EventHandler();
         }
 
+        GossipSync gossip_sync;
+        if (this.graph_msg_handler == null)
+            gossip_sync = GossipSync.none();
+        else
+            gossip_sync = GossipSync.p2_p(this.graph_msg_handler);
+
         background_processor = BackgroundProcessor.start(Persister.new_impl(new Persister.PersisterInterface() {
             @Override
             public Result_NoneErrorZ persist_manager(ChannelManager channel_manager) {
@@ -239,7 +246,13 @@ assert this.payer != null;
                 event_handler.persist_network_graph(network_graph.write());
                 return Result_NoneErrorZ.ok();
             }
-        }), ldk_handler, this.chain_monitor, this.channel_manager, this.graph_msg_handler, this.peer_manager, this.logger);
+
+            @Override
+            public Result_NoneErrorZ persist_scorer(MultiThreadedLockableScore scorer) {
+                event_handler.persist_scorer(scorer.write());
+                return Result_NoneErrorZ.ok();
+            }
+        }), ldk_handler, this.chain_monitor, this.channel_manager, gossip_sync, this.peer_manager, this.logger, scorer);
     }
 
     /**
index 64bf97a4340df60b90ee27bdc8664951b2740145..e1a2eacb104e757ab333f0b04cc9cfc79637940c 100644 (file)
@@ -150,14 +150,16 @@ class HumanObjectPeerTestInstance {
                 }
 
                 @Override
-                public MonitorEvent[] release_pending_monitor_events() {
+                public TwoTuple_OutPointCVec_MonitorEventZZ[] release_pending_monitor_events() {
                     synchronized (monitors) {
                         assert monitors.size() <= 1;
                         for (ChannelMonitor mon : monitors.values()) {
-                            return mon.get_and_clear_pending_monitor_events();
+                            TwoTuple_OutPointCVec_MonitorEventZZ[] res = new TwoTuple_OutPointCVec_MonitorEventZZ[1];
+                            res[0] = TwoTuple_OutPointCVec_MonitorEventZZ.of(mon.get_funding_txo().get_a(), mon.get_and_clear_pending_monitor_events());
+                            return res;
                         }
                     }
-                    return new MonitorEvent[0];
+                    return new TwoTuple_OutPointCVec_MonitorEventZZ[0];
                 }
             };
             Watch watch = Watch.new_impl(watch_impl);
@@ -176,7 +178,7 @@ class HumanObjectPeerTestInstance {
         final KeysInterface keys_interface;
         final ChainMonitor chain_monitor;
         NetworkGraph router;
-        NetGraphMsgHandler route_handler;
+        P2PGossipSync route_handler;
         final Watch chain_watch;
         final HashSet<String> filter_additions;
         Option_FilterZ filter;
@@ -338,7 +340,7 @@ class HumanObjectPeerTestInstance {
             }
         }
         private void setup_route_handler() {
-            this.route_handler = NetGraphMsgHandler.of(this.router, Option_AccessZ.some(Access.new_impl(new Access.AccessInterface() {
+            this.route_handler = P2PGossipSync.of(this.router, Option_AccessZ.some(Access.new_impl(new Access.AccessInterface() {
                 @Override
                 public Result_TxOutAccessErrorZ get_utxo(byte[] genesis_hash, long short_channel_id) {
                     // We don't exchange any gossip, so should never actually get called, but providing a Some(Access)
@@ -350,7 +352,7 @@ class HumanObjectPeerTestInstance {
         }
         Peer(byte seed) {
             this(null, seed);
-            this.router = NetworkGraph.of(new byte[32]);
+            this.router = NetworkGraph.of(new byte[32], this.logger);
             this.setup_route_handler();
 
             if (use_chan_manager_constructor) {
@@ -362,8 +364,8 @@ class HumanObjectPeerTestInstance {
                                                        this.keys_interface, this.fee_estimator, this.chain_monitor, this.router, this.tx_broadcaster, this.logger);
                 }
                 ProbabilisticScoringParameters params = ProbabilisticScoringParameters.with_default();
-                ProbabilisticScorer default_scorer = ProbabilisticScorer.of(params, this.router);
-                Result_ProbabilisticScorerDecodeErrorZ score_res = ProbabilisticScorer.read(default_scorer.write(), params, this.router);
+                ProbabilisticScorer default_scorer = ProbabilisticScorer.of(params, this.router, this.logger);
+                Result_ProbabilisticScorerDecodeErrorZ score_res = ProbabilisticScorer.read(default_scorer.write(), params, this.router, this.logger);
                 assert score_res.is_ok();
                 Score score = ((Result_ProbabilisticScorerDecodeErrorZ.Result_ProbabilisticScorerDecodeErrorZ_OK) score_res).res.as_Score();
                 MultiThreadedLockableScore scorer = null;
@@ -377,6 +379,7 @@ class HumanObjectPeerTestInstance {
                     }
                     @Override public void persist_manager(byte[] channel_manager_bytes) { assert channel_manager_bytes.length > 1; }
                     @Override public void persist_network_graph(byte[] graph_bytes) { assert graph_bytes.length > 1; }
+                    @Override public void persist_scorer(byte[] scorer_bytes) { assert scorer_bytes.length > 1; }
                 }, scorer);
                 this.chan_manager = constructor.channel_manager;
                 this.peer_manager = constructor.peer_manager;
@@ -398,7 +401,7 @@ class HumanObjectPeerTestInstance {
                         }
                     }), MultiThreadedLockableScore.of(Score.new_impl(new Score.ScoreInterface() {
                         @Override public void payment_path_failed(RouteHop[] path, long scid) {}
-                        @Override public long channel_penalty_msat(long short_channel_id, long send_amt_msat, long channel_capacity_msat, NodeId source, NodeId target) { return 0; }
+                        @Override public long channel_penalty_msat(long short_channel_id, NodeId source, NodeId target, ChannelUsage usage) { return 0; }
                         @Override public void payment_path_successful(RouteHop[] path) {}
                         @Override public byte[] write() { assert false; return null; }
                     })), logger, EventHandler.new_impl(new EventHandler.EventHandlerInterface() {
@@ -408,7 +411,7 @@ class HumanObjectPeerTestInstance {
                                 pending_manager_events.notifyAll();
                             }
                         }
-                    }), RetryAttempts.of(0));
+                    }), Retry.attempts(0));
                 }
             }
 
@@ -452,7 +455,7 @@ class HumanObjectPeerTestInstance {
                     this.router = this.constructor.net_graph;
                     setup_route_handler();
                     MultiThreadedLockableScore scorer = null;
-                    if (use_invoice_payer) { scorer = MultiThreadedLockableScore.of(ProbabilisticScorer.of(ProbabilisticScoringParameters.with_default(), this.router).as_Score()); }
+                    if (use_invoice_payer) { scorer = MultiThreadedLockableScore.of(ProbabilisticScorer.of(ProbabilisticScoringParameters.with_default(), this.router, this.logger).as_Score()); }
                     constructor.chain_sync_completed(new ChannelManagerConstructor.EventHandler() {
                         @Override public void handle_event(Event event) {
                             synchronized (pending_manager_events) {
@@ -462,6 +465,7 @@ class HumanObjectPeerTestInstance {
                         }
                         @Override public void persist_manager(byte[] channel_manager_bytes) { assert channel_manager_bytes.length > 1; }
                         @Override public void persist_network_graph(byte[] graph_bytes) { assert graph_bytes.length > 1; }
+                        @Override public void persist_scorer(byte[] scorer_bytes) { assert scorer_bytes.length > 1; }
                     }, scorer);
                     this.chan_manager = constructor.channel_manager;
                     this.payer = constructor.payer;
@@ -478,7 +482,7 @@ class HumanObjectPeerTestInstance {
                     assert false;
                 }
             } else {
-                this.router = NetworkGraph.of(new byte[32]);
+                this.router = NetworkGraph.of(new byte[32], this.logger);
                 this.setup_route_handler();
                 ChannelMonitor[] monitors = new ChannelMonitor[1];
                 assert orig.monitors.size() == 1;
@@ -516,7 +520,7 @@ class HumanObjectPeerTestInstance {
                             return UtilMethods.find_route(payer, params, router, first_hops, logger, scorer, new byte[32]);
                         }
                     }), MultiThreadedLockableScore.of(Score.new_impl(new Score.ScoreInterface() {
-                        @Override public long channel_penalty_msat(long short_channel_id, long send_amt_msat, long channel_capacity_msat, NodeId source, NodeId target) { return 0; }
+                        @Override public long channel_penalty_msat(long short_channel_id, NodeId source, NodeId target, ChannelUsage usage) { return 0; }
                         @Override public void payment_path_failed(RouteHop[] path, long scid) {}
                         @Override public void payment_path_successful(RouteHop[] path) {}
                         @Override public byte[] write() { assert false; return null; }
@@ -527,7 +531,7 @@ class HumanObjectPeerTestInstance {
                                 pending_manager_events.notifyAll();
                             }
                         }
-                    }), RetryAttempts.of(0));
+                    }), Retry.attempts(0));
                 }
             }
             this.node_id = chan_manager.get_our_node_id();
@@ -785,7 +789,7 @@ class HumanObjectPeerTestInstance {
         funding.getInputs().get(0).setWitness(new TransactionWitness(2)); // Make sure we don't complain about lack of witness
         funding.getInput(0).getWitness().setPush(0, new byte[]{0x1});
         funding.addOutput(Coin.SATOSHI.multiply(100000), new Script(funding_spk));
-        Result_NoneAPIErrorZ funding_res = peer1.chan_manager.funding_transaction_generated(chan_id, funding.bitcoinSerialize());
+        Result_NoneAPIErrorZ funding_res = peer1.chan_manager.funding_transaction_generated(chan_id, peer2.node_id, funding.bitcoinSerialize());
         assert funding_res instanceof Result_NoneAPIErrorZ.Result_NoneAPIErrorZ_OK;
 
         maybe_exchange_peer_messages(peer1, peer2);
@@ -825,7 +829,7 @@ class HumanObjectPeerTestInstance {
         assert Arrays.equals(peer1_chans[0].get_channel_id(), funding.getTxId().getReversedBytes());
         assert Arrays.equals(peer2_chans[0].get_channel_id(), funding.getTxId().getReversedBytes());
 
-        Result_InvoiceSignOrCreationErrorZ invoice = UtilMethods.create_invoice_from_channelmanager(peer2.chan_manager, peer2.keys_interface, Currency.LDKCurrency_Bitcoin, Option_u64Z.some(10000000), "Invoice Description");
+        Result_InvoiceSignOrCreationErrorZ invoice = UtilMethods.create_invoice_from_channelmanager(peer2.chan_manager, peer2.keys_interface, Currency.LDKCurrency_Bitcoin, Option_u64Z.some(10000000), "Invoice Description", 7200);
         assert invoice instanceof Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK;
         System.out.println("Got invoice: " + ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.to_str());
 
@@ -851,7 +855,7 @@ class HumanObjectPeerTestInstance {
             RouteParameters route_params = RouteParameters.of(payee, 10000000, 42);
             Result_RouteLightningErrorZ route_res = UtilMethods.find_route(
                     peer1.chan_manager.get_our_node_id(), route_params, peer1.router,
-                    peer1_chans, peer1.logger, Scorer.with_default().as_Score(), new byte[32]);
+                    peer1_chans, peer1.logger, ProbabilisticScorer.of(ProbabilisticScoringParameters.with_default(), peer1.router, peer1.logger).as_Score(), new byte[32]);
             assert route_res instanceof Result_RouteLightningErrorZ.Result_RouteLightningErrorZ_OK;
             Route route = ((Result_RouteLightningErrorZ.Result_RouteLightningErrorZ_OK) route_res).res;
             assert route.get_paths().length == 1;
@@ -927,6 +931,12 @@ class HumanObjectPeerTestInstance {
         assert !Arrays.equals(payment_preimage, new byte[32]);
         state.peer2.chan_manager.claim_funds(payment_preimage);
 
+        events = state.peer2.get_manager_events(1, state.peer1, state.peer2);
+        assert events[0] instanceof Event.PaymentClaimed;
+        assert ((Event.PaymentClaimed)events[0]).purpose instanceof PaymentPurpose.InvoicePayment;
+        payment_preimage = ((PaymentPurpose.InvoicePayment)((Event.PaymentClaimed)events[0]).purpose).payment_preimage;
+        assert !Arrays.equals(payment_preimage, new byte[32]);
+
         events = state.peer1.get_manager_events(2, state.peer1, state.peer2);
         assert events[0] instanceof Event.PaymentSent;
         assert Arrays.equals(((Event.PaymentSent) events[0]).payment_preimage, payment_preimage);
@@ -950,7 +960,7 @@ class HumanObjectPeerTestInstance {
         ChannelDetails[] peer1_chans = state.peer1.chan_manager.list_channels();
 
         if (nice_close) {
-            Result_NoneAPIErrorZ close_res = state.peer1.chan_manager.close_channel(peer1_chans[0].get_channel_id());
+            Result_NoneAPIErrorZ close_res = state.peer1.chan_manager.close_channel(peer1_chans[0].get_channel_id(), state.peer2.node_id);
             assert close_res instanceof Result_NoneAPIErrorZ.Result_NoneAPIErrorZ_OK;
             maybe_exchange_peer_messages(state.peer1, state.peer2);
             synchronized (state.peer1.broadcast_set) {
@@ -959,9 +969,6 @@ class HumanObjectPeerTestInstance {
             synchronized (state.peer2.broadcast_set) {
                 while (state.peer2.broadcast_set.size() != 1) state.peer2.broadcast_set.wait();
             }
-
-            assert state.peer1.broadcast_set.size() == 1;
-            assert state.peer2.broadcast_set.size() == 1;
         } else {
             state.peer1.chan_manager.force_close_all_channels();
             maybe_exchange_peer_messages(state.peer1, state.peer2);
@@ -971,11 +978,11 @@ class HumanObjectPeerTestInstance {
             synchronized (state.peer2.broadcast_set) {
                 while (state.peer2.broadcast_set.size() != 1) state.peer2.broadcast_set.wait();
             }
-
-            assert state.peer1.broadcast_set.size() == 1;
-            assert state.peer2.broadcast_set.size() == 1;
         }
 
+        assert state.peer1.broadcast_set.size() == 1;
+        assert state.peer2.broadcast_set.size() == 1;
+
         events = state.peer2.get_manager_events(1, state.peer1, state.peer2);
         assert events[0] instanceof Event.ChannelClosed;
         events = state.peer1.get_manager_events(1, state.peer1, state.peer2);
index 786d7427dc9471b0855b29424825a90d272042b3..40c536ee180334e215f10c1c1743af43352e794c 100644 (file)
@@ -34,7 +34,7 @@ public class ManualMsgHandlingPeerTest {
             }
 
             @Override
-            public void handle_funding_locked(byte[] their_node_id, long msg) {
+            public void handle_channel_ready(byte[] their_node_id, long msg) {
 
             }
 
index e5967cf5b611cc3ae3f0b50e1a70abaec87fbe6b..ec3f92f7ec1ccc8c98c4195411bfeb5fa901a26a 100644 (file)
@@ -11,6 +11,8 @@ import java.lang.ref.Reference;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
 
 public class PeerTest {
@@ -80,7 +82,12 @@ public class PeerTest {
                     synchronized (monitors) {
                         assert monitors.size() <= 1;
                         for (Long mon : monitors.values()) {
-                            return bindings.ChannelMonitor_get_and_clear_pending_monitor_events(mon);
+                            long funding_info = bindings.ChannelMonitor_get_funding_txo(mon);
+                            long funding_txo = bindings.C2Tuple_OutPointScriptZ_get_a(funding_info);
+                            long[] mon_events = bindings.ChannelMonitor_get_and_clear_pending_monitor_events(mon);
+                            long funding_mon_tuple = bindings.C2Tuple_OutPointCVec_MonitorEventZZ_new(funding_txo, mon_events);
+                            bindings.C2Tuple_OutPointScriptZ_free(funding_info);
+                            return new long[] {funding_mon_tuple};
                         }
                     }
                     return new long[0];
@@ -99,9 +106,9 @@ public class PeerTest {
             this.chan_manager_events = bindings.ChannelManager_as_EventsProvider(chan_manager);
 
             this.chan_handler = bindings.ChannelManager_as_ChannelMessageHandler(chan_manager);
-            this.router = bindings.NetworkGraph_new(new byte[32]);
-            this.router_wrapper = bindings.NetGraphMsgHandler_new(router, bindings.COption_AccessZ_none(), logger);
-            this.route_handler = bindings.NetGraphMsgHandler_as_RoutingMessageHandler(router_wrapper);
+            this.router = bindings.NetworkGraph_new(new byte[32], logger);
+            this.router_wrapper = bindings.P2PGossipSync_new(router, bindings.COption_AccessZ_none(), logger);
+            this.route_handler = bindings.P2PGossipSync_as_RoutingMessageHandler(router_wrapper);
             this.message_handler = bindings.MessageHandler_new(chan_handler, route_handler);
             this.custom_message_handler = bindings.IgnoringMessageHandler_new();
 
@@ -148,7 +155,7 @@ public class PeerTest {
             bindings.EventsProvider_free(chan_manager_events);
             bindings.ChannelMessageHandler_free(chan_handler);
             bindings.NetworkGraph_free(router);
-            bindings.NetGraphMsgHandler_free(router_wrapper);
+            bindings.P2PGossipSync_free(router_wrapper);
             bindings.RoutingMessageHandler_free(route_handler);
             //MessageHandler was actually moved into the route_handler!: bindings.MessageHandler_free(message_handler);
             bindings.PeerManager_free(peer_manager);
@@ -161,13 +168,30 @@ public class PeerTest {
     }
 
     class LongHolder { long val; }
+    class PendingWrite {
+        long pm;
+        long descriptor;
+        byte[] array;
+        PendingWrite(long pm, long descriptor, byte[] array) { this.pm = pm; this.descriptor = descriptor; this.array = array; }
+        void process() {
+            long res = bindings.PeerManager_read_event(pm, descriptor, array);
+            assert bindings.CResult_boolPeerHandleErrorZ_is_ok(res);
+            assert !bindings.CResult_boolPeerHandleErrorZ_get_ok(res);
+            bindings.CResult_boolPeerHandleErrorZ_free(res);
+        }
+    }
+    ConcurrentLinkedQueue<PendingWrite> pending_writes = new ConcurrentLinkedQueue<>();
 
     void do_read_event(ConcurrentLinkedQueue<Thread> list, long pm, long descriptor, byte[] arr) {
+        pending_writes.add(new PendingWrite(pm, descriptor, arr));
         Thread thread = new Thread(() -> {
-            long res = bindings.PeerManager_read_event(pm, descriptor, arr);
-            assert bindings.CResult_boolPeerHandleErrorZ_is_ok(res);
-            //assert bindings.deref_bool(bindings.LDKCResult_boolPeerHandleErrorZ_get_inner(res));
-            bindings.CResult_boolPeerHandleErrorZ_free(res);
+            synchronized (pending_writes) {
+                while (true) {
+                    PendingWrite write = pending_writes.poll();
+                    if (write == null) break;
+                    write.process();
+                }
+            }
         });
         thread.start();
         list.add(thread);
@@ -256,7 +280,7 @@ public class PeerTest {
         funding.getInputs().get(0).setWitness(new TransactionWitness(2)); // Make sure we don't complain about lack of witness
         funding.getInput(0).getWitness().setPush(0, new byte[] {0x1});
         funding.addOutput(Coin.SATOSHI.multiply(10000), new Script(funding_spk));
-        bindings.ChannelManager_funding_transaction_generated(peer1.chan_manager, chan_id, funding.bitcoinSerialize());
+        bindings.ChannelManager_funding_transaction_generated(peer1.chan_manager, chan_id, peer2.node_id, funding.bitcoinSerialize());
 
         deliver_peer_messages(list, peer1.peer_manager, peer2.peer_manager);
 
@@ -287,8 +311,9 @@ public class PeerTest {
         assert bindings.CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(inbound_payment);
         long payment_tuple = bindings.CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(inbound_payment);
         bindings.COption_u64Z_free(no_min_val);
-        long scorer = bindings.Scorer_default();
-        long scorer_interface = bindings.Scorer_as_Score(scorer);
+
+        long scorer = bindings.ProbabilisticScorer_new(bindings.ProbabilisticScoringParameters_default(), peer1.router, peer1.logger);
+        long scorer_interface = bindings.ProbabilisticScorer_as_Score(scorer);
 
         long no_u64 = bindings.COption_u64Z_none();
         long invoice_features = bindings.InvoiceFeatures_known();
@@ -296,12 +321,12 @@ public class PeerTest {
         bindings.InvoiceFeatures_free(invoice_features);
         bindings.COption_u64Z_free(no_u64);
         long route_params = bindings.RouteParameters_new(payee, 1000, 42);
-        long route = bindings.find_route(peer1.node_id, route_params, peer1.router, peer1_chans,
-                peer1.logger, scorer_interface, new byte[32]);
+        long route = bindings.find_route(peer1.node_id, route_params, peer1.router, peer1_chans, peer1.logger,
+                scorer_interface, new byte[32]);
         bindings.RouteParameters_free(route_params);
         bindings.PaymentParameters_free(payee);
         bindings.Score_free(scorer_interface);
-        bindings.Scorer_free(scorer);
+        bindings.ProbabilisticScorer_free(scorer);
 
         for (long chan : peer1_chans) bindings.ChannelDetails_free(chan);
         assert bindings.CResult_RouteLightningErrorZ_is_ok(route);
@@ -327,7 +352,13 @@ public class PeerTest {
         assert payment_recvd instanceof bindings.LDKEvent.PaymentReceived;
         bindings.LDKPaymentPurpose purpose = bindings.LDKPaymentPurpose_ref_from_ptr(((bindings.LDKEvent.PaymentReceived) payment_recvd).purpose);
         assert purpose instanceof bindings.LDKPaymentPurpose.InvoicePayment;
-        assert bindings.ChannelManager_claim_funds(peer2.chan_manager, ((bindings.LDKPaymentPurpose.InvoicePayment) purpose).payment_preimage);
+        bindings.ChannelManager_claim_funds(peer2.chan_manager, ((bindings.LDKPaymentPurpose.InvoicePayment) purpose).payment_preimage);
+        bindings.Event_free(events.remove(0));
+
+        bindings.EventsProvider_process_pending_events(peer2.chan_manager_events, handler);
+        assert events.size() == 1;
+        bindings.LDKEvent payment_claimed = bindings.LDKEvent_ref_from_ptr(events.get(0));
+        assert payment_claimed instanceof bindings.LDKEvent.PaymentClaimed;
         bindings.Event_free(events.remove(0));
 
         deliver_peer_messages(list, peer1.peer_manager, peer2.peer_manager);