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

bkpr tests: return actual error data, not just a blank assert failure #8051

Merged
merged 2 commits into from
Feb 7, 2025

Conversation

niftynei
Copy link
Contributor

@niftynei niftynei commented Feb 4, 2025

It's really hard to tell what on earth went wrong when a coin movement check fails, since we dont' return good error info.

Here we replace almost every assert with a proper check + error with message to help make debugging easier.

We also fixup a flake in one of the penalty HTLC anchor tests, which was causing errors here. https://github.com/ElementsProject/lightning/actions/runs/13090154480/job/36526299502?pr=8031#logs

Change Log: None

@niftynei niftynei force-pushed the nifty/bkpr-fails branch 2 times, most recently from 62af272 to d5e362b Compare February 5, 2025 01:33
It's really hard to tell what on earth went wrong when a coin movement
check fails, since we dont' return good error info.

Here we replace almost every `assert` with a proper check + error with
message to help make debugging easier.

cc @rustyrussell

Changelog-None: improve failure messages
Test flake where the balance for lightning-2 went negative

```
>       assert account_balance(l2, channel_id) == 0

tests/test_closing.py:1314:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/utils.py:183: in account_balance
    m_sum -= Millisatoshi(m['debit_msat'])
contrib/pyln-client/pyln/client/lightning.py:193: in __sub__
    return Millisatoshi(int(self) - int(other))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = -10000msat, v = -10000
```

Led me to look into this test. lightning-2 should go negative since we
roll back the amounts it's received by going to a prior database state.

Rather than trying to do the right thing with obviously broken node
records, instead we just stop trying to account for them correctly
(impossible).

I also noticed that the anchor tests were failing the utxo output
matchup, which we should be asserting on it. The HTLC RBF that our
anchor code creates was causing an issue by creating another wallet
deposit utxo under the HTLC output. We now optionally add this utxo
in the case that anchors are turned on.

Changelog-None: Fix test flake
Copy link
Collaborator

@endothermicdev endothermicdev left a comment

Choose a reason for hiding this comment

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

That was a fun read and flake. Nice debugging!
ACK 50d7b7e

@endothermicdev endothermicdev merged commit fc08340 into ElementsProject:master Feb 7, 2025
40 checks passed
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.

2 participants