From 171d3cd3c70632770b2b14712f1b97e9f373b89b Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 29 Nov 2021 01:05:05 +0000 Subject: [PATCH] Use new is_ok functions for Result checks in hand-written code --- .../java/org/ldk/batteries/NioPeerHandler.java | 2 +- src/test/java/org/ldk/PeerTest.java | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/ldk/batteries/NioPeerHandler.java b/src/main/java/org/ldk/batteries/NioPeerHandler.java index afe728b0..49f60c7f 100644 --- a/src/main/java/org/ldk/batteries/NioPeerHandler.java +++ b/src/main/java/org/ldk/batteries/NioPeerHandler.java @@ -217,7 +217,7 @@ public class NioPeerHandler { buf.get(read_bytes, 0, read); long read_result_pointer = bindings.PeerManager_read_event( peer_manager_raw_pointer, peer.descriptor_raw_pointer, read_bytes); - if (bindings.LDKCResult_boolPeerHandleErrorZ_result_ok(read_result_pointer)) { + if (bindings.CResult_boolPeerHandleErrorZ_is_ok(read_result_pointer)) { if (bindings.LDKCResult_boolPeerHandleErrorZ_get_ok(read_result_pointer)) { key.interestOps(key.interestOps() & (~SelectionKey.OP_READ)); } diff --git a/src/test/java/org/ldk/PeerTest.java b/src/test/java/org/ldk/PeerTest.java index 8dc85de0..2aee0784 100644 --- a/src/test/java/org/ldk/PeerTest.java +++ b/src/test/java/org/ldk/PeerTest.java @@ -66,7 +66,7 @@ public class PeerTest { String txid = Arrays.toString(bindings.OutPoint_get_txid(funding_txo)); assert monitors.containsKey(txid); long update_res = bindings.ChannelMonitor_update_monitor(monitors.get(txid), update, tx_broadcaster, fee_estimator, logger); - assert bindings.LDKCResult_NoneMonitorUpdateErrorZ_result_ok(update_res); + assert bindings.CResult_NoneMonitorUpdateErrorZ_is_ok(update_res); bindings.CResult_NoneMonitorUpdateErrorZ_free(update_res); } bindings.OutPoint_free(funding_txo); @@ -165,7 +165,7 @@ public class PeerTest { void do_read_event(ConcurrentLinkedQueue list, long pm, long descriptor, byte[] arr) { Thread thread = new Thread(() -> { long res = bindings.PeerManager_read_event(pm, descriptor, arr); - assert bindings.LDKCResult_boolPeerHandleErrorZ_result_ok(res); + assert bindings.CResult_boolPeerHandleErrorZ_is_ok(res); //assert bindings.deref_bool(bindings.LDKCResult_boolPeerHandleErrorZ_get_inner(res)); bindings.CResult_boolPeerHandleErrorZ_free(res); }); @@ -218,10 +218,10 @@ public class PeerTest { descriptor1.val = bindings.LDKSocketDescriptor_new(sock2); long init_vec = bindings.PeerManager_new_outbound_connection(peer1.peer_manager, peer2.node_id, descriptor1.val); - assert(bindings.LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(init_vec)); + assert(bindings.CResult_CVec_u8ZPeerHandleErrorZ_is_ok(init_vec)); long con_res = bindings.PeerManager_new_inbound_connection(peer2.peer_manager, descriptor2); - assert(bindings.LDKCResult_NonePeerHandleErrorZ_result_ok(con_res)); + assert(bindings.CResult_NonePeerHandleErrorZ_is_ok(con_res)); bindings.CResult_NonePeerHandleErrorZ_free(con_res); do_read_event(list, peer2.peer_manager, descriptor2, bindings.LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(init_vec)); bindings.CResult_CVec_u8ZPeerHandleErrorZ_free(init_vec); @@ -229,7 +229,7 @@ public class PeerTest { deliver_peer_messages(list, peer1.peer_manager, peer2.peer_manager); long cc_res = bindings.ChannelManager_create_channel(peer1.chan_manager, peer2.node_id, 10000, 1000, 42, 0); - assert bindings.LDKCResult_NoneAPIErrorZ_result_ok(cc_res); + assert bindings.CResult_NoneAPIErrorZ_is_ok(cc_res); bindings.CResult_NoneAPIErrorZ_free(cc_res); deliver_peer_messages(list, peer1.peer_manager, peer2.peer_manager); @@ -299,12 +299,12 @@ public class PeerTest { bindings.Scorer_free(scorer); for (long chan : peer1_chans) bindings.ChannelDetails_free(chan); - assert bindings.LDKCResult_RouteLightningErrorZ_result_ok(route); + assert bindings.CResult_RouteLightningErrorZ_is_ok(route); long payment_res = bindings.ChannelManager_send_payment(peer1.chan_manager, bindings.LDKCResult_RouteLightningErrorZ_get_ok(route), bindings.C2Tuple_PaymentHashPaymentSecretZ_get_a(inbound_payment), bindings.C2Tuple_PaymentHashPaymentSecretZ_get_b(inbound_payment)); bindings.CResult_RouteLightningErrorZ_free(route); bindings.C2Tuple_PaymentHashPaymentSecretZ_free(inbound_payment); - assert bindings.LDKCResult_NonePaymentSendFailureZ_result_ok(payment_res); + assert bindings.CResult_NonePaymentSendFailureZ_is_ok(payment_res); bindings.CResult_NonePaymentSendFailureZ_free(payment_res); deliver_peer_messages(list, peer1.peer_manager, peer2.peer_manager); -- 2.39.5