Skip to content
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

Genericize Test Functions #2177

Merged

Conversation

TheBlueMatt
Copy link
Collaborator

This is the prefactors from #2111 which just set us up to have more functions in testing, avoiding more macros in tests.

In the coming commits we'll add some additional complexity to the
event handling flows, so best to DRY them up before we get there.
@TheBlueMatt TheBlueMatt changed the title 2023 04 test function generics Genericize Test Functions Apr 12, 2023
@TheBlueMatt
Copy link
Collaborator Author

Assigning val and wilmer cause y'all are already on 2111.

@TheBlueMatt TheBlueMatt added this to the 0.0.115 milestone Apr 12, 2023
&'a test_utils::TestFeeEstimator, &'a test_utils::TestRouter<'a>,
&'a test_utils::TestLogger>;

struct ANodeHolder<'a, P: Persist<InMemorySigner>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we migrate the BackgroundProcessor utils as well so they can use functional_test_utils?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think so, but its a bit big, would have to add a bunch of new accessors and maybe do the chain tracking via the trait too.

@TheBlueMatt TheBlueMatt force-pushed the 2023-04-test-function-generics branch from 1be3caf to db9cd01 Compare April 12, 2023 20:03
@codecov-commenter
Copy link

codecov-commenter commented Apr 12, 2023

Codecov Report

Patch coverage: 98.27% and project coverage change: -0.02 ⚠️

Comparison is base (157af6e) 91.36% compared to head (cfb9eb9) 91.34%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2177      +/-   ##
==========================================
- Coverage   91.36%   91.34%   -0.02%     
==========================================
  Files         102      102              
  Lines       50369    50401      +32     
  Branches    50369    50401      +32     
==========================================
+ Hits        46018    46040      +22     
- Misses       4351     4361      +10     
Impacted Files Coverage Δ
lightning/src/ln/functional_test_utils.rs 92.68% <98.18%> (+0.20%) ⬆️
lightning/src/ln/channelmanager.rs 89.19% <100.00%> (+<0.01%) ⬆️
lightning/src/ln/functional_tests.rs 98.27% <100.00%> (+0.01%) ⬆️

... and 4 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

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.

LGTM after @wpaulino takes a look

In our test utilities, we generally refer to a `Node` struct which
holds a `ChannelManager` and a number of other structs. However, we
use the same utilities in benchmarking, where we have a different
`Node`-like struct. This made moving from macros to functions
entirely impossible, as we end up needing multiple types in a given
context.

Thus, here, we take the pain and introduce some wrapper traits
which encapsulte what we need from `Node`, swapping some of our
macros to functions.
This marginally reduces the quantity of code compiled in tests
further.
@TheBlueMatt TheBlueMatt force-pushed the 2023-04-test-function-generics branch from db9cd01 to cfb9eb9 Compare April 13, 2023 18:40
@TheBlueMatt
Copy link
Collaborator Author

Squashed with typo fixes:

$ git diff-tree -U1 db9cd012 cfb9eb96
diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs
index d35d286bb..f8ccce058 100644
--- a/lightning/src/ln/functional_test_utils.rs
+++ b/lightning/src/ln/functional_test_utils.rs
@@ -1566,3 +1566,3 @@ macro_rules! commitment_signed_dance {
 /// Runs the commitment_signed dance after the initial commitment_signed is delivered through to
-/// the initiator's `revoke_and_ack` resposne. i.e. [`do_main_commitment_signed_dance`] plus the
+/// the initiator's `revoke_and_ack` response. i.e. [`do_main_commitment_signed_dance`] plus the
 /// `revoke_and_ack` response to it.
@@ -1579,3 +1579,3 @@ pub fn commitment_signed_dance_through_cp_raa(node_a: &Node<'_, '_, '_>, node_b:
 /// been delivered, this method picks up and delivers the response `revoke_and_ack` and
-/// `commitment_signed`, returning the receipient's `revoke_and_ack` and any extra message it may
+/// `commitment_signed`, returning the recipient's `revoke_and_ack` and any extra message it may
 /// have included.

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.

4 participants