X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Fldk%2FHumanObjectPeerTest.java;h=3051239816e5bce07ebac9432cb285b18f1731eb;hb=293bcee787de3eb181b82175a1784a4ef311e012;hp=e1a2eacb104e757ab333f0b04cc9cfc79637940c;hpb=f3e3ee84e51d947c0057773b2c672bb1a5470ba7;p=ldk-java diff --git a/src/test/java/org/ldk/HumanObjectPeerTest.java b/src/test/java/org/ldk/HumanObjectPeerTest.java index e1a2eacb..30512398 100644 --- a/src/test/java/org/ldk/HumanObjectPeerTest.java +++ b/src/test/java/org/ldk/HumanObjectPeerTest.java @@ -27,6 +27,7 @@ class HumanObjectPeerTestInstance { private final boolean use_ignore_handler; private final boolean use_chan_manager_constructor; private final boolean use_invoice_payer; + TxOut gossip_txout = null; HumanObjectPeerTestInstance(boolean nice_close, boolean use_km_wrapper, boolean use_manual_watch, boolean reload_peers, boolean break_cross_peer_refs, boolean use_nio_peer_handler, boolean use_filter, boolean use_ignore_handler, boolean use_chan_manager_constructor, boolean use_invoice_payer) { this.nice_close = nice_close; @@ -168,6 +169,14 @@ class HumanObjectPeerTestInstance { return watch; } + UserConfig get_config() { + ChannelHandshakeConfig channel_config = ChannelHandshakeConfig.with_default(); + channel_config.set_announced_channel(true); + UserConfig config = UserConfig.with_default(); + config.set_channel_handshake_config(channel_config); + return config; + } + NioPeerHandler nio_peer_handler; short nio_port; final byte seed; @@ -340,15 +349,8 @@ class HumanObjectPeerTestInstance { } } private void setup_route_handler() { - this.route_handler = P2PGossipSync.of(this.router, Option_AccessZ.some(Access.new_impl(new Access.AccessInterface() { - @Override - public Result_TxOutAccessErrorZ get_utxo(byte[] genesis_hash, long short_channel_id) { - // We don't exchange any gossip, so should never actually get called, but providing a Some(Access) - // is a good test of our Option free'ing, which used to be broken and relies on a dirty hack. - assert false; - return Result_TxOutAccessErrorZ.err(AccessError.LDKAccessError_UnknownTx); - } - })), this.logger); + this.route_handler = P2PGossipSync.of(this.router, + Option_AccessZ.some(Access.new_impl((genesis_hash, short_channel_id) -> Result_TxOutAccessErrorZ.ok(gossip_txout))), this.logger); } Peer(byte seed) { this(null, seed); @@ -357,10 +359,10 @@ class HumanObjectPeerTestInstance { if (use_chan_manager_constructor) { if (use_ignore_handler) { - this.constructor = new ChannelManagerConstructor(Network.LDKNetwork_Bitcoin, UserConfig.with_default(), new byte[32], 0, + this.constructor = new ChannelManagerConstructor(Network.LDKNetwork_Bitcoin, get_config(), new byte[32], 0, this.keys_interface, this.fee_estimator, this.chain_monitor, null, this.tx_broadcaster, this.logger); } else { - this.constructor = new ChannelManagerConstructor(Network.LDKNetwork_Bitcoin, UserConfig.with_default(), new byte[32], 0, + this.constructor = new ChannelManagerConstructor(Network.LDKNetwork_Bitcoin, get_config(), new byte[32], 0, this.keys_interface, this.fee_estimator, this.chain_monitor, this.router, this.tx_broadcaster, this.logger); } ProbabilisticScoringParameters params = ProbabilisticScoringParameters.with_default(); @@ -387,7 +389,7 @@ class HumanObjectPeerTestInstance { must_free_objs.add(new WeakReference<>(this.chan_manager)); } else { ChainParameters params = ChainParameters.of(Network.LDKNetwork_Bitcoin, BestBlock.of(new byte[32], 0)); - this.chan_manager = ChannelManager.of(this.fee_estimator, chain_watch, tx_broadcaster, logger, this.keys_interface, UserConfig.with_default(), params); + this.chan_manager = ChannelManager.of(this.fee_estimator, chain_watch, tx_broadcaster, logger, this.keys_interface, get_config(), params); byte[] random_data = keys_interface.get_secure_random_bytes(); Result_SecretKeyNoneZ node_secret = keys_interface.get_node_secret(Recipient.LDKRecipient_Node); assert node_secret.is_ok(); @@ -434,11 +436,11 @@ class HumanObjectPeerTestInstance { filter_nullable = ((Option_FilterZ.Some) this.filter).some; } if (use_ignore_handler) { - this.constructor = new ChannelManagerConstructor(serialized, monitors, UserConfig.with_default(), + this.constructor = new ChannelManagerConstructor(serialized, monitors, get_config(), this.keys_interface, this.fee_estimator, this.chain_monitor, filter_nullable, null, this.tx_broadcaster, this.logger); } else { - this.constructor = new ChannelManagerConstructor(serialized, monitors, UserConfig.with_default(), + this.constructor = new ChannelManagerConstructor(serialized, monitors, get_config(), this.keys_interface, this.fee_estimator, this.chain_monitor, filter_nullable, serialized_router, this.tx_broadcaster, this.logger); try { @@ -446,7 +448,7 @@ class HumanObjectPeerTestInstance { byte[][] monitors_dupd = new byte[2][]; monitors_dupd[0] = monitors[0]; monitors_dupd[1] = monitors[0]; - ChannelManagerConstructor constr = this.constructor = new ChannelManagerConstructor(serialized, monitors_dupd, UserConfig.with_default(), + ChannelManagerConstructor constr = this.constructor = new ChannelManagerConstructor(serialized, monitors_dupd, get_config(), this.keys_interface, this.fee_estimator, this.chain_monitor, filter_nullable, null, this.tx_broadcaster, this.logger); assert false; @@ -497,7 +499,7 @@ class HumanObjectPeerTestInstance { } byte[] serialized = orig.chan_manager.write(); Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ read_res = - UtilMethods.C2Tuple_BlockHashChannelManagerZ_read(serialized, this.keys_interface, this.fee_estimator, this.chain_watch, this.tx_broadcaster, this.logger, UserConfig.with_default(), monitors); + UtilMethods.C2Tuple_BlockHashChannelManagerZ_read(serialized, this.keys_interface, this.fee_estimator, this.chain_watch, this.tx_broadcaster, this.logger, get_config(), monitors); assert read_res instanceof Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK; this.chan_manager = ((Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK) read_res).res.get_b(); this.chain_watch.watch_channel(monitors[0].get_funding_txo().get_a(), monitors[0]); @@ -792,6 +794,8 @@ class HumanObjectPeerTestInstance { Result_NoneAPIErrorZ funding_res = peer1.chan_manager.funding_transaction_generated(chan_id, peer2.node_id, funding.bitcoinSerialize()); assert funding_res instanceof Result_NoneAPIErrorZ.Result_NoneAPIErrorZ_OK; + gossip_txout = new TxOut(100000, funding_spk); + maybe_exchange_peer_messages(peer1, peer2); synchronized (peer1.broadcast_set) { while (peer1.broadcast_set.size() != 1) { @@ -851,7 +855,7 @@ class HumanObjectPeerTestInstance { InvoiceFeatures invoice_features = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.features(); RouteHint[] route_hints = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.route_hints(); - PaymentParameters payee = PaymentParameters.of(peer2.node_id, invoice_features, route_hints, Option_u64Z.none(), 6*24*14); + PaymentParameters payee = PaymentParameters.of(peer2.node_id, invoice_features, route_hints, Option_u64Z.none(), 6*24*14, (byte)1); RouteParameters route_params = RouteParameters.of(payee, 10000000, 42); Result_RouteLightningErrorZ route_res = UtilMethods.find_route( peer1.chan_manager.get_our_node_id(), route_params, peer1.router, @@ -970,7 +974,7 @@ class HumanObjectPeerTestInstance { while (state.peer2.broadcast_set.size() != 1) state.peer2.broadcast_set.wait(); } } else { - state.peer1.chan_manager.force_close_all_channels(); + state.peer1.chan_manager.force_close_all_channels_broadcasting_latest_txn(); maybe_exchange_peer_messages(state.peer1, state.peer2); synchronized (state.peer1.broadcast_set) { while (state.peer1.broadcast_set.size() != 1) state.peer1.broadcast_set.wait();