Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

swap-fees: free-mint path grants 199 steps for 100 paid (allotment 11,940,000 ms vs 6,000,000 expected)

Open
#720 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
docker, go
Domain
backend, testing

Research direction

Start by running the named test, test_swap_fees.py::TestSwapFees::test_fee_mint_payments_do_not_break_the_free_mint_path, in tests/cloud-lab and compare it with an isolated run. Then inspect the allotment calculation in src/upstream_session_manager/ and the kind-1022 event emission in src/merchant/; first establish whether the event represents a per-payment grant or a session total. Done means the product behavior is confirmed and the test passes with the free-mint allotment matching that behavior.

Written by the indexing model from the issue text.

Description

release:v0.6.0

Summary

test_swap_fees.py::TestSwapFees::test_fee_mint_payments_do_not_break_the_free_mint_path fails on current main: a 100-step payment on the FREE mint is granted 11,940,000 ms of allotment — exactly 199 steps — where the test demands 100 × 60,000 = 6,000,000. The anomaly is in the generous direction (customer receives ~2× what was paid for). Funds-adjacent: allotment accounting is wrong somewhere.

Severity: S2 candidate. 4 of 5 fee tests in the same file pass; only the free-mint-path check fails.

Verified on

  • Commit: 68ad5144ab09cb4723d8f3f655cbba1ac7ea9de5 (main, 2026-10-07)
  • Lane: tests/cloud-lab docker lab, client pytest run

Evidence (verbatim)

>       assert allotment == 100 * 60000, (
E       AssertionError: Free-mint allotment 11940000 should equal the full 100 steps (6000000): {'p': ['c6:a5:b8:02:91:1e'], 'device-identifier': ['mac', 'c6:a5:b8:02:91:1e'], 'allotment': ['11940000'], 'metric': ['milliseconds'], 'start-time': ['1791388848']}
E       assert 11940000 == (100 * 60000)
test_swap_fees.py:301: AssertionError
FAILED test_swap_fees.py::TestSwapFees::test_fee_mint_payments_do_not_break_the_free_mint_path
1 failed, 4 passed in 3.41s

Note 11,940,000 == 199 × 60,000 exactly.

Reproduce

git clone https://github.com/OpenTollGate/tollgate-module-basic-go && cd tollgate-module-basic-go
git checkout 68ad5144ab09cb4723d8f3f655cbba1ac7ea9de5
cd tests/cloud-lab
export TG_GO_VERSION="$(jq -r '.go.version' ../../packaging/build-inputs.json)"
docker compose up -d          # builds mint, mint-fees (100 ppk) and upstream
docker compose run --rm client -q test_swap_fees.py ; echo EXIT=$?   # or -sv for full output

Expected: 5/5 pass. Actual: 4 passed, 1 failed with the allotment assertion above.

Docker-29 caveat: if the client image fails to build (failed to parse stage name "golang:-bookworm"), apply the Dockerfile.client ARG fix from the companion issue first.

Troubleshooting guide

  1. First hypothesis — test isolation / accumulation: the paying client in the failing test is c6:a5:b8:02:91:1e. Check whether earlier tests in the same session reuse that MAC and whether allotment in the session event is a per-payment grant or a session TOTAL (renewal accumulation). 199 = 100 + 99 is suspiciously close to "this payment plus an earlier 99-step grant".
    • Repro A (isolation): run only the one test — docker compose run --rm client -q test_swap_fees.py::TestSwapFees::test_fee_mint_payments_do_not_break_the_free_mint_path — if it passes alone, the bug is state leakage between tests (shared MAC, wallet not reset, or the session renewal math accumulating across payments).
    • Repro B (unit seam): the allotment math lives in src/upstream_session_manager/ (usage trackers, renewal thresholds) and src/merchant/ (session event emission). Look at where the kind-1022 event's allotment tag is computed for a SECOND payment by the same MAC.
  2. Second hypothesis — fee-path contamination of the free path: the test's premise is that paying the free mint while the wallet ALSO knows the 100-ppk fee mint must not change the free grant. If the fee-resolution logic (per #440/#447-era work) applies a fee-derived step count or renewal top-up to the free path, you'd see inflated grants. Compare the wallet's credited amount for the free-mint token before/after the fee-mint tests ran.
  3. What 99 would mean: if an earlier test granted 99 steps (or a renewal added 99), find the emitter of that grant and why the free-path payment sees it merged.

Fix hints

  • If accumulation-by-design: the session event should either report per-payment allotment or the test should assert on the delta — but get the PRODUCT answer first: is allotment specified as total-session or per-payment? The wire spec (OpenTollGate/tollgate) is the authority.
  • If leakage: reset the client MAC between tests or drain the session in the fixture.

References

  • Lane docs: tests/cloud-lab/README.md (tg-mint-fees, swap-fee expectations)
  • Fee-math history: #409 (below-swap-fee pre-check), #440/#447 (fee error classification)
Dominant language
Go
Stars
12
Forks
14
Avg merge
1d 5h
Merged PRs (30d)
240

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenTollGate/tollgate-module-basic-go

All issues in OpenTollGate/tollgate-module-basic-go

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.