-
Notifications
You must be signed in to change notification settings - Fork 411
Scope payment preimage in do_test_keysend_payments #2481
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
Scope payment preimage in do_test_keysend_payments #2481
Conversation
b0d4ab8 fixed a nasty bug where we'd failed to include the payment preimage in keysend onions at all. Ultimately, this was a test failure - the existing test suite should which did keysend payments were not structured in a way that would fail in this case, instead using the same preimage variable both for sending and receiving. Here we improve the main keysend test tweaked by b0d4ab8 to make absolutely sure it cannot work if the preimage doesn't come from the onion. We make the payment preimage on the sending side a variable inside a scope which only exists for the send call. Once that scope completes the payment preimage only exists in the sending `ChannelManager`, which must have put it in the onion in order for the receiving node to have it.
Doing `cargo test` causes us to build both the crate(s) themselves and the test binaries, which depend on the main builds. However, it can start building the test code while the actual program code for the main crate(s) themselves are being built, making a build -> test flow slightly slower than test -> build. Its not really a huge deal, but I'm using `ci/ci-tests.sh` more locally and it meaningfully changes the time-to-test-run.
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## main #2481 +/- ##
==========================================
- Coverage 90.33% 90.33% -0.01%
==========================================
Files 106 106
Lines 55771 55775 +4
Branches 55771 55775 +4
==========================================
+ Hits 50382 50384 +2
- Misses 5389 5391 +2
☔ View full report in Codecov by Sentry. |
FWIW, now also introduced test coverage for spontaneous payments in LDK Node (lightningdevkit/ldk-node#151). |
Will let @alecchendev take a look here, I don't really care much about this, just wanted to demonstrate what I think makes a good test for this kinda thing and will let him comment. |
This makes sense to me. I was thinking we should technically hit the "We require payment secrets" onion error in this single-path keysend test (which is how I ended up finding the bug), but now that we accept payment secrets on keysend after adding MPP support, if we sent a secret in this test it would probably pass before this PR (and ofc either way this better tests the actual keysend flow; the fact that we catch the secret case here is more a byproduct of being a better test). So yea this looks good (and maybe should also apply to the MPP keysend tests too) |
It maybe should, but doing it on the MPP tests is annoying since it would mean being much more verbose and doing |
b0d4ab8 fixed a nasty bug where
we'd failed to include the payment preimage in keysend onions at
all. Ultimately, this was a test failure - the existing test suite
should which did keysend payments were not structured in a way that
would fail in this case, instead using the same preimage variable
both for sending and receiving.
Here we improve the main keysend test tweaked by b0d4ab8
to make absolutely sure it cannot work if the preimage doesn't come
from the onion. We make the payment preimage on the sending side a
variable inside a scope which only exists for the send call. Once
that scope completes the payment preimage only exists in the
sending
ChannelManager
, which must have put it in the onion inorder for the receiving node to have it.