]> git.bitcoin.ninja Git - ldk-java/commitdiff
update tests for new upstream and check null result 2021-08-nullable-fixes
authorMatt Corallo <git@bluematt.me>
Thu, 5 Aug 2021 13:53:04 +0000 (13:53 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 5 Aug 2021 13:53:04 +0000 (13:53 +0000)
src/test/java/org/ldk/HumanObjectPeerTest.java
src/test/java/org/ldk/PeerTest.java

index 79085c5362654b7913a381d0c1af24fa5090e85b..bdfaee3f0472d095c941f9d13c3df6f60d867029 100644 (file)
@@ -615,6 +615,10 @@ class HumanObjectPeerTestInstance {
         Result_NoneAPIErrorZ cc_res = peer1.chan_manager.create_channel(peer2.node_id, 10000, 1000, 42, null);
         assert cc_res instanceof Result_NoneAPIErrorZ.Result_NoneAPIErrorZ_OK;
 
+        // Previously, this was a SEGFAULT instead of get_funding_txo() returning null.
+        ChannelDetails pre_funding_chan = peer1.chan_manager.list_channels()[0];
+        assert pre_funding_chan.get_funding_txo() == null;
+
         Event[] events = peer1.get_manager_events(1, peer1, peer2);
         assert events[0] instanceof Event.FundingGenerationReady;
         assert ((Event.FundingGenerationReady) events[0]).channel_value_satoshis == 10000;
@@ -758,7 +762,8 @@ class HumanObjectPeerTestInstance {
 
         events = state.peer2.get_manager_events(1, state.peer1, state.peer2);
         assert events[0] instanceof Event.PaymentReceived;
-        byte[] payment_preimage = ((Event.PaymentReceived)events[0]).payment_preimage;
+        assert ((Event.PaymentReceived)events[0]).purpose instanceof PaymentPurpose.InvoicePayment;
+        byte[] payment_preimage = ((PaymentPurpose.InvoicePayment)((Event.PaymentReceived)events[0]).purpose).payment_preimage;
         assert !Arrays.equals(payment_preimage, new byte[32]);
         state.peer2.chan_manager.claim_funds(payment_preimage);
 
index a05c899f5e12fa8077e0199c26c08ad18e171274..de96a8bfa0aa223626b15e436d7523cae3b04dbf 100644 (file)
@@ -302,7 +302,9 @@ public class PeerTest {
         assert events.size() == 1;
         bindings.LDKEvent payment_recvd = bindings.LDKEvent_ref_from_ptr(events.get(0));
         assert payment_recvd instanceof bindings.LDKEvent.PaymentReceived;
-        assert bindings.ChannelManager_claim_funds(peer2.chan_manager, ((bindings.LDKEvent.PaymentReceived) payment_recvd).payment_preimage);
+        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.Event_free(events.remove(0));
 
         deliver_peer_messages(list, peer1.peer_manager, peer2.peer_manager);