fixed8: fix Satoshi() and add a test for it

This commit is contained in:
Roman Khimov 2019-08-23 15:37:01 +03:00
parent 20a4ad99b3
commit b0af8b306d
2 changed files with 6 additions and 1 deletions

View file

@ -116,7 +116,7 @@ func (f Fixed8) MarshalJSON() ([]byte, error) {
// Satoshi defines the value of a 'Satoshi'. // Satoshi defines the value of a 'Satoshi'.
func Satoshi() Fixed8 { func Satoshi() Fixed8 {
return NewFixed8(1) return Fixed8(1)
} }
// Div implements Fixd8 division operator. // Div implements Fixd8 division operator.

View file

@ -66,6 +66,11 @@ func TestFixed8DecodeString(t *testing.T) {
assert.Equal(t, Fixed8(90123410000), n) assert.Equal(t, Fixed8(90123410000), n)
} }
func TestSatoshi(t *testing.T) {
satoshif8 := Satoshi()
assert.Equal(t, "0.00000001", satoshif8.String())
}
func TestFixed8UnmarshalJSON(t *testing.T) { func TestFixed8UnmarshalJSON(t *testing.T) {
var testCases = []float64{ var testCases = []float64{
123.45, 123.45,