Skip to content

Commit 1c0079f

Browse files
TheBlueMattMatt Corallo
authored andcommitted
Use newly-exposed get_route in HumanObjectPeerTest
1 parent 9ad2841 commit 1c0079f

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

src/test/java/org/ldk/HumanObjectPeerTest.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -470,21 +470,6 @@ Event[] get_manager_events(int expected_len) {
470470
assert res.length == expected_len;
471471
return res;
472472
}
473-
474-
Route get_route(byte[] dest_node, ChannelDetails[] our_chans) {
475-
try (LockedNetworkGraph netgraph = this.router.read_locked_graph()) {
476-
NetworkGraph graph = netgraph.graph();
477-
long res = bindings.get_route(this.node_id, graph._test_only_get_ptr(), dest_node, 0L, new long[]{our_chans[0]._test_only_get_ptr()},
478-
new long[0], 1000000, 42, this.logger._test_only_get_ptr());
479-
assert bindings.LDKCResult_RouteLightningErrorZ_result_ok(res);
480-
byte[] serialized_route = bindings.Route_write(bindings.LDKCResult_RouteLightningErrorZ_get_ok(res));
481-
must_free_objs.add(new WeakReference<>(serialized_route));
482-
Result_RouteDecodeErrorZ copy = Route.read(serialized_route);
483-
assert copy instanceof Result_RouteDecodeErrorZ.Result_RouteDecodeErrorZ_OK;
484-
bindings.CResult_RouteLightningErrorZ_free(res);
485-
return ((Result_RouteDecodeErrorZ.Result_RouteDecodeErrorZ_OK) copy).res;
486-
}
487-
}
488473
}
489474

490475
static class DescriptorHolder { SocketDescriptor val; }
@@ -664,8 +649,19 @@ TestState do_test_message_handler() throws InterruptedException {
664649
assert description_string.equals("Invoice Description");
665650
byte[] payment_hash = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.payment_hash();
666651
byte[] payment_secret = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.payment_secret();
652+
byte[] dest_node_id = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.recover_payee_pub_key();
653+
assert Arrays.equals(dest_node_id, peer2.node_id);
654+
InvoiceFeatures invoice_features = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.features();
655+
RouteHint[] route_hints = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.route_hints();
656+
657+
Route route;
658+
try (LockedNetworkGraph netgraph = peer1.router.read_locked_graph()) {
659+
NetworkGraph graph = netgraph.graph();
660+
Result_RouteLightningErrorZ route_res = UtilMethods.get_route(peer1.chan_manager.get_our_node_id(), graph, peer2.node_id, invoice_features, peer1_chans, route_hints, 1000000, 42, peer1.logger);
661+
assert route_res instanceof Result_RouteLightningErrorZ.Result_RouteLightningErrorZ_OK;
662+
route = ((Result_RouteLightningErrorZ.Result_RouteLightningErrorZ_OK) route_res).res;
663+
}
667664

668-
Route route = peer1.get_route(peer2.node_id, peer1_chans);
669665
Result_NonePaymentSendFailureZ payment_res = peer1.chan_manager.send_payment(route, payment_hash, payment_secret);
670666
assert payment_res instanceof Result_NonePaymentSendFailureZ.Result_NonePaymentSendFailureZ_OK;
671667
wait_events_processed(peer1, peer2);

0 commit comments

Comments
 (0)