-
Notifications
You must be signed in to change notification settings - Fork 377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor channelmanager tests into more appropriate submodule tests #2977
base: main
Are you sure you want to change the base?
Refactor channelmanager tests into more appropriate submodule tests #2977
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #2977 +/- ##
==========================================
- Coverage 89.82% 89.77% -0.06%
==========================================
Files 116 119 +3
Lines 96466 96480 +14
Branches 96466 96480 +14
==========================================
- Hits 86655 86615 -40
- Misses 7264 7304 +40
- Partials 2547 2561 +14 ☔ View full report in Codecov by Sentry. |
8eda436
to
388e6bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that you'll probably have to rebase this after #2731 adds a new test.
388e6bc
to
e75b405
Compare
Will take care of that for sure 👍 |
e75b405
to
30dcf01
Compare
@TheBlueMatt updated changes from main after the merge of #2731 Took care of added test |
30dcf01
to
f585d35
Compare
e50313f
to
77fc367
Compare
#[test] | ||
fn bad_inbound_payment_hash() { | ||
// Add coverage for checking that a user-provided payment hash matches the payment secret. | ||
let chanmon_cfgs = create_chanmon_cfgs(2); | ||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs); | ||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]); | ||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs); | ||
node_cfgs[0].keys_manager.get_inbound_payment_key_material(); | ||
|
||
let highest_seen_timestamp = bitcoin::blockdata::constants::genesis_block(bitcoin::Network::Testnet).header.time; | ||
let node_signer = node_cfgs[0].keys_manager; | ||
let inbound_pmt_key_material = node_signer.get_inbound_payment_key_material(); | ||
let expanded_inbound_key = inbound_payment::ExpandedKey::new(&inbound_pmt_key_material); | ||
|
||
let (_, payment_hash, payment_secret) = get_payment_preimage_hash!(&nodes[0]); | ||
let payment_data = msgs::FinalOnionHopData { | ||
payment_secret, | ||
total_msat: 100_000, | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TheBlueMatt I have refactored this test, can you go through this whether this behaves as expected ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically I tried to untie the dependency between the channelmanagers internal state, let me know if there is better way
// Should we drop this check ? | ||
// Assert that ChannelUpdate message has been added to node[0] pending broadcast messages | ||
// let pending_broadcast_messages = nodes[0].node.get_and_clear_pending_msg_events(); | ||
// assert_eq!(pending_broadcast_messages.len(), 2); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TheBlueMatt I had to remove this check, because this effects the at the 703-704 and fails
I am not able to figure out the reason why this is happening
This might need a rebase by now - sorry! |
Thanks, will rebase with main. |
If you do the move-only parts in a separate move-only commit it'll be pretty easy to see with |
77fc367
to
e4dfd72
Compare
Rebased with main |
e4dfd72
to
162ddea
Compare
* Few tests were dependent on channelmanagers internal state, refactored that them to publicly visible apis
162ddea
to
2e4f552
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems close, thanks for tackling this!
use crate::ln::msgs::ChannelMessageHandler; | ||
use crate::ln::types::ChannelId; | ||
use crate::ln::functional_test_utils::*; | ||
use crate::ln::msgs::ErrorAction; | ||
use crate::ln::{functional_test_utils::*, ChannelId}; | ||
use crate::ln::msgs::ChannelMessageHandler; | ||
use crate::prelude::*; | ||
use crate::util::config::ChannelConfigUpdate; | ||
use crate::util::errors::APIError; | ||
use crate::util::config::ChannelConfigUpdate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this diff belongs in the previous commit?
@@ -663,7 +663,7 @@ fn test_channel_update_cached() { | |||
|
|||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1); | |||
|
|||
nodes[0].node.force_close_channel_with_peer(&chan.2, &nodes[1].node.get_our_node_id(), None, true).unwrap(); | |||
let _ = nodes[0].node.force_close_broadcasting_latest_txn(&chan.2, &nodes[1].node.get_our_node_id()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep the unwrap, we still want to make sure this call doesn't error.
use crate::ln::msgs::ChannelMessageHandler; | ||
use crate::ln::msgs::ErrorAction; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: combine these imports
use crate::events::{Event, MessageSendEvent, MessageSendEventsProvider}; | ||
use crate::ln::msgs::ChannelMessageHandler; | ||
use crate::ln::msgs::ErrorAction; | ||
use crate::ln::{functional_test_utils::*, ChannelId}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: split this into two imports and alphabetize them. This should remove some unnecessary diff in the next commit too
use bitcoin::hashes::Hash; | ||
use crate::ln::channelmanager::{PaymentId, PaymentSendFailure, RecipientOnionFields}; | ||
use crate::ln::functional_test_utils::*; | ||
use crate::util::errors::APIError; | ||
use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey}; | ||
use crate::events::{Event, MessageSendEvent, MessageSendEventsProvider, ClosureReason}; | ||
use crate::ln::channelmanager; | ||
use crate::ln::ChannelId; | ||
use crate::ln::msgs::{self}; | ||
use crate::ln::msgs::ChannelMessageHandler; | ||
use crate::prelude::*; | ||
use crate::util::config::ChannelConfig; | ||
use crate::sign::EntropySource; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: alphabetize these imports. I think if you copy this into the rust playground and run rustfmt
it will do it for you. Please check the other new test files in this commit to see if they need it too.
Looks like this needs rebase, sadly. |
oops..., I will try to complete this PR after this rebase |
Fix #2958
Previously
channelmanager
had a single test module withintchannelmanager.rs
This changes introduces moving refactoring
23
tests ofchannelmanager
into following test groupsGroup 1: Key Send and Payment Verification
Group 2: Channel Management and Limits
Group 3: Anchor Channel and Configuration Tests