-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathoutput_test.go
31 lines (24 loc) · 1.09 KB
/
output_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
package keyring
import (
"testing"
"github.com/stretchr/testify/require"
kmultisig "github.com/line/lfb-sdk/crypto/keys/multisig"
"github.com/line/lfb-sdk/crypto/keys/secp256k1"
"github.com/line/lfb-sdk/crypto/types"
sdk "github.com/line/lfb-sdk/types"
)
func TestBech32KeysOutput(t *testing.T) {
tmpKey := secp256k1.GenPrivKey().PubKey()
bechTmpKey := sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeAccPub, tmpKey)
tmpAddr := sdk.BytesToAccAddress(tmpKey.Address())
multisigPks := kmultisig.NewLegacyAminoPubKey(1, []types.PubKey{tmpKey})
multiInfo := NewMultiInfo("multisig", multisigPks)
accAddr := sdk.BytesToAccAddress(multiInfo.GetPubKey().Address())
bechPubKey := sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeAccPub, multiInfo.GetPubKey())
expectedOutput := NewKeyOutput(multiInfo.GetName(), multiInfo.GetType().String(), accAddr.String(), bechPubKey)
expectedOutput.Threshold = 1
expectedOutput.PubKeys = []multisigPubKeyOutput{{tmpAddr.String(), bechTmpKey, 1}}
outputs, err := Bech32KeysOutput([]Info{multiInfo})
require.NoError(t, err)
require.Equal(t, expectedOutput, outputs[0])
}