forked from calvinlauyh/cosmosutils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmpubkey_test.go
More file actions
27 lines (23 loc) · 978 Bytes
/
tmpubkey_test.go
File metadata and controls
27 lines (23 loc) · 978 Bytes
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
package cosmosutils_test
import (
"encoding/base64"
"testing"
"github.com/calvinlauyh/cosmosutils"
"github.com/stretchr/testify/assert"
)
func TestConsensusNodeAddressFromTmPubKey(t *testing.T) {
prefix := "tcrocnclcons"
tmpubkey, err := base64.StdEncoding.DecodeString("Og8ZfQTHFgTBGD5qoyo5NpyJCJRddC+WuSPtyZtlE7E=")
assert.NoError(t, err)
consensusNodeAddress, err := cosmosutils.ConsensusNodeAddressFromTmPubKey(prefix, tmpubkey)
assert.NoError(t, err)
expected := "tcrocnclcons1wqajdt4qseasx4e8r8fz7juwdkfu4quvt9e87u"
assert.Equal(t, expected, consensusNodeAddress)
}
func TestConsensusNodeAddressFromPubKey(t *testing.T) {
prefix := "tcrocnclcons"
consensusNodeAddress, err := cosmosutils.ConsensusNodeAddressFromPubKey(prefix, "tcrocnclconspub1zcjduepq8g83jlgycutqfsgc8e42x23ex6wgjzy5t46zl94ey0kunxm9zwcsuzkxpr")
assert.NoError(t, err)
expected := "tcrocnclcons1wqajdt4qseasx4e8r8fz7juwdkfu4quvt9e87u"
assert.Equal(t, expected, consensusNodeAddress)
}