-
Notifications
You must be signed in to change notification settings - Fork 10
/
enterprise_address_test.go
94 lines (88 loc) · 2.2 KB
/
enterprise_address_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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package libada
import (
"encoding/hex"
"testing"
)
func TestEnterprise_String(t *testing.T) {
type fields struct {
Network Network
Payment StakeCredential
}
MustDecodeHex := func(raw string) []byte {
b, err := hex.DecodeString(raw)
if err != nil {
t.Fatal(err)
}
return b
}
tests := []struct {
name string
fields fields
want string
}{
{
name: "testnet address",
fields: fields{
Network: Testnet,
Payment: StakeCredential{
Kind: KeyStakeCredentialType,
Data: MustDecodeHex("7ffcf441f7bae81f15e61fda81833eef8ee779a1f83aaab2371598a5"),
},
},
want: "addr_test1vplleazp77aws8c4uc0a4qvr8mhcaeme58ur424jxu2e3fg6cgfgj",
},
{
name: "mainnet address",
fields: fields{
Network: Mainnet,
Payment: StakeCredential{
Kind: KeyStakeCredentialType,
Data: MustDecodeHex("7ffcf441f7bae81f15e61fda81833eef8ee779a1f83aaab2371598a5"),
},
},
want: "addr1v9lleazp77aws8c4uc0a4qvr8mhcaeme58ur424jxu2e3fgpsu48h",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
e := &EnterpriseAddress{
Network: tt.fields.Network,
Payment: tt.fields.Payment,
}
if got := e.String(); got != tt.want {
t.Errorf("Enterprise.String() = %v, want %v", got, tt.want)
}
})
}
}
func TestNewEnterprise(t *testing.T) {
pubkey := []byte{62, 10, 246, 49, 19, 79, 17, 153, 156, 252, 94, 21, 12, 6, 65, 246, 17, 58, 139, 207, 101, 15, 20, 43, 229, 253, 173, 13, 9, 102, 211, 130}
type args struct {
key []byte
kind StakeCredentialType
network Network
}
tests := []struct {
name string
args args
want string
}{
{
name: "testnet",
args: args{key: pubkey, kind: KeyStakeCredentialType, network: Testnet},
want: "addr_test1vqpjd93t42ju4majh9tcz69z2fvmaeyxzxvpr3x95g9mw4sxmvk7w",
},
{
name: "mainnet",
args: args{key: pubkey, kind: KeyStakeCredentialType, network: Mainnet},
want: "addr1vypjd93t42ju4majh9tcz69z2fvmaeyxzxvpr3x95g9mw4sanc23t",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewEnterpriseAddress(tt.args.key, tt.args.kind, tt.args.network).String(); got != tt.want {
t.Errorf("NewEnterprise() = %s, want %s", got, tt.want)
}
})
}
}