Aller au contenu
login
arrow_backRetour aux issues
Wayfare-labs/wayfare #1

Add unit tests for the refrate package

ecoDébutant help wanted good first issue area:tests difficulty:easy

descriptionDescription

### What The `refrate` package (reference mid-market rates) has no direct test file — it's only exercised indirectly through `route`. Add focused unit tests. ### Why it matters `refrate` is a **required** dependency of the engine: without a reference rate the monitor can rank routes but can't tell a good deal from a disaster. That is the single assumption this project exists to check, so its parsing and error paths need direct coverage — a regression should be caught here, not three packages downstream in `route`. ### Where to start - Read [CONTRIBUTING.md](../blob/main/CONTRIBUTING.md) for the invariants, then skim `route/route.go` to see how `refrate` is consumed. - `refrate/refrate.go` — the `Provider` interface, `Rate` (`Pair()` / `Age()`), the `Static` provider, `ErrNoRate`, and the `Checked` wrapper. `Static` needs no network, so start there. - `refrate/exchangerate.go` — the live `ExchangeRateAPI`. Test its response parsing with an `httptest.Server` serving canned JSON, never a live call. - Match the existing test style in `route/route_test.go` and `sep38/sep38_test.go`. ### Acceptance criteria - [ ] `refrate/refrate_test.go` (and/or `exchangerate_test.go`), table-driven - [ ] `Static.Rate` returns the right rate for a known pair, and `ErrNoRate` for an unknown one - [ ] `Rate.Pair()` and `Rate.Age()` covered - [ ] `ExchangeRateAPI` parsing tested via `httptest.Server`, including a malformed/error path — **no live network in unit tests** - [ ] `Checked` wrapper behaviour covered - [ ] Money assertions use `decimal.Decimal`, never `float64` - [ ] `make test` green; `go test -race ./refrate/...` clean ### Verify before you build None external — pure Go testing against existing code. **Difficulty:** easy
codeOuvre sur GitHub