fix(e2e): await async selector() in e2e_nested_utility_calls#23656
Merged
Conversation
The 4 `toMatchObject` assertions in the `authorizeUtilityCall hook` block compared `lastRequest.functionSelector` against `contractB.methods.pow_utility.selector()`, which is async (returns `Promise<FunctionSelector>` via `FunctionSelector.fromNameAndParameters`, async since #23007). An un-awaited Promise has no own enumerable properties, so `toMatchObject` treated the expected `functionSelector` as a vacuously-satisfied empty object and never actually checked the selector -- the assertions silently passed regardless of the real value. Awaiting `.selector()` makes the assertions compare against the resolved `FunctionSelector`. Verified: a negative control with a deliberately wrong selector fails only after the await is added, and the full suite passes 10/10 with the correct selector.
Contributor
Author
|
Oops.... i did not mean to merge this.... wrong pr.... Wait how did it merge without approval? |
Contributor
|
So weird that the assertion actually passed 😅 Well, approved post-merge ✔️ |
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.
Root cause
The 4
toMatchObjectassertions in theauthorizeUtilityCall hookblock ofe2e_nested_utility_calls.test.tscomparedlastRequest.functionSelectoragainstcontractB.methods.pow_utility.selector(). That method is async — it returnsPromise<FunctionSelector>viaFunctionSelector.fromNameAndParameters(...), which became async in #23007.Because the expected value was an un-awaited Promise, and a Promise has no own enumerable properties,
toMatchObjecttreatedfunctionSelectoras a vacuously-satisfied empty object and never compared the actual selector. The assertions silently passed regardless of the real value — the selector check was a no-op since #23007.Note: this is a latent / vacuous-assertion defect, not a deterministic hard failure. The 4 subtests were passing (10/10) both before and after the change; the value of the fix is that the assertions now actually verify the selector.
Fix
Add
awaitto the 4 assertions:One line each, no other changes.
Verification
Ran
yarn-project/end-to-end/scripts/run_test.sh simple src/e2e_nested_utility_calls.test.ts(node 24.12.0, full bootstrap):set_pow_args) on the awaited assertion makes that subtest fail (1 failed / 9 passed), proving the awaited assertion is now genuinely meaningful. Reverted before commit.