Files
zeekayandHanzo Dev 4644d5e09f bank: fees scoped to payment/conversion; bankd honors CLI args (v1.6.1)
Two tracked audit fixes, no external deps:

- Fees no longer charge deposits, withdrawals, on-chain crypto sends,
  or the testnet faucet. The default fee branch wrote a service_fee row
  that was never debited (and on crypto it was bp on micro-units). Fees
  now apply only to payment (rails) and conversion (FX spread) — the
  surfaces the schedule actually prices. Locked with a test.
- cmd/bankd honors os.Args: `serve --http`, `migrate`, and `--help`
  work instead of being overridden by a hardcoded serve on :8070. Bare
  invocation still serves on BANKD_HTTP (default :8070) for the k8s/demo
  path. --help now prints usage instead of nil-derefing base's migration
  runner.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-22 14:31:52 -07:00

25 lines
932 B
Go

package hooks
import "testing"
// Fees apply to the surfaces the schedule prices — payment (rails) and
// conversion (FX spread) — and to nothing else. Deposits, withdrawals and
// on-chain crypto sends carry no platform fee, so no undebited fee row is
// written for them.
func TestCalculateFeeScopedToPaymentAndConversion(t *testing.T) {
const amt = 100_00 // $100.00
if fee, _ := CalculateFee("individual", "withdrawal", amt, 0); fee != 0 {
t.Errorf("withdrawal fee = %d, want 0", fee)
}
if fee, _ := CalculateFee("individual", "deposit", amt, 0); fee != 0 {
t.Errorf("deposit fee = %d, want 0", fee)
}
if fee, ft := CalculateFee("individual", "conversion", amt, 0); fee <= 0 || ft != "conversion_spread" {
t.Errorf("conversion fee = (%d, %q), want (>0, conversion_spread)", fee, ft)
}
if fee, _ := CalculateFee("individual", "payment", amt, 0); fee <= 0 {
t.Errorf("payment fee = %d, want > 0", fee)
}
}