Skip to content

Test runs write to the real state files under data/ #335

Description

@crtahlin

Noticed while checking that the new spend budget did not leak state during tests (#102). It does not — but three pre-existing trackers do.

After pytest tests/ on a clean checkout:

data/pool_allowance.json
data/pool_state.json
data/stamp_owners.json

Those are the real paths the running gateway uses. POOL_ALLOWANCE_STATE_FILE, the pool state file and the ownership registry all default to data/ and nothing redirects them during tests.

Why it matters

  • On a developer machine running a local gateway, a test run overwrites the pool allowance counters, the pool inventory and the stamp ownership registry that the local instance is using. Ownership is the one that stings: check_access denies batches it has no record of, so a clobbered registry makes previously working uploads start failing for no visible reason.
  • Tests can depend on each other through those files — anything a test writes is still there for the next run, so a suite that passes on a clean checkout can behave differently on the second run.
  • The files land in the working tree. data/ is gitignored, so this is invisible rather than noisy, which is why it has gone unnoticed.

Fix

The pattern is already in tests/conftest.py for the spend budget: an autouse fixture that constructs the tracker against a tmp_path and patches the module-level singleton. The same treatment applied to the pool allowance, pool state and ownership trackers would cover it.

Worth doing as one change rather than three, since the fixtures are near-identical and the point is that no tracker writes to a real path.

Not urgent. Nothing is broken in CI, where the checkout is thrown away.

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

    bugSomething isn't workingp3Low priority — someday

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions