Skip to content

extract the shared cross-major system-test harness into an importable module #16

Description

@kp2pml30

tests/system/cross-major-observability/test.py reuses the real-manager harness from tests/system/cross-major/test.py, because duplicating ~600 lines of ManagerProc / contract-source / mock-host plumbing would be worse. There is no blessed way to do that, so it currently does this:

def _load_cross_major_harness():
	path = Path(__file__).parents[1] / 'cross-major' / 'test.py'
	spec = importlib.util.spec_from_file_location('cross_major_system_harness', path)
	...

and then reaches for base._contract_source, base._message, base._calldata, base._apply_storage_changes, base.CrossMajorStep, base.ManagerProc, base.SENDER, base.PY_GENLAYER_V03 — eight private names across a module boundary, plus a path coupling that breaks silently if the sibling directory is renamed.

It works and the case passes, but it is the wrong shape.

Suggested fix

Extract the generic parts into an importable module — tests/runner/gvm_extra/ is already on the test path (from gvm_extra.mock_host import MockStorage works today). Roughly:

  • constants (SENDER, TIMESTAMP, PY_GENLAYER_V03), _contract_source, _TestContext, ManagerProc, _message, _calldata, _apply_storage_changes, _descendants;
  • the harness half of CrossMajorStep (_new_host, _deploy, _replace_code) as a base class, leaving each case its own _execute and _assert_*.

Then both cases import it normally and the importlib loader goes away.

Deliberately not done in the same change: it is a real refactor of the 1452-line cross-major/test.py, and splitting that class is worth doing on its own rather than tacked onto a new test.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions