]> git.bitcoin.ninja Git - ldk-java/commitdiff
Update tests for latest upstream API, sadly disabling the Sign wrapper test
authorMatt Corallo <git@bluematt.me>
Fri, 16 Apr 2021 00:38:28 +0000 (00:38 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 16 Apr 2021 00:44:11 +0000 (00:44 +0000)
src/main/java/org/ldk/batteries/ChannelManagerConstructor.java
src/test/java/org/ldk/HumanObjectPeerTest.java
src/test/java/org/ldk/PeerTest.java

index 43bea0559b5bfeb045c66361b0916f08e35f390c..61bec8e3cdb0e37f82ffd2b4099254799ae8ea76 100644 (file)
@@ -81,7 +81,8 @@ public class ChannelManagerConstructor {
         channel_monitors = new TwoTuple[0];
         channel_manager_latest_block_hash = null;
         this.chain_monitor = chain_monitor;
-        channel_manager = ChannelManager.constructor_new(fee_estimator, chain_monitor.as_Watch(), tx_broadcaster, logger, keys_interface, config, network, current_blockchain_tip_hash, current_blockchain_tip_height);
+        BestBlock block = BestBlock.constructor_new(current_blockchain_tip_hash, current_blockchain_tip_height);
+        channel_manager = ChannelManager.constructor_new(fee_estimator, chain_monitor.as_Watch(), tx_broadcaster, logger, keys_interface, config, network, block);
     }
 
     /**
@@ -118,6 +119,7 @@ public class ChannelManagerConstructor {
                     need_persist = true;
                 }
                 events = this.chain_monitor.as_EventsProvider().get_and_clear_pending_events();
+
                 if (events.length != 0) {
                     persister.handle_events(events);
                     need_persist = true;
@@ -129,7 +131,7 @@ public class ChannelManagerConstructor {
                     return;
                 }
                 if (lastTimerTick < System.currentTimeMillis() - 60 * 1000) {
-                    this.channel_manager.timer_chan_freshness_every_min();
+                    this.channel_manager.timer_tick_occurred();
                     lastTimerTick = System.currentTimeMillis();
                 }
             }
index 175a90166ce18a53f8a4edcaef827053fcc36eac..bd4510cae58db60e5ecec25e97e41c2ecb686284 100644 (file)
@@ -43,7 +43,8 @@ class HumanObjectPeerTestInstance {
                 @Override
                 public Sign get_channel_signer(boolean inbound, long channel_value_satoshis) {
                     Sign underlying_ck = underlying_if.get_channel_signer(inbound, channel_value_satoshis);
-                    Sign.SignInterface si = new Sign.SignInterface() {
+                    // TODO: Expose the underlying signer from a Sign
+                    /*BaseSign.BaseSignInterface si = new BaseSign.BaseSignInterface() {
                         @Override
                         public byte[] get_per_commitment_point(long idx) {
                             return underlying_ck.get_per_commitment_point(idx);
@@ -98,12 +99,13 @@ class HumanObjectPeerTestInstance {
                         public byte[] write() {
                             return underlying_ck.write();
                         }
-                    };
-                    Sign resp = Sign.new_impl(si, underlying_ck.get_pubkeys());
-                    must_free_objs.add(new WeakReference<>(si));
-                    must_free_objs.add(new WeakReference<>(resp));
+                    };*/
+                    //Sign resp = Sign.new_impl(si, underlying_ck.get_pubkeys());
+                    //must_free_objs.add(new WeakReference<>(si));
+                    //must_free_objs.add(new WeakReference<>(resp));
                     must_free_objs.add(new WeakReference<>(underlying_ck));
-                    return resp;
+                    //return resp;
+                    return underlying_ck;
                 }
 
                 @Override
@@ -270,7 +272,7 @@ class HumanObjectPeerTestInstance {
         }
         Peer(byte seed) {
             this(null, seed);
-            this.chan_manager = ChannelManager.constructor_new(FeeEstimator.new_impl(confirmation_target -> 0), chain_watch, tx_broadcaster, logger, this.keys_interface, UserConfig.constructor_default(), LDKNetwork.LDKNetwork_Bitcoin, new byte[32], 0);
+            this.chan_manager = ChannelManager.constructor_new(FeeEstimator.new_impl(confirmation_target -> 0), chain_watch, tx_broadcaster, logger, this.keys_interface, UserConfig.constructor_default(), LDKNetwork.LDKNetwork_Bitcoin, BestBlock.constructor_new(new byte[32], 0));
             this.node_id = chan_manager.get_our_node_id();
             this.chan_manager_events = chan_manager.as_EventsProvider();
 
@@ -522,7 +524,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(10000), new Script(funding_spk));
-        Result_NoneAPIErrorZ funding_res = peer1.chan_manager.funding_transaction_generated(chan_id, funding.bitcoinSerialize(), (short) 0);
+        Result_NoneAPIErrorZ funding_res = peer1.chan_manager.funding_transaction_generated(chan_id, funding.bitcoinSerialize());
         assert funding_res instanceof Result_NoneAPIErrorZ.Result_NoneAPIErrorZ_OK;
         wait_events_processed(peer1, peer2);
 
index 3373c0376221b947c98f8933061ea76e32c845fe..2de927c71dcbf9913c21492291ba9806d49eaac8 100644 (file)
@@ -3,9 +3,8 @@ package org.ldk;
 import org.bitcoinj.core.*;
 import org.bitcoinj.script.Script;
 import org.junit.jupiter.api.Test;
+import org.ldk.enums.LDKNetwork;
 import org.ldk.impl.bindings;
-import org.ldk.enums.*;
-import org.ldk.structs.Result_NoneChannelMonitorUpdateErrZ;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -93,7 +92,7 @@ public class PeerTest {
             this.keys = bindings.KeysManager_new(key_seed, System.currentTimeMillis() / 1000, (int)(System.currentTimeMillis() * 1000) & 0xffffffff);
             this.keys_interface = bindings.KeysManager_as_KeysInterface(keys);
             this.config = bindings.UserConfig_default();
-            long params = bindings.ChainParameters_new(LDKNetwork.LDKNetwork_Bitcoin, new byte[32], 0);
+            long params = bindings.ChainParameters_new(LDKNetwork.LDKNetwork_Bitcoin, bindings.BestBlock_new(new byte[32], 0));
             this.chan_manager = bindings.ChannelManager_new(fee_estimator, chain_monitor, tx_broadcaster, logger, keys_interface, config, params);
             this.node_id = bindings.ChannelManager_get_our_node_id(chan_manager);
             this.chan_manager_events = bindings.ChannelManager_as_EventsProvider(chan_manager);
@@ -238,7 +237,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(), (short)0);
+        bindings.ChannelManager_funding_transaction_generated(peer1.chan_manager, chan_id, funding.bitcoinSerialize());
 
         bindings.PeerManager_process_events(peer1.peer_manager);
         while (!list.isEmpty()) { list.poll().join(); }