cacti icon indicating copy to clipboard operation
cacti copied to clipboard

test(ethereum): fix broken validations in tests

Open malsomesh9 opened this issue 7 months ago • 4 comments

Summary

Fix broken Ethereum connector validation behavior and refactor the affected negative tests to use Jest rejection matchers.

Changes

  • reject unexpected top-level properties in deployContract() requests
  • reject web3.eth.getBlock calls when required arguments are missing
  • refactor the three affected negative tests away from try/catch assertions to Jest matchers

Verification

Validated in an isolated checkout by running:

  • geth-invoke-web3-method-v1.test.ts
  • geth-contract-deploy-and-invoke-using-json-object-v1.test.ts
  • geth-contract-deploy-and-invoke-using-keychain-v1.test.ts

Fixes #3475 Related to #3487

malsomesh9 avatar Apr 06 '26 17:04 malsomesh9

Verification summary:

  • validated the targeted fix in an isolated checkout
  • confirmed these issue-related integration tests pass end-to-end:
    • geth-invoke-web3-method-v1.test.ts
    • geth-contract-deploy-and-invoke-using-json-object-v1.test.ts
    • geth-contract-deploy-and-invoke-using-keychain-v1.test.ts

Note: while verifying, I found a separate repo-level Jest/TypeScript workspace-resolution issue in the temporary environment setup. I did not include those broader harness changes in this PR so the scope stays focused on #3475.

malsomesh9 avatar Apr 06 '26 17:04 malsomesh9

One scope note for reviewers: this PR fixes the three broken negative cases called out in #3487 and converts those assertions to Jest rejection matchers. It also adds the missing runtime validation that makes those expectations true again: unexpected top-level deployContract() fields now reject, and web3.eth.getBlock rejects when called without the required block argument.

Since #3475 is worded broadly as “all negative test case exception assertions” for the Ethereum connector, please let me know if you want this PR to remain scoped to the failing cases from #3487 or if we should expand it to sweep any remaining try/catch-style negative assertions before closing #3475.

malsomesh9 avatar Apr 15 '26 12:04 malsomesh9

Implemented the requested review fixes.

The negative deploy tests now validate one thing at a time by using valid gasConfig and keeping fake as the only unexpected top-level field. I also updated the connector so request-shape validation and missing getBlock args are treated as client errors and returned as 400 Bad Request, and refactored the affected negative tests to use Jest rejection matchers.

malsomesh9 avatar Apr 29 '26 13:04 malsomesh9

@malsomesh9 please fix the linter, so we can run the tests and try to merge

RafaelAPB avatar Jul 09 '26 14:07 RafaelAPB

closed due to inactivity

RafaelAPB avatar Aug 16 '26 22:08 RafaelAPB