Repository navigation
Refactor channelmanager tests into more appropriate submodule tests - #2977
srikanth-iyengar wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
TheBlueMatt
left a comment
There was a problem hiding this comment.
Note that you'll probably have to rebase this after #2731 adds a new test.
Will take care of that for sure 👍 |
|
@TheBlueMatt updated changes from main after the merge of #2731 Took care of added test |
| #[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.
@TheBlueMatt I have refactored this test, can you go through this whether this behaves as expected ?
There was a problem hiding this comment.
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.
@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 |
|
Rebased with main |
* Few tests were dependent on channelmanagers internal state, refactored that them to publicly visible apis
valentinewallace
left a comment
There was a problem hiding this comment.
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.
I think this diff belongs in the previous commit?
| 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.
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.
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.
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.
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 |
|
Hi @TheBlueMatt @valentinewallace, it looks like PR #2977 has been inactive since mid-2024 and has merge conflicts. I would like to take over this task and finish moving the tests. I'll start a fresh PR based on the current main branch to avoid conflict hell. Let me know if that works! |
|
Closing as abandoned, feel free to take a crack at it. |
Fix #2958
Previously
channelmanagerhad a single test module withintchannelmanager.rsThis changes introduces moving refactoring
23tests ofchannelmanagerinto following test groupsGroup 1: Key Send and Payment Verification
Group 2: Channel Management and Limits
Group 3: Anchor Channel and Configuration Tests