Skip to content

Commit 5dd69f6

Browse files
committed
f fix test + drop missing imports
1 parent 990374a commit 5dd69f6

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

lightning/src/routing/gossip.rs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ use bitcoin::secp256k1;
1616

1717
use bitcoin::hashes::sha256d::Hash as Sha256dHash;
1818
use bitcoin::hashes::Hash;
19-
use bitcoin::blockdata::script::Builder;
2019
use bitcoin::blockdata::transaction::TxOut;
21-
use bitcoin::blockdata::opcodes;
2220
use bitcoin::hash_types::BlockHash;
2321

2422
use chain;
@@ -1834,6 +1832,7 @@ impl ReadOnlyNetworkGraph<'_> {
18341832
#[cfg(test)]
18351833
mod tests {
18361834
use chain;
1835+
use ln::chan_utils::make_funding_redeemscript;
18371836
use ln::PaymentHash;
18381837
use ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
18391838
use routing::gossip::{P2PGossipSync, NetworkGraph, NetworkUpdate, NodeAlias, MAX_EXCESS_BYTES_FOR_RELAY, NodeId, RoutingFees, ChannelUpdateInfo, ChannelInfo, NodeAnnouncementInfo, NodeInfo};
@@ -1851,9 +1850,8 @@ mod tests {
18511850
use bitcoin::hashes::Hash;
18521851
use bitcoin::network::constants::Network;
18531852
use bitcoin::blockdata::constants::genesis_block;
1854-
use bitcoin::blockdata::script::{Builder, Script};
1853+
use bitcoin::blockdata::script::Script;
18551854
use bitcoin::blockdata::transaction::TxOut;
1856-
use bitcoin::blockdata::opcodes;
18571855

18581856
use hex;
18591857

@@ -1942,17 +1940,6 @@ mod tests {
19421940
}
19431941
}
19441942

1945-
fn get_channel_script(secp_ctx: &Secp256k1<secp256k1::All>) -> Script {
1946-
let node_1_btckey = &SecretKey::from_slice(&[40; 32]).unwrap();
1947-
let node_2_btckey = &SecretKey::from_slice(&[39; 32]).unwrap();
1948-
Builder::new().push_opcode(opcodes::all::OP_PUSHNUM_2)
1949-
.push_slice(&PublicKey::from_secret_key(&secp_ctx, node_1_btckey).serialize())
1950-
.push_slice(&PublicKey::from_secret_key(&secp_ctx, node_2_btckey).serialize())
1951-
.push_opcode(opcodes::all::OP_PUSHNUM_2)
1952-
.push_opcode(opcodes::all::OP_CHECKMULTISIG).into_script()
1953-
.to_v0_p2wsh()
1954-
}
1955-
19561943
fn get_signed_channel_update<F: Fn(&mut UnsignedChannelUpdate)>(f: F, node_key: &SecretKey, secp_ctx: &Secp256k1<secp256k1::All>) -> ChannelUpdate {
19571944
let mut unsigned_channel_update = UnsignedChannelUpdate {
19581945
chain_hash: genesis_block(Network::Testnet).header.block_hash(),
@@ -2042,7 +2029,8 @@ mod tests {
20422029
let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
20432030
let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
20442031

2045-
let good_script = get_channel_script(&secp_ctx);
2032+
let good_script = make_funding_redeemscript(&PublicKey::from_secret_key(secp_ctx, &node_1_btckey),
2033+
&PublicKey::from_secret_key(secp_ctx, &node_2_btckey)).to_v0_p2wsh();
20462034
let valid_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
20472035

20482036
// Test if the UTXO lookups were not supported
@@ -2167,7 +2155,9 @@ mod tests {
21672155

21682156
{
21692157
// Announce a channel we will update
2170-
let good_script = get_channel_script(&secp_ctx);
2158+
let good_script = make_funding_redeemscript(&PublicKey::from_secret_key(secp_ctx, &node_1_privkey),
2159+
&PublicKey::from_secret_key(secp_ctx, &node_2_privkey)).to_v0_p2wsh();
2160+
21712161
*chain_source.utxo_ret.lock().unwrap() = Ok(TxOut { value: amount_sats, script_pubkey: good_script.clone() });
21722162

21732163
let valid_channel_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);

0 commit comments

Comments
 (0)