-
Notifications
You must be signed in to change notification settings - Fork 257
/
test_util.go
40 lines (32 loc) · 986 Bytes
/
test_util.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
package types
import (
"testing"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
)
const (
// nolint:lll
TestAccName = "test-account"
testMnemo = `ramp soldier connect gadget domain mutual staff unusual first midnight iron good deputy wage vehicle mutual spike unlock rocket delay hundred script tumble choose`
testChainID = "test-chain-1"
)
func GenerateKeyring(t *testing.T, accts ...string) keyring.Keyring {
t.Helper()
encCfg := makeBlobEncodingConfig()
kb := keyring.NewInMemory(encCfg.Codec)
for _, acc := range accts {
_, _, err := kb.NewMnemonic(acc, keyring.English, "", "", hd.Secp256k1)
if err != nil {
t.Error(err)
}
}
_, err := kb.NewAccount(TestAccName, testMnemo, "", "", hd.Secp256k1)
if err != nil {
panic(err)
}
return kb
}
func GenerateKeyringSigner(t *testing.T, accts ...string) *KeyringSigner {
kr := GenerateKeyring(t, accts...)
return NewKeyringSigner(kr, TestAccName, testChainID)
}