-
Notifications
You must be signed in to change notification settings - Fork 422
Set and relay experimental accountable signal #4232
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
Open
carlaKC
wants to merge
5
commits into
lightningdevkit:main
Choose a base branch
from
carlaKC:4181-experimental-accountable
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6bcd1b6
ln: add experimental accountable signal to update_add_htlc
carlaKC b657945
ln: add incoming_accountable to PendingHTLCInfo
carlaKC e60486e
ln: add accountable signal to HTLCUpdateAwaitingACK::AddHTLC
carlaKC c4d6406
ln: add accountable signal to OutboundHTLCOutput
carlaKC 9e14c82
ln/test: add test coverage for accountable signal propagation
carlaKC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| use crate::ln::channelmanager::{PaymentId, RecipientOnionFields, Retry}; | ||
| use crate::ln::functional_test_utils::*; | ||
| use crate::ln::msgs::{accountable_from_bool, ChannelMessageHandler, ExperimentalAccountable}; | ||
| use crate::routing::router::{PaymentParameters, RouteParameters}; | ||
|
|
||
| fn test_accountable_forwarding_with_override( | ||
| override_accountable: ExperimentalAccountable, expected_forwarded: ExperimentalAccountable, | ||
| ) { | ||
| let chanmon_cfgs = create_chanmon_cfgs(3); | ||
| let node_cfgs = create_node_cfgs(3, &chanmon_cfgs); | ||
| let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]); | ||
| let nodes = create_network(3, &node_cfgs, &node_chanmgrs); | ||
|
|
||
| let _chan_ab = create_announced_chan_between_nodes(&nodes, 0, 1); | ||
| let _chan_bc = create_announced_chan_between_nodes(&nodes, 1, 2); | ||
|
|
||
| let (payment_preimage, payment_hash, payment_secret) = get_payment_preimage_hash!(nodes[2]); | ||
| let route_params = RouteParameters::from_payment_params_and_value( | ||
| PaymentParameters::from_node_id(nodes[2].node.get_our_node_id(), TEST_FINAL_CLTV), | ||
| 100_000, | ||
| ); | ||
| let onion_fields = RecipientOnionFields::secret_only(payment_secret); | ||
| let payment_id = PaymentId(payment_hash.0); | ||
| nodes[0] | ||
| .node | ||
| .send_payment(payment_hash, onion_fields, payment_id, route_params, Retry::Attempts(0)) | ||
| .unwrap(); | ||
| check_added_monitors(&nodes[0], 1); | ||
|
|
||
| let updates_ab = get_htlc_update_msgs(&nodes[0], &nodes[1].node.get_our_node_id()); | ||
| assert_eq!(updates_ab.update_add_htlcs.len(), 1); | ||
| let mut htlc_ab = updates_ab.update_add_htlcs[0].clone(); | ||
| assert_eq!(htlc_ab.accountable, accountable_from_bool(false)); | ||
|
|
||
| // Override accountable value if requested | ||
| if let Some(override_value) = override_accountable { | ||
| htlc_ab.accountable = Some(override_value); | ||
| } | ||
|
|
||
| nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &htlc_ab); | ||
| do_commitment_signed_dance(&nodes[1], &nodes[0], &updates_ab.commitment_signed, false, false); | ||
| expect_and_process_pending_htlcs(&nodes[1], false); | ||
| check_added_monitors(&nodes[1], 1); | ||
|
|
||
| let updates_bc = get_htlc_update_msgs(&nodes[1], &nodes[2].node.get_our_node_id()); | ||
| assert_eq!(updates_bc.update_add_htlcs.len(), 1); | ||
| let htlc_bc = &updates_bc.update_add_htlcs[0]; | ||
| assert_eq!( | ||
| htlc_bc.accountable, expected_forwarded, | ||
| "B -> C should have accountable = {:?}", | ||
| expected_forwarded | ||
| ); | ||
|
|
||
| nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), htlc_bc); | ||
| do_commitment_signed_dance(&nodes[2], &nodes[1], &updates_bc.commitment_signed, false, false); | ||
| expect_and_process_pending_htlcs(&nodes[2], false); | ||
| check_added_monitors(&nodes[2], 0); | ||
| expect_payment_claimable!(nodes[2], payment_hash, payment_secret, 100_000); | ||
| claim_payment(&nodes[0], &[&nodes[1], &nodes[2]], payment_preimage); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_accountable_signal() { | ||
| // Tests forwarding of accountable signal for various incoming signal values. | ||
| test_accountable_forwarding_with_override(None, accountable_from_bool(false)); | ||
| test_accountable_forwarding_with_override(Some(7), accountable_from_bool(true)); | ||
| test_accountable_forwarding_with_override(Some(3), accountable_from_bool(false)); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
didn't give it a shot mysef, could dig into the
PendingHTLCInfoof node 2 here to cover thecreate_recv_pending_htlc_infocase ?