feat: add more invalid BAL test cases; extend invalid case coverage#2653
Conversation
40a762d to
f7d0078
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## forks/amsterdam #2653 +/- ##
===================================================
+ Coverage 86.24% 86.25% +0.01%
===================================================
Files 599 599
Lines 36984 37032 +48
Branches 3795 3795
===================================================
+ Hits 31895 31943 +48
Misses 4525 4525
Partials 564 564
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
f4fb9a5 to
a9056b4
Compare
a9056b4 to
1d8d8e7
Compare
|
cc: @nerolation |
|
I haven't checked bal-devnet-3... but cherry-picking this on bal-devnet-2 and running against clients to verify the exception mapper message consolidation changes (they look good), I believe there are genuine client bugs that some tests found. Summary from Claude:
Something to pay extra attention to when reviewing perhaps. |
e83ca7e to
6fd97fd
Compare
suggestion: Increase invalid test coverage using the frameworkBAL validation can be broken down into three dimensions:
BAL equivalence = Correctness + Exactness + Sequence. Our tests should not assume how clients verify equivalence of computed vs provided BAL (hash, item-by-item, or otherwise). A client that does zero BAL validation (one that simply passes through the provided BAL) will pass every happy path test. For every happy path test, we should have a negative test and ensure client rejects them:
However, instead of writing invalid tests by hand, we should automate them using the framework. We can derive these invalid tests from a single valid one:
The required modifiers for these mutations already exists. So some kind of pytest hook over this way our invalid coverage grows organically with valid tests. |
I think this is a great idea to attempt to implement as a separate exercise, perhaps even as its own simulator / test run. I can see something like a decorator used for specific tests that can do this sort of mutation otherwise I suspect we will bloat invalid tests with a ton of overlap on code paths. It's worth exploring as a different test flow for some fuzzing equivalent for invalid tests. I would argue we should get these test cases in and review this PR solely on the cases here though. We shouldn't wait for a big framework change like this. I support your idea but I'd like to get coverage here asap as I share your view on the importance of invalid tests at the current moment for devnet progress. |
nerolation
left a comment
There was a problem hiding this comment.
Awesome thanks!
Reviewed and looks good to me.
Some nits that could be ignored:
- test_bal_invalid_field_entries passes alice= to every modifier lambda though none use it
- append_account in test_bal_invalid_extraneous_coinbase appends at the end without re-sorting. If the coinbase EOA address sorts below a prior entry, the client may reject for ordering rather than "extra account". Since it about "INVALID_BLOCK_ACCESS_LIST" it might be fine(?)
Nope, I think number 2 is a legitimate concern not worth ignoring.. thanks! I added both here since I was already going into the code to make sure, especially for a reader of the test, that point |
marioevz
left a comment
There was a problem hiding this comment.
Just one comment in one of the tests.
…alidate against this on apply
marioevz
left a comment
There was a problem hiding this comment.
LGTM, thanks for the new check in Header/FixtureHeader!
🗒️ Description
Extend invalid BAL test coverage by adding:
test_bal_invalid_hash_mismatch: injects wrong hash via theheader_modifyoption. We were'nt testing this before.Add missing coverage / test cases for:
missing_storage_changemissing_storage_readmissing_code_changewrong_code_valueAdds invalid coinbase test cases:
test_bal_invalid_missing_coinbase— fee recipient removed from BAL (block has tx with tip)test_bal_invalid_coinbase_balance_value— fee recipient balance wrong (999 instead of actual tip)test_bal_invalid_extraneous_coinbase[empty_block]— spurious coinbase injected into block with no txs/withdrawalstest_bal_invalid_extraneous_coinbase[withdrawal_only]— spurious coinbase injected into block with only withdrawals (no fees paid)Updates the
test_cases.mdfor the tests introduced here, as well as for tests introduced in PR tests(amsterdam): add BAL missing withdrawal account tests #2652 which I missed to add totest_cases.md- helps us keep track of it all.Audited the implemented tests and
test_cases.mdand attempted to sync the md with the current state of things (some renames were not updated and some implementations were not recorded there, but not a whole lot seems out of sync).Consolidates unused, granular BAL exceptions that don't map 1-to-1 for any client - we should just keep these more generic for now. If granularity is added to clients, we can approach newer exceptions imo.
✅ Checklist
just statictype(scope):.mkdocs servelocally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.Cute Animal Picture