test: strengthen mock-echo and vacuous tests in Abi, Optimism and Xdc test projects - #12720
Open
benaadams wants to merge 5 commits into
Open
test: strengthen mock-echo and vacuous tests in Abi, Optimism and Xdc test projects#12720benaadams wants to merge 5 commits into
benaadams wants to merge 5 commits into
Conversation
The extension tests asserted only Received on the inner call and ignored the extension return value. A stub on the exact unpacked arguments plus an identity assert on the result covers both.
The single test asserted Is.Not.Null on a result that cannot be null. The factory contract is routing: Xdc databases get a PerTableDbConfig without consulting the base factory, and every other database delegates to it. Both branches are now pinned; the delegation branch was untested.
The vote routing test pins the exact vote, but the timeout test used Arg.Any, so a handler that routes the wrong timeout passed.
Removes an unused using that fails lint CI. Pins the factory options against the provided IDbConfig, so a wrong database name in the special branch turns the test red. Moves the extension rationale to class level and renames the Abi tests to the project snake_case convention.
NSubstitute returns an empty array, not null, for an unmatched call on an array-returning member. The prefixed-options claim holds for only half of the database prefixes, so the sentence is dropped.
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.
Changes
Test-hygiene chunk: mock-echo and do-nothing tests in
Nethermind.Abi.Test,Nethermind.Optimism.Test, andNethermind.Xdc.Test. A scanner pass over the three projects found 43 candidates (no-verification bodies,Received-only tests,Not.Null-only asserts); after reading every hit, three fixes remained - the rest verify real behavior through local assert helpers or useReceivedas a legitimate oracle for routing/dedup contracts (details below). No product code changed (verified: diff touches only*.Testfiles).Nethermind.Abi.Test/AbiEncoderExtensionsTests.cs: both tests called the extension and asserted onlyReceived()on the inner call, ignoring the extension's return value. They now stub the exact unpacked arguments and assert the extension returns the stubbed instance. A misforwarded argument makes the substitute return null, so the identity assert pins the unpacking and the return propagation at once.Nethermind.Xdc.Test/ModuleTests/XdcRocksDbConfigFactoryTests.cs: the single test assertedIs.Not.Nulltwice on values that cannot be null. The factory's contract is routing: Xdc databases (XdcSnapshots,XdcRewards) get aPerTableDbConfigwithout consulting the base factory (validation bypass - the reason the class exists), every other database delegates. Both branches are now pinned (InstanceOf+ options read through the providedIDbConfig+DidNotReceivefor the special names;Is.SameAsthe base result for delegation). The delegation branch was previously untested, and the options assert also pins the forwarded database name (the Xdc names have no dedicated options, so the config must fall back to the unprefixed options; a wrong name appends prefixed options). Note:PerTableDbConfigvalidation is#if DEBUGonly, so no throw-based assert is possible in release mode.Nethermind.Xdc.Test/XdcProtocolHandlerTests.cs(one line): the timeout routing test usedArg.Any<Timeout>()while its vote sibling pins the routed value - a handler routing the wrong timeout passed. It now pins the routed timeout.Timeoutequality is RLP-hash based (full wire content: round, signature, gap), which is the semantically right pin for routed message content - a content-equal copy is behaviorally identical, so reference identity is deliberately not asserted (matches the vote sibling's idiom).Triage of the remaining scanner hits (all verified by file read, left unchanged)
ForkInfoTests(delegates to the asserting sharedNetwork.Test.ForkInfoTests.Testhelper),OptimismReceiptTests(AssertL1AndOperatorFees),CL/PayloadDecoderTests(ComparePayloads),Rpc/DepositTransactionForRpcTests(ValidateSchema),Xdc HobbitTests(HobbitTestsBase.Runasserts byte-identical round-trips),XdcSubnetHeaderDecoderTests(AssertRoundTripwith a field comparer).Received-based behavioral tests:XdcProtocolHandlerTests(conditional routing, send dedup, sync gating),VotesManagerTests(QC build timing and dedup,DidNotReceiveon missing header),SyncInfoManagerTests(dispatch with exact certificates),SignTransactionManagerTests(60s signing-window boundary viaReceived(1/0)),OptimismEngineRpcModuleTest(version comparison branching viaReceived(1/0)with exact args).Optimism.Test/RlpDecoderTests.csis excluded: already strengthened on the open test: make decoder tests assert the decoded values #12711 branch.Nethermind.Taiko.Testis out of scope for the whole effort.Mutation evidence
Product mutations applied against committed state, run, and reverted:
[]Receivedcannot see the return value)InstanceOf/DidNotReceive)Arg.Anypasses by constructionVerification
Nethermind.Abi.Test: 226/226 passed. FullNethermind.Xdc.Test: 543/543 passed.dotnet format whitespaceon both projects: no changes.Types of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?
Notes on testing
Tests are the subject of this PR. Each strengthened assertion was shown to fail under a product perturbation or an expectation flip, and the replaced assertions were shown empirically to stay green under mutations the new ones catch (table above).
Documentation
Requires documentation update
Requires explanation in Release Notes