Skip to content

Pre-scoring test clean-ups #1120

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

Merged
merged 4 commits into from
Oct 14, 2021

Conversation

jkczyz
Copy link
Contributor

@jkczyz jkczyz commented Oct 13, 2021

Replaces get_route with get_route_and_payment_hash in tests wherever possible, since a scorer will need to be passed to get_route. Also includes some fairly trivial test clean ups.

@jkczyz
Copy link
Contributor Author

jkczyz commented Oct 13, 2021

I left a few TODO comments in the primary commit where I was unsure of the change. So please take a close look at those. Everything else should be fairly mechanical.

@codecov
Copy link

codecov bot commented Oct 13, 2021

Codecov Report

Merging #1120 (d4ec090) into main (fe8c10d) will increase coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1120      +/-   ##
==========================================
+ Coverage   90.67%   90.73%   +0.06%     
==========================================
  Files          66       66              
  Lines       34732    34808      +76     
==========================================
+ Hits        31494    31584      +90     
+ Misses       3238     3224      -14     
Impacted Files Coverage Δ
lightning-background-processor/src/lib.rs 94.23% <ø> (ø)
lightning/src/chain/channelmonitor.rs 91.26% <ø> (ø)
lightning/src/ln/functional_test_utils.rs 95.08% <ø> (-0.01%) ⬇️
lightning/src/ln/monitor_tests.rs 100.00% <ø> (ø)
lightning/src/ln/chanmon_update_fail_tests.rs 97.67% <100.00%> (-0.11%) ⬇️
lightning/src/ln/channelmanager.rs 85.12% <100.00%> (-0.03%) ⬇️
lightning/src/ln/functional_tests.rs 97.33% <100.00%> (-0.15%) ⬇️
lightning/src/ln/onion_route_tests.rs 96.60% <100.00%> (-0.05%) ⬇️
lightning/src/ln/payment_tests.rs 98.83% <100.00%> (+0.08%) ⬆️
lightning/src/ln/shutdown_tests.rs 95.87% <100.00%> (-0.02%) ⬇️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe8c10d...d4ec090. Read the comment docs.

@TheBlueMatt
Copy link
Collaborator

The "Fix need for #[allow(unused_mut)] in tests" commit is largely duplicative with "Use Persister to return errors in tests not chain::Watch " in #1108, is it possible to drop that commit here and use the one from 1108?

@jkczyz jkczyz force-pushed the 2021-10-test-refactors branch from 49e7016 to 7719633 Compare October 13, 2021 19:09
@jkczyz
Copy link
Contributor Author

jkczyz commented Oct 13, 2021

The "Fix need for #[allow(unused_mut)] in tests" commit is largely duplicative with "Use Persister to return errors in tests not chain::Watch " in #1108, is it possible to drop that commit here and use the one from 1108?

Dropped the commit.

I left a few TODO comments in the primary commit where I was unsure of the change. So please take a close look at those. Everything else should be fairly mechanical.

Reverted the marked changes to use get_route where applicable for ease of review, as requested offline. Left TODOs about changing them to get_route_and_payment_hash.

@@ -71,6 +71,9 @@ fn pre_funding_lock_shutdown_test() {
check_closed_event!(nodes[1], 1, ClosureReason::CooperativeClosure);
}

// TODO: Determine why get_route fails when replacing get_payment_preimage_hash with
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have another todo here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly to note why it may be that a simple replacement doesn't work here. Can drop it if you prefer.

@TheBlueMatt
Copy link
Collaborator

TheBlueMatt commented Oct 13, 2021

Do you want to take the in-number _ additions from #1113 here? It makes things a bit easier to read in a number of places IMO.Actually, I'll just rebase 1113 we can do it later.

let (_, second_payment_hash, second_payment_secret) = get_payment_preimage_hash!(nodes[2]);
let sending_node = if forwarded_htlc { &nodes[0] } else { &nodes[1] };
let (route, second_payment_hash, _, second_payment_secret) = get_route_and_payment_hash!(sending_node, nodes[2], 100000);
// TODO: Why use a different payment secret here?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cause there's two different payments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was unsure because they both used second_payment_hash but a different secret.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I was comparing it to the first send event further up, its just a typo I believe, feel free to drop it if the test still passes and always use the second secret.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use the second secret.

@@ -7906,6 +7740,8 @@ fn test_bump_penalty_txn_on_revoked_htlcs() {
assert_ne!(node_txn[0].input[0].previous_output, node_txn[2].input[0].previous_output);
assert_ne!(node_txn[1].input[0].previous_output, node_txn[2].input[0].previous_output);

// TODO: Determine why replacing get_route with get_route_and_payment_hash above causes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the tx ordering is based on the payment hash and we end up with a different hash, I assume? Or something like that, but maybe we should just drop the TODO and open a general "move the remaining explicit route calls to the routing macro" issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK mod removing the todos in favor of an issue + squash

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs squash.

@jkczyz jkczyz force-pushed the 2021-10-test-refactors branch from b6a3f5c to d700faa Compare October 13, 2021 22:27
@@ -9376,11 +9189,7 @@ fn test_keysend_payments_to_private_node() {
nodes[1].node.peer_connected(&payer_pubkey, &msgs::Init { features: InitFeatures::known() });

let _chan = create_chan_between_nodes(&nodes[0], &nodes[1], InitFeatures::known(), InitFeatures::known());
let network_graph = &nodes[0].net_graph_msg_handler.network_graph;
let first_hops = nodes[0].node.list_usable_channels();
let route = get_keysend_route(&payer_pubkey, &network_graph, &payee_pubkey,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be the only place we call get_keysend_route in tests through a private channel, so I think best to keep it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted and updated the other keysend test to use get_keysend_route.

@jkczyz jkczyz force-pushed the 2021-10-test-refactors branch from d700faa to 3e9678c Compare October 13, 2021 23:21
The interface for get_route will change to take a scorer. Using
get_route_and_payment_hash whenever possible allows for keeping the
scorer inside get_route_and_payment_hash rather than at every call site.

Replace get_route with get_route_and_payment_hash wherever possible.
Additionally, update get_route_and_payment_hash to use the known invoice
features and the sending node's logger.
@jkczyz jkczyz force-pushed the 2021-10-test-refactors branch from 3e9678c to d4ec090 Compare October 13, 2021 23:37
@TheBlueMatt TheBlueMatt merged commit da498d7 into lightningdevkit:main Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants