refactor(tests): dedupe integration harness, drop dead scaffolding - #42
Merged
Conversation
The feature PRs merged today each brought their own copy of the test harness. Consolidate it and remove leftover template scaffolding. - Add src/tests/integration/conftest.py holding the shared server fixture, the HTTP/JSON-RPC plumbing, the spec-shape predicates, and composable transaction helpers (send_tx, fund_account, deploy_contract, make_invoker, deploy_and_get_invoker). - test_server.py and test_get_events.py now import these instead of redefining them; the ~7 inline send/builder closures and the five separate deploy helpers collapse onto the shared primitives. - Unify the duplicated _is_number / _is_json_number predicate. - Delete komet_node/hello.py (untouched cookiecutter scaffolding, used nowhere in the product) and its two duplicate test_hello tests. - Strengthen test_call_tx_with_args: it now round-trips each decoded argument from the trace's callContract frame back through scval_from_json and asserts equality with the sent SCVals, so a decoding bug is caught even when the transaction still succeeds (previously it only asserted SUCCESS). No behavior change: the 78 non-injection tests pass; the contract upload/deploy/invoke tests fail only on the pre-existing kdist compiled.json v3 vs pyk v4 toolchain skew, identically on main.
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.
Summary
Post-merge cleanup of the test suite. The feature PRs merged today (get-events, tx-result-xdr, simulate-transaction, get-ledger-entries, trace-transaction) each brought their own copy of the integration harness, so the fixtures, RPC plumbing, and deploy helpers had drifted across files. This consolidates them and removes leftover cookiecutter scaffolding.
Changes
src/tests/integration/conftest.py— the sharedserverfixture (was duplicated verbatim in both integration files), the HTTP/JSON-RPC plumbing (_rpc/_post/_post_raw/wat_to_wasm/_find_free_port/_wait_for_server), the spec-shape predicates, and composable transaction helpers (send_tx,fund_account,deploy_contract,make_invoker,deploy_and_get_invoker).test_server.py/test_get_events.pyimport from conftest instead of redefining. The ~7 inlinesend/builderclosures and the five separate deploy helpers collapse onto the shared primitives._is_number/_is_json_numberpredicate.komet_node/hello.py(untouched cookiecutter scaffolding, used nowhere in the product) and its two duplicatetest_hellotests.test_call_tx_with_args— it now round-trips each decoded argument from the trace'scallContractframe back throughscval_from_jsonand asserts equality with the sent SCVals, so a decoding bug is caught even when the transaction still succeeds. Previously it only assertedSUCCESS.Net
-423/+93across the edited files, with the shared logic centralised in the new 216-line conftest.Verification
make checkclean (flake8, mypy, autoflake, isort, black).send_tx,fund_account, and the predicate unification.kdistwritescompiled.jsonv3, installedpykexpects v4 →ValueError: Invalid version: 3ininterpreter._inject_program), which reproduces identically onmain. CI, running the pinned toolchain, is unaffected.