commit b5cc1cfaa8eb0cb19d2030dca7f06bf25e53fc1a
parent 903c2fdca4c572deb74598350cede90e58ce891b
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date: Sun, 17 Jul 2022 13:16:02 +0200
fix
Diffstat:
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/pkg/util/amount.go b/pkg/util/amount.go
@@ -68,7 +68,7 @@ func (a *Amount) Add(b Amount) (*Amount,error) {
uint64(math.Floor((float64(a.Fraction) + float64(b.Fraction)) / FractionalBase))
if v >= MaxAmountValue {
- return nil, errors.New("Amount Overflow!")
+ return nil, errors.New(fmt.Sprintf("Amount Overflow (%d > %d)!", v, MaxAmountValue))
}
f := uint64((a.Fraction + b.Fraction) % FractionalBase)
r := Amount{
diff --git a/pkg/util/amount_test.go b/pkg/util/amount_test.go
@@ -2,6 +2,7 @@ package util
import (
"testing"
+ "fmt"
)
var a = Amount{
@@ -43,8 +44,11 @@ func TestAmountSub(t *testing.T) {
}
}
-func TestAmountString(t *testing.T) {
- if c.String() != "EUR:25.20007" {
- t.Errorf("Failed to generate correct string")
+func TestAmountLarge(t *testing.T) {
+ x, err := ParseAmount("EUR:50")
+ _, err = x.Add(a)
+ if nil != err {
+ fmt.Println(err)
+ t.Errorf("Failed")
}
}