-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkeys_test.go
48 lines (41 loc) · 1.14 KB
/
keys_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
package gosdk_test
import (
"testing"
"github.com/NibiruChain/nibiru/gosdk"
"github.com/stretchr/testify/require"
)
var LOCALNET_VALIDATOR_MNEMONIC = "guard cream sadness conduct invite crumble clock pudding hole grit liar hotel maid produce squeeze return argue turtle know drive eight casino maze host"
func TestCreateSigner(t *testing.T) {
testCases := []struct {
testName string
mnemonic string
expectErr bool
}{
{testName: "bad input", mnemonic: "not a mnemonic", expectErr: true},
{
testName: "good input (localnet genesis)",
mnemonic: LOCALNET_VALIDATOR_MNEMONIC,
expectErr: false,
},
}
for _, tc := range testCases {
t.Run(tc.testName, func(t *testing.T) {
kring := gosdk.NewKeyring()
keyName := ""
signer, privKey, err := gosdk.CreateSigner(tc.mnemonic, kring, keyName)
if tc.expectErr {
require.Error(t, err)
return
}
require.NoError(t, err)
require.NotNil(t, signer.PubKey)
err = gosdk.AddSignerToKeyring(kring, privKey, privKey.PubKey().String())
require.NoError(t, err)
})
}
}
func TestKeyring(t *testing.T) {
require.NotPanics(t, func() {
_ = gosdk.NewKeyring()
})
}