mirror of
https://github.com/muun/recovery.git
synced 2025-10-30 00:05:04 -04:00
28 lines
571 B
Go
28 lines
571 B
Go
package newop
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
func TestExchangeWindowConvert(t *testing.T) {
|
|
|
|
window := &ExchangeRateWindow{}
|
|
window.AddRate("BTC", 1)
|
|
window.AddRate("USD", 32_000)
|
|
|
|
amount := NewMonetaryAmountFromSatoshis(100_000_000)
|
|
|
|
converted := window.convert(amount, "USD")
|
|
|
|
if converted.Currency != "USD" {
|
|
t.Fatalf("expected converted currency to be USD, got %v", converted.Currency)
|
|
}
|
|
|
|
if converted.Value.Cmp(decimal.NewFromInt(32_000)) != 0 {
|
|
t.Fatalf("expected converted amount to be 32000, got %v", converted.Value)
|
|
}
|
|
|
|
}
|