fix(ci): unbreak the Go test suite on develop - #1459
Merged
Conversation
…evelop The mochi-pricing-revamp sub-goal 05 (Alchemy pricing) landed new call paths these tests never wired mocks for: - Test_dexscreener_Get: fixture pair address was never a real dexscreener pair (unrelated to the revamp, pre-existing bad fixture); swapped for the Uniswap V3 WETH/USDC pool. - TestEntity_SearchCoins / TestEntity_UpsertCustomToken: repo.CoingeckoSupportedTokens.GetOne() never returns a nil token (pg.go always returns a non-nil pointer even on ErrRecordNotFound); the CoinGecko-era mocks returned nil, nil-deref'ing at SearchCoins' `token.ID` check now that this path is actually reached. The new price_resolver.go tier (Alchemy by-symbol/by-contract) also needed mocking: a symbol-resolution GetOne() call per priced token, an Alchemy mock, and a wired-up logger (logTierCounts nil-panics without one). TestHandler_GetCoin was already fixed (skip-with-comment) by a prior commit on develop; no change needed here. TestHandler_SearchCoins remains red (same pricing-revamp root cause, real-DB/testdata-JSON fixtures with hardcoded prices) but was not in scope for this fix and was already failing before this change.
Three independent review passes (kit:code-reviewer test-coverage lens,
kit:security-reviewer, kit:advisor critique) ran against the first
commit. Security came back clean. The advisor caught a real scope gap
this commit closes, plus three nits addressed below.
- TestHandler_SearchCoins was still red after the first commit (it was
never in this task's original 4-test list, which named
TestHandler_GetCoin instead, already fixed via a prior skip on
develop). CL-015's own backlog text names TestHandler_SearchCoins,
not TestHandler_GetCoin, as the actual 4th target, and a branch named
fix/ci-test-green that leaves a known test red doesn't earn its name.
Fixed the same way as the pkg/entities tests: mock svc.Alchemy, and
update the "get multiple coins" golden JSON fixture, two coingecko
ids sharing symbol "doge" ("binance-peg-dogecoin" / "dogecoin") can
no longer get different Alchemy-sourced prices, so both now expect
0.2 with most_popular on the first (scan-order) entry, verified
against the real DB-seeded test run, not guessed.
- Softened the "no longer price-distinguishable" comments (defi_test.go,
handler/defi/defi_test.go): this is the CURRENT resolver's tier
ordering (by-symbol before by-contract), not an inherent limitation,
a populated contract could still differentiate via the DexScreener
tier. Worth an explicit accept-or-fix call from whoever owns the
pricing revamp; the test fixture documents today's behavior, it
doesn't endorse it.
- Deleted now-dead coinIds/coinPrices fixture fields left over from the
CoinGecko-mocked version of these tests (defi_test.go, tokens_test.go,
handler/defi/defi_test.go) that nothing reads post-fix.
- Commented the tests[0]-vs-tt coupling in tokens_test.go's Alchemy mock
(set up outside the test-case loop, matching this file's existing
GetOne/List/GetTokenMetadata mocks): a second test case would need
this hoisted into the loop.
Full suite verified: `go test ./...` is now 0 FAIL packages (244
package results, all ok/no-test-files).
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.
What's this PR does ?
Fixes the CI test suite (
ci-test.yml/make test), red on develop since the Alchemy pricing revamp. Test-only, zero production code changed.Which UI commands affect by this change ?
None (test-only change).
DoD
Summary
ci-test(make test) has been red on develop since the Alchemy pricing revamp (mochi-pricing-revamp sub-goal 05) retired Etherscan/SolScan/CoinGecko pricing for a tiered resolver (Alchemy by-symbol/by-contract -> DexScreener by-contract). The tests below never got their mocks/fixtures updated for the new call paths. This PR is test-only, zero production code changed.Test_dexscreener_Get(pkg/service/dexscreener): fixture pair address (0x5201...be4d) was never a real dexscreener pair (confirmed live: the API returnspairs:nullfor it), pre-existing bad fixture, unrelated to the revamp. Swapped for the Uniswap V3 WETH/USDC pool, a deep-liquidity, long-lived pair, matching this file's existing convention of live unmocked calls.TestEntity_SearchCoins/TestEntity_UpsertCustomToken(pkg/entities):repo.CoingeckoSupportedTokens.GetOne()never returns a nil token in production (pg.goalways returns a non-nil pointer, even ongorm.ErrRecordNotFound); the CoinGecko-era mocks returned literalnil, nil-deref'ing atSearchCoins'token.IDcheck now that this path is actually reached. The newprice_resolver.gotier also does a secondGetOnecall per priced token (to resolve its Alchemy ticker symbol), needed a new mock. Added an Alchemy service mock, and found + fixed a nile.login one test'sEntityfixture that the newlogTierCountscall nil-panics on.TestHandler_SearchCoins(pkg/handler/defi): same root cause at the handler/DB-integration level. Mockedsvc.Alchemythe same way, and updated thetestdata/search_coin/200-ok-multiple.jsongolden fixture: two coingecko ids sharing symbol "doge" (binance-peg-dogecoin/dogecoin) used to get different hardcoded prices under old CoinGecko per-id batch pricing (0.1 / 0.2); the new Alchemy-by-symbol tier can't distinguish them, so both now expect the same price. New expected values were captured from a real run against the seeded test DB, not guessed.TestHandler_GetCoinwas already fixed (skip-with-comment, "re-sourced off CoinGecko in sub-goal 05; see TestBuildCoinResponseByID") by a prior commit already on develop; no change needed.Scope note: the task brief named
TestHandler_GetCoinas the 4th failing test, but it was already green (SKIP) on develop. CL-015's own backlog description namesTestHandler_SearchCoinsinstead, which was genuinely still red, fixed here too so the branch actually earns its name.Before / after
go test ./...(full suite, mise-pinned Go 1.24.2 to matchgo.mod'sgo 1.19toolchain requirement, matchingci-test.yml's pinned toolchain approach):pkg/entitiesTestEntity_UpsertCustomToken, aborts the whole package beforeTestEntity_SearchCoinseven completes)pkg/service/dexscreenerTest_dexscreener_Get: dead fixture, real API returns no pairs)pkg/handler/defiTestHandler_SearchCoins: price mismatch)Confirmed via
git stashbefore/after comparison on the same checkout (not just the 4 named tests in isolation).Coverage (touched packages/functions; zero production lines changed)
pkg/entities(whole package, all tests)SearchCoins(defi.go)CreateCustomToken(tokens.go)enrichPriceQuery(price_resolver.go)symbolForCoingeckoIDtierAlchemyGetTokenPricesByIDresolvePriceOnepkg/service/dexscreener(package)GetByChainAndPairAddressPer-function coverage on
SearchCoins/CreateCustomToken/enrichPriceQuery/tierAlchemysits in the 48-67% range, below an 80% bar. These are large, multi-branch functions (skull-symbol override, default-ticker/native/is_popular tie-break branches, DexScreener-fallback path) where the uncovered branches are pre-existing and unrelated to what broke CI. Reviewer 1 (test-coverage lens) assessed this as acceptable for a CI-red bugfix ("scope here is explicitly making CI green, not raising coverage") and flagged thetierAlchemyDexScreener-fallback branch as a cheap follow-up, not a blocker for this PR.Review
Three review passes ran against this diff before opening:
gomock.Any()matchers are compensated by exact-match dispatch inside theirDoAndReturnclosures), the same-price fixture change is a legitimate reflection of the new architecture, and coverage levels are acceptable for this task's scope.TestHandler_SearchCoinsstill red), fixed, now 0 FAIL packages.coinIds/coinPricesfixture fields left over from the pre-revamp mocks, deleted.tests[0]-vs-loop-scoped-ttcoupling intokens_test.go's Alchemy mock, commented for the next person adding a test case.Worth a follow-up decision (not blocking this PR)
Two coingecko ids that share one ticker symbol (
ethereum/ethereum-wormhole,binance-peg-dogecoin/dogecoin) now resolve to the same Alchemy-sourced price, where the old CoinGecko-based pricing could tell them apart by id. This PR's tests document that as today's actual behavior rather than trying to fake differentiation. Whoever owns the pricing revamp should confirm whether that's an accepted tradeoff or worth a DexScreener-by-contract fallback for same-symbol tokens.Not in scope
SearchCoins/tierAlchemy/etc. coverage beyond what's needed to get CI green (see coverage table above).Reproduce
This is a production service repo; this PR is not being merged by me. Waiting on human review.