From: Matt Corallo Date: Sun, 21 Mar 2021 17:02:03 +0000 (-0400) Subject: Update tests to use Listen interface and for latest upstream X-Git-Tag: v0.0.98~7^2~6 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=b093ef696a8c676532527fcebe419a8d03094e09;p=ldk-java Update tests to use Listen interface and for latest upstream --- diff --git a/src/test/java/org/ldk/HumanObjectPeerTest.java b/src/test/java/org/ldk/HumanObjectPeerTest.java index cc67cfe8..2812e55d 100644 --- a/src/test/java/org/ldk/HumanObjectPeerTest.java +++ b/src/test/java/org/ldk/HumanObjectPeerTest.java @@ -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[]>[] watch_outputs = state.peer2.connect_block(b, 1, 1); + TwoTuple[]>[] 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()); diff --git a/src/test/java/org/ldk/ManualMsgHandlingPeerTest.java b/src/test/java/org/ldk/ManualMsgHandlingPeerTest.java index c1d6a5e3..12fa620e 100644 --- a/src/test/java/org/ldk/ManualMsgHandlingPeerTest.java +++ b/src/test/java/org/ldk/ManualMsgHandlingPeerTest.java @@ -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) { diff --git a/src/test/java/org/ldk/PeerTest.java b/src/test/java/org/ldk/PeerTest.java index bc83c95b..97093333 100644 --- a/src/test/java/org/ldk/PeerTest.java +++ b/src/test/java/org/ldk/PeerTest.java @@ -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); }