Skip to content

Commit 976cee7

Browse files
committed
[Java] Update tests to latest upstream API
1 parent e276522 commit 976cee7

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,16 @@ public Result_NoneChannelMonitorUpdateErrZ update_channel(OutPoint funding_txo,
151151
}
152152

153153
@Override
154-
public TwoTuple_OutPointCVec_MonitorEventZZ[] release_pending_monitor_events() {
154+
public ThreeTuple_OutPointCVec_MonitorEventZPublicKeyZ[] release_pending_monitor_events() {
155155
synchronized (monitors) {
156156
assert monitors.size() <= 1;
157157
for (ChannelMonitor mon : monitors.values()) {
158-
TwoTuple_OutPointCVec_MonitorEventZZ[] res = new TwoTuple_OutPointCVec_MonitorEventZZ[1];
159-
res[0] = TwoTuple_OutPointCVec_MonitorEventZZ.of(mon.get_funding_txo().get_a(), mon.get_and_clear_pending_monitor_events());
158+
ThreeTuple_OutPointCVec_MonitorEventZPublicKeyZ[] res = new ThreeTuple_OutPointCVec_MonitorEventZPublicKeyZ[1];
159+
res[0] = ThreeTuple_OutPointCVec_MonitorEventZPublicKeyZ.of(mon.get_funding_txo().get_a(), mon.get_and_clear_pending_monitor_events(), mon.get_counterparty_node_id());
160160
return res;
161161
}
162162
}
163-
return new TwoTuple_OutPointCVec_MonitorEventZZ[0];
163+
return new ThreeTuple_OutPointCVec_MonitorEventZPublicKeyZ[0];
164164
}
165165
};
166166
Watch watch = Watch.new_impl(watch_impl);
@@ -405,6 +405,8 @@ public Result_RouteLightningErrorZ find_route(byte[] payer, RouteParameters para
405405
@Override public void payment_path_failed(RouteHop[] path, long scid) {}
406406
@Override public long channel_penalty_msat(long short_channel_id, NodeId source, NodeId target, ChannelUsage usage) { return 0; }
407407
@Override public void payment_path_successful(RouteHop[] path) {}
408+
@Override public void probe_failed(RouteHop[] path, long short_channel_id) { assert false; }
409+
@Override public void probe_successful(RouteHop[] path) { assert false; }
408410
@Override public byte[] write() { assert false; return null; }
409411
})), logger, EventHandler.new_impl(new EventHandler.EventHandlerInterface() {
410412
@Override public void handle_event(Event event) {
@@ -525,6 +527,8 @@ public Result_RouteLightningErrorZ find_route(byte[] payer, RouteParameters para
525527
@Override public long channel_penalty_msat(long short_channel_id, NodeId source, NodeId target, ChannelUsage usage) { return 0; }
526528
@Override public void payment_path_failed(RouteHop[] path, long scid) {}
527529
@Override public void payment_path_successful(RouteHop[] path) {}
530+
@Override public void probe_failed(RouteHop[] path, long short_channel_id) { assert false; }
531+
@Override public void probe_successful(RouteHop[] path) { assert false; }
528532
@Override public byte[] write() { assert false; return null; }
529533
})), logger, EventHandler.new_impl(new EventHandler.EventHandlerInterface() {
530534
@Override public void handle_event(Event event) {
@@ -855,7 +859,7 @@ TestState do_test_message_handler() throws InterruptedException {
855859
InvoiceFeatures invoice_features = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.features();
856860
RouteHint[] route_hints = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.route_hints();
857861

858-
PaymentParameters payee = PaymentParameters.of(peer2.node_id, invoice_features, route_hints, Option_u64Z.none(), 6*24*14, (byte)1);
862+
PaymentParameters payee = PaymentParameters.of(peer2.node_id, invoice_features, route_hints, Option_u64Z.none(), 6*24*14, (byte)1, (byte)2, new long[0]);
859863
RouteParameters route_params = RouteParameters.of(payee, 10000000, 42);
860864
Result_RouteLightningErrorZ route_res = UtilMethods.find_route(
861865
peer1.chan_manager.get_our_node_id(), route_params, peer1.router,
@@ -1087,9 +1091,10 @@ void do_test_message_handler_b(TestState state) throws InterruptedException {
10871091
state.peer1.router.write();
10881092

10891093
// Construct the only Option_Enum::Variant(OpaqueStruct) we have in the codebase as this used to cause double-frees:
1090-
byte[] serd = new byte[] {(byte)0xd9,(byte)0x77,(byte)0xcb,(byte)0x9b,(byte)0x53,(byte)0xd9,(byte)0x3a,(byte)0x6f,(byte)0xf6,(byte)0x4b,(byte)0xb5,(byte)0xf1,(byte)0xe1,(byte)0x58,(byte)0xb4,(byte)0x09,(byte)0x4b,(byte)0x66,(byte)0xe7,(byte)0x98,(byte)0xfb,(byte)0x12,(byte)0x91,(byte)0x11,(byte)0x68,(byte)0xa3,(byte)0xcc,(byte)0xdf,(byte)0x80,(byte)0xa8,(byte)0x30,(byte)0x96,(byte)0x34,(byte)0x0a,(byte)0x6a,(byte)0x95,(byte)0xda,(byte)0x0a,(byte)0xe8,(byte)0xd9,(byte)0xf7,(byte)0x76,(byte)0x52,(byte)0x8e,(byte)0xec,(byte)0xdb,(byte)0xb7,(byte)0x47,(byte)0xeb,(byte)0x6b,(byte)0x54,(byte)0x54,(byte)0x95,(byte)0xa4,(byte)0x31,(byte)0x9e,(byte)0xd5,(byte)0x37,(byte)0x8e,(byte)0x35,(byte)0xb2,(byte)0x1e,(byte)0x07,(byte)0x3a,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x19,(byte)0xd6,(byte)0x68,(byte)0x9c,(byte)0x08,(byte)0x5a,(byte)0xe1,(byte)0x65,(byte)0x83,(byte)0x1e,(byte)0x93,(byte)0x4f,(byte)0xf7,(byte)0x63,(byte)0xae,(byte)0x46,(byte)0xa2,(byte)0xa6,(byte)0xc1,(byte)0x72,(byte)0xb3,(byte)0xf1,(byte)0xb6,(byte)0x0a,(byte)0x8c,(byte)0xe2,(byte)0x6f,(byte)0x00,(byte)0x08,(byte)0x3a,(byte)0x84,(byte)0x00,(byte)0x00,(byte)0x03,(byte)0x4d,(byte)0x01,(byte)0x34,(byte)0x13,(byte)0xa7,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x90,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x0f,(byte)0x42,(byte)0x40,(byte)0x00,(byte)0x00,(byte)0x27,(byte)0x10,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x14,};
1094+
byte[] serd = new byte[] {(byte)0xd9,(byte)0x77,(byte)0xcb,(byte)0x9b,(byte)0x53,(byte)0xd9,(byte)0x3a,(byte)0x6f,(byte)0xf6,(byte)0x4b,(byte)0xb5,(byte)0xf1,(byte)0xe1,(byte)0x58,(byte)0xb4,(byte)0x09,(byte)0x4b,(byte)0x66,(byte)0xe7,(byte)0x98,(byte)0xfb,(byte)0x12,(byte)0x91,(byte)0x11,(byte)0x68,(byte)0xa3,(byte)0xcc,(byte)0xdf,(byte)0x80,(byte)0xa8,(byte)0x30,(byte)0x96,(byte)0x34,(byte)0x0a,(byte)0x6a,(byte)0x95,(byte)0xda,(byte)0x0a,(byte)0xe8,(byte)0xd9,(byte)0xf7,(byte)0x76,(byte)0x52,(byte)0x8e,(byte)0xec,(byte)0xdb,(byte)0xb7,(byte)0x47,(byte)0xeb,(byte)0x6b,(byte)0x54,(byte)0x54,(byte)0x95,(byte)0xa4,(byte)0x31,(byte)0x9e,(byte)0xd5,(byte)0x37,(byte)0x8e,(byte)0x35,(byte)0xb2,(byte)0x1e,(byte)0x07,(byte)0x3a,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x01,(byte)0x19,(byte)0xd6,(byte)0x68,(byte)0x9c,(byte)0x08,(byte)0x5a,(byte)0xe1,(byte)0x65,(byte)0x83,(byte)0x1e,(byte)0x93,(byte)0x4f,(byte)0xf7,(byte)0x63,(byte)0xae,(byte)0x46,(byte)0xa2,(byte)0xa6,(byte)0xc1,(byte)0x72,(byte)0xb3,(byte)0xf1,(byte)0xb6,(byte)0x0a,(byte)0x8c,(byte)0xe2,(byte)0x6f,(byte)0x00,(byte)0x08,(byte)0x3a,(byte)0x84,(byte)0x00,(byte)0x00,(byte)0x03,(byte)0x4d,(byte)0x01,(byte)0x34,(byte)0x13,(byte)0xa7,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x90,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x0f,(byte)0x42,(byte)0x40,(byte)0x00,(byte)0x00,(byte)0x27,(byte)0x10,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x14,(byte)0xde,(byte)0xad,(byte)0xbe,(byte)0xef,(byte)0x42,(byte)0x42,(byte)0x42,(byte)0x42};
10911095
Result_ChannelUpdateDecodeErrorZ upd_msg = ChannelUpdate.read(serd);
10921096
assert upd_msg instanceof Result_ChannelUpdateDecodeErrorZ.Result_ChannelUpdateDecodeErrorZ_OK;
1097+
assert ((Result_ChannelUpdateDecodeErrorZ.Result_ChannelUpdateDecodeErrorZ_OK) upd_msg).res.get_contents().get_htlc_maximum_msat() == 0xdeadbeef42424242L;
10931098
Option_NetworkUpdateZ upd = Option_NetworkUpdateZ.some(NetworkUpdate.channel_update_message(((Result_ChannelUpdateDecodeErrorZ.Result_ChannelUpdateDecodeErrorZ_OK) upd_msg).res));
10941099
}
10951100

src/test/java/org/ldk/PeerTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ public long[] release_pending_monitor_events() {
8585
long funding_info = bindings.ChannelMonitor_get_funding_txo(mon);
8686
long funding_txo = bindings.C2Tuple_OutPointScriptZ_get_a(funding_info);
8787
long[] mon_events = bindings.ChannelMonitor_get_and_clear_pending_monitor_events(mon);
88-
long funding_mon_tuple = bindings.C2Tuple_OutPointCVec_MonitorEventZZ_new(funding_txo, mon_events);
88+
byte[] counterparty_pk = bindings.ChannelMonitor_get_counterparty_node_id(mon);
89+
long funding_mon_tuple = bindings.C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(funding_txo, mon_events, counterparty_pk);
8990
bindings.C2Tuple_OutPointScriptZ_free(funding_info);
9091
return new long[] {funding_mon_tuple};
9192
}
@@ -317,7 +318,7 @@ public long send_data(byte[] data, boolean resume_read) {
317318

318319
long no_u64 = bindings.COption_u64Z_none();
319320
long invoice_features = bindings.InvoiceFeatures_known();
320-
long payee = bindings.PaymentParameters_new(peer2.node_id, invoice_features, new long[0], no_u64, 6*24*14, (byte)1);
321+
long payee = bindings.PaymentParameters_new(peer2.node_id, invoice_features, new long[0], no_u64, 6*24*14, (byte)1, (byte)1, new long[0]);
321322
bindings.InvoiceFeatures_free(invoice_features);
322323
bindings.COption_u64Z_free(no_u64);
323324
long route_params = bindings.RouteParameters_new(payee, 1000, 42);

0 commit comments

Comments
 (0)