Skip to content

Test coverage for transaction_unconfirmed #1481

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

Conversation

TheBlueMatt
Copy link
Collaborator

I noticed we have ~zero test coverage of the transaction_unconfirmed API, which is somewhat frightening. This adds such coverage via a new ConnectionStyle in the functional tests and also randomizes the ConnectionStyle used during functional tests, providing more coverage of the various connection methods generally.

@TheBlueMatt TheBlueMatt force-pushed the 2022-05-new-chain-tests branch 3 times, most recently from 1ba1c6d to 640af71 Compare May 16, 2022 16:42
@codecov-commenter
Copy link

codecov-commenter commented May 16, 2022

Codecov Report

Merging #1481 (b083870) into main (e5c988e) will increase coverage by 0.62%.
The diff coverage is 88.23%.

@@            Coverage Diff             @@
##             main    #1481      +/-   ##
==========================================
+ Coverage   90.89%   91.51%   +0.62%     
==========================================
  Files          76       77       +1     
  Lines       42054    46787    +4733     
  Branches    42054    46787    +4733     
==========================================
+ Hits        38223    42815    +4592     
- Misses       3831     3972     +141     
Impacted Files Coverage Δ
lightning/src/ln/functional_tests.rs 98.14% <76.00%> (+0.98%) ⬆️
lightning/src/ln/payment_tests.rs 99.24% <93.33%> (+<0.01%) ⬆️
lightning/src/ln/functional_test_utils.rs 97.31% <97.61%> (+1.77%) ⬆️
lightning/src/ln/chanmon_update_fail_tests.rs 97.70% <100.00%> (-0.06%) ⬇️
lightning/src/ln/reorg_tests.rs 100.00% <100.00%> (ø)
lightning/src/util/test_utils.rs 77.96% <100.00%> (ø)
lightning/src/util/time.rs 81.25% <0.00%> (ø)
lightning/src/ln/channel.rs 88.60% <0.00%> (+0.02%) ⬆️
... and 12 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 e5c988e...b083870. Read the comment docs.

@TheBlueMatt
Copy link
Collaborator Author

Tagging 108 because #1486 depends on this.

Comment on lines 1283 to 1284
// Check we only broadcast 1 timeout tx
let claim_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().clone();
assert_eq!(claim_txn.len(), 8);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still checking that we only broadcast 1 timeout tx per the comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Kinda? I mean we do broadcast one timeout tx per commitment, but, yea, I'm just gonna drop the comment its confusing.

Comment on lines 2586 to 2609
assert_eq!(node_txn.len(), 9);
assert!(node_txn.len() == 9 || node_txn.len() == 10);
// ChannelMonitor: justice tx revoked offered htlc, justice tx revoked received htlc, justice tx revoked to_local (3)
// ChannelManager: local commmitment + local HTLC-timeout (2)
// ChannelMonitor: bumped justice tx, after one increase, bumps on HTLC aren't generated not being substantial anymore, bump on revoked to_local isn't generated due to more room for expiration (2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these comments enumerating the txs in node_txn? Do they need updating?

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 just dropped them. We aren't actually checking all those things so the comment is just going to get stale and confusing over time anyway.

@valentinewallace
Copy link
Contributor

I think a warning may have been introduced in stable

@TheBlueMatt TheBlueMatt force-pushed the 2022-05-new-chain-tests branch 2 times, most recently from 3936511 to 51a58a9 Compare May 17, 2022 19:44
Previously `transaction_unconfirmed` was never called in tests!
In the next commit we'll randomize the `ConnectStyle` used in each
test. However, some tests are slightly too prescriptive, which we
address here in a few places.
We have a bunch of fancy infrastructure to ensure we can connect
blocks using all our different connection interfaces, but we only
bother to use it in a few select tests.

This expands our use of `ConnectStyle` to most of our tests by
simply randomizing the style in each test. This makes our tests
non-deterministic, but we print the connection style at start so
that it's easy to reproduce a failure deterministically.
@TheBlueMatt
Copy link
Collaborator Author

Squashed without changes:

$ git diff-tree -U1 51a58a90 b0838705
$

@valentinewallace valentinewallace merged commit 1fd6c6f into lightningdevkit:main May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants