]> git.bitcoin.ninja Git - ldk-java/commitdiff
Update tests to use Listen interface and for latest upstream
authorMatt Corallo <git@bluematt.me>
Sun, 21 Mar 2021 17:02:03 +0000 (13:02 -0400)
committerMatt Corallo <git@bluematt.me>
Sun, 21 Mar 2021 17:02:03 +0000 (13:02 -0400)
src/test/java/org/ldk/HumanObjectPeerTest.java
src/test/java/org/ldk/ManualMsgHandlingPeerTest.java
src/test/java/org/ldk/PeerTest.java

index cc67cfe877005cc9f75d7ee87a08293c509e98bf..2812e55d06975af75b4f6930b391939bcb7fa829 100644 (file)
@@ -267,7 +267,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], 1);
+            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.node_id = chan_manager.get_our_node_id();
             this.chan_manager_events = chan_manager.as_EventsProvider();
 
@@ -351,7 +351,7 @@ class HumanObjectPeerTestInstance {
                 txn = new TwoTuple[]{txp};
             } else
                 txn = new TwoTuple[0];
-            chan_manager.block_connected(header, txn, height);
+            chan_manager.as_Listen().block_connected(b.bitcoinSerialize(), height);
             if (chain_monitor != null) {
                 chain_monitor.block_connected(header, txn, height);
             } else {
@@ -656,7 +656,7 @@ class HumanObjectPeerTestInstance {
             Transaction tx = new Transaction(bitcoinj_net, state.peer1.broadcast_set.getFirst());
             Block b = new Block(bitcoinj_net, 2, state.best_blockhash, Sha256Hash.ZERO_HASH, 42, 0, 0,
                     Arrays.asList(new Transaction[]{tx}));
-            TwoTuple<byte[], TwoTuple<Integer, TxOut>[]>[] watch_outputs = state.peer2.connect_block(b, 1, 1);
+            TwoTuple<byte[], TwoTuple<Integer, TxOut>[]>[] watch_outputs = state.peer2.connect_block(b, 10, 1);
             if (watch_outputs != null) { // We only process watch_outputs manually when we use a manually-build Watch impl
                 assert watch_outputs.length == 1;
                 assert Arrays.equals(watch_outputs[0].a, tx.getTxId().getReversedBytes());
index c1d6a5e3d12c51cf5c068e8a694b99316fb7ef38..12fa620e13374da23a0481e7eb6a0a0d1af03e27 100644 (file)
@@ -101,6 +101,11 @@ public class ManualMsgHandlingPeerTest {
 
             }
 
+            @Override
+            public void handle_channel_update(byte[] their_node_id, long msg) {
+
+            }
+
             @Override
             public void handle_error(byte[] their_node_id, long msg) {
 
index bc83c95b64cb86cbdff7889c4724f0e3319837d8..97093333473684ccab176ab404fbf1ca0960ba98 100644 (file)
@@ -93,7 +93,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], 1);
+            long params = bindings.ChainParameters_new(LDKNetwork.LDKNetwork_Bitcoin, 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);
@@ -109,19 +109,17 @@ public class PeerTest {
         }
 
         void connect_block(Block b, Transaction t, int height) {
-            byte[] header = Arrays.copyOfRange(b.bitcoinSerialize(), 0, 80);
-            long[] txn;
-            if (t != null)
-                txn = new long[]{bindings.C2Tuple_usizeTransactionZ_new(1, t.bitcoinSerialize())};
-            else
-                txn = new long[0];
-            bindings.ChannelManager_block_connected(chan_manager, header, txn, height);
+            long listen = bindings.ChannelManager_as_Listen(chan_manager);
+            bindings.Listen_block_connected(listen, b.bitcoinSerialize(), height);
+            bindings.Listen_free(listen);
             synchronized (monitors) {
                 for (Long mon : monitors.values()) {
+                    long[] txn;
                     if (t != null)
                         txn = new long[]{bindings.C2Tuple_usizeTransactionZ_new(1, t.bitcoinSerialize())};
                     else
                         txn = new long[0];
+                    byte[] header = Arrays.copyOfRange(b.bitcoinSerialize(), 0, 80);
                     long[] ret = bindings.ChannelMonitor_block_connected(mon, header, txn, height, tx_broadcaster, fee_estimator, logger);
                     for (long r : ret) {
                         bindings.C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(r);
@@ -260,7 +258,7 @@ public class PeerTest {
         peer2.connect_block(b, funding, 1);
 
         for (int height = 2; height < 10; height++) {
-            b = new Block(NetworkParameters.fromID(NetworkParameters.ID_MAINNET), 2, b.getHash(), Sha256Hash.ZERO_HASH, 42, 0, 0, Arrays.asList(new Transaction[]{funding}));
+            b = new Block(NetworkParameters.fromID(NetworkParameters.ID_MAINNET), 2, b.getHash(), Sha256Hash.ZERO_HASH, 42, 0, 0, Arrays.asList(new Transaction[0]));
             peer1.connect_block(b, null, height);
             peer2.connect_block(b, null, height);
         }