-
Notifications
You must be signed in to change notification settings - Fork 0
/
type_test.go
69 lines (65 loc) · 1.38 KB
/
type_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package nimiqrpc
import (
"testing"
)
func TestLunaToNIM(t *testing.T) {
// 0 luna is 0 NIM
if FormatNIM(0) != "0" {
t.Fail()
}
// 1 luna is 0.00001 NIM
if FormatNIM(1) != "0.00001" {
t.Fail()
}
// 100000 luna is 1 NIM
if FormatNIM(100000) != "1" {
t.Fail()
}
// 1234567 is 12.34567 NIM
if FormatNIM(1234567) != "12.34567" {
t.Fail()
}
// 1200000 is 12 NIM
if FormatNIM(1200000) != "12" {
t.Fail()
}
// 123456789 is 1234.56789 NIM
if FormatNIM(123456789) != "1234.56789" {
t.Fail()
}
}
func TestNIMToLuna(t *testing.T) {
// 0 NIM is 0 Luna
if l, _ := FormatLuna("0"); l != 0 {
t.Fail()
}
// 0.00001 NIM is 1 Luna
if l, _ := FormatLuna("0.00001"); l != 1 {
t.Fail()
}
// 1 NIM is 100000 Luna
if l, _ := FormatLuna("1"); l != 100000 {
t.Fail()
}
// 12.34567 NIM is 1234567 Luna
if l, _ := FormatLuna("12.34567"); l != 1234567 {
t.Fail()
}
// 12 NIM is 1200000 Luna
if l, _ := FormatLuna("12"); l != 1200000 {
t.Fail()
}
// 1234.56789 NIM is 123456789 Luna
if l, _ := FormatLuna("1234.56789"); l != 123456789 {
t.Fail()
}
}
// The Nimiq Network has been designed for a total supply of 21 Billion NIM.
// The smallest unit of NIM is called Luna and 100’000 (1e5) Luna equal 1 NIM,
// which results in a total supply of 21e14 Luna
func TestMaxLuna(t *testing.T) {
max, _ := FormatLuna("21000000000")
if max != 2100000000000000 {
t.Fail()
}
}