-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathxrp_test.go
60 lines (53 loc) · 1.36 KB
/
xrp_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
package coincodec
import (
"testing"
"github.com/pkg/errors"
"github.com/wealdtech/go-slip44"
)
func TestXRPEncodeToBytes(t *testing.T) {
tests := []TestcaseEncode {
{
name: "Normal",
input: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
output: "004b4e9c06f24296074f7bc48f92a97916c6dc5ea9",
},
{
name: "Normal2",
input: "X7qvLs7gSnNoKvZzNWUT2e8st17QPY64PPe7zriLNuJszeg",
output: "05444b4e9c06f24296074f7bc48f92a97916c6dc5ea9000000000000000000",
},
{
name: "Short",
input: "123",
err: errors.New("base58 decode error: Base58 string too short: 123"),
},
{
name: "Short with checksum",
input: "1FuGcFfSmQMU2cMR",
err: errors.New("base58 decode error: Bad Base58 checksum"),
},
{
name: "Bitcoin",
input: "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
err: errors.New("base58 decode error: Bad Base58 checksum"),
},
}
RunTestsEncode(t, slip44.RIPPLE, tests)
}
func TestXRPDecodeToString(t *testing.T) {
keyhash := "004b4e9c06f24296074f7bc48f92a97916c6dc5ea9"
keyhash2 := "05444b4e9c06f24296074f7bc48f92a97916c6dc5ea9000000000000000000"
tests := []TestcaseDecode {
{
name: "Good",
input: keyhash,
output: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
},
{
name: "Good2",
input: keyhash2,
output: "X7qvLs7gSnNoKvZzNWUT2e8st17QPY64PPe7zriLNuJszeg",
},
}
RunTestsDecode(t, slip44.RIPPLE, tests)
}