Repository navigation
Conversation
Add tests/test_lsps2_malicious_lsp.py, for tests of the client against an LSP that misbehaves, starting with an LSP that deducts the wrong fee from the JIT payment. Each case of one parametrized test ends with the oracles; the fee taken again from a later payment needs two payments and has its own test: - 1 msat more than the opening fee, on a fixed invoice paid in parts; - a fee on the rounding boundary, accepted exactly; - the fee spread over MPP parts, correctly, and adding up to 1 msat more; - only some of the MPP parts forwarded; - the fee deducted again from a later payment; - an overpaid fixed invoice. Cases that rely on the MPP timeout of 70 seconds are marked slow. A forward below the client's htlc_minimum_msat cannot be produced by an LSP running Core Lightning, so there is no case for it.
Test how the client handles what the LSP sends over the LSPS0 transport, one parametrized case each, ending with the oracles: - a response with the wrong id, or none: the request times out; - a response to no request is ignored; - of two responses, the first counts; - a negative msat or one above u64: a clean error; - unknown keys in a result are ignored; - a full-size message of garbage or deeply nested JSON is ignored; - an error with a huge message does not fill the log. lightningd hands the client one custom message from a peer at a time, so a request answered after the mock's unsolicited messages shows they were handled; every case also checks the client still gets an honest menu afterwards. The cases that wait for the client's 60 second request timeout are marked slow.
Test which entry of an LSP's get_info menu the client buys, if any, one parametrized case each, ending with the oracles: - an expired entry, or one expiring within the client's margin; - a minimum payment size above the maximum; - a fee that eats the payment, or overflows; - a large max_client_to_self_delay; - min_lifetime 0; - a menu filling a whole message, usable only at its end; - promises too long or with forbidden characters, which abort the flow even in an entry not picked, and valid ones at the limits; - duplicate entries; - an entry missing a field, or with one bLIP-52 does not define. The invoice call is waited for at most 30 seconds, so a hang fails the case instead of the run.
Test how the client handles the LSP's lsps2.buy result and channel opens it did not ask for, each case ending with the oracles: - a jit_channel_scid that is no SCID; - an lsp_cltv_expiry_delta of 0; - "invalid promise" for an unchanged promise: no retries; - a second buy result with another SCID; - a zero-conf open from the LSP before any buy or after the session's channel; - a second zero-conf open for the session; - a zero-conf open from another node during a session. Core Lightning refuses the unsolicited zero-conf opens because the client allows zero-conf only for the LSP it just bought from, once.
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Important
26.09 FREEZE August 5th: Non-bugfix PRs not ready by this date will wait for 26.12.
RC1 is scheduled on August 17th
The final release is scheduled for September 7th.
Checklist
Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked:
tools/lightning-downgradeThis adds
tests/test_lsps2_malicious_lsp.py. In each case the mock misbehaves in one specific way; the test checks how the client reacts, then runs the invariant checks.max_client_to_self_delayand amin_lifetimeof 0;lsp_cltv_expiry_deltaof 0;Cases that wait for the client's 60 s request timeout or lightningd's 70 s MPP timeout are marked
slow_test. The client itself is not changed.Changelog-None