asxpio/test/fmt_test.rb
Sergei Poljanski 0fbb6ee809
All checks were successful
Build and Deploy to Production / test (push) Successful in 18s
Build and Deploy to Production / build (push) Successful in 49s
Build and Deploy to Production / deploy (push) Successful in 31s
invoices: multi-crypto payment support
One asset per invoice from a registry (lib/crypto_asset.rb): BTC, LTC,
ETH, XMR, SOL, ALGO, USDT/USDC on ERC-20/TRC-20/BEP-20/Solana/Algorand.
Migration 003 generalizes the ltc_* columns to crypto_* + crypto_coin
(existing LTC invoices backfilled). QR payload adapts per asset: BIP21
amount URIs where supported, bare address for tokens with a network
hint on the PDF. Default addresses come from the CRYPTO_ADDRESSES
secret (JSON code=>address); LTC_ADDRESS still works as legacy.
2026-07-03 02:01:57 +04:00

22 lines
570 B
Ruby

require_relative 'test_helper'
class FmtTest < Minitest::Test
def test_rate_pads_to_min_dp
assert_equal '2.9500', Fmt.rate('2.95')
assert_equal '3.0000', Fmt.rate(3)
end
def test_rate_keeps_captured_precision
assert_equal '2.95123456', Fmt.rate('2.95123456')
end
def test_rate_groups_thousands
assert_equal '1,050.2500', Fmt.rate('1050.25')
end
def test_crypto_trims_trailing_zeros
assert_equal '1.25', Fmt.crypto('1.250000')
assert_equal '2', Fmt.crypto('2.0')
assert_equal '0.00123456', Fmt.crypto('0.00123456')
end
end