forked from cosmos/ledger-cosmos-go
-
Notifications
You must be signed in to change notification settings - Fork 4
/
validator_app_test.go
64 lines (54 loc) · 1.95 KB
/
validator_app_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
/*******************************************************************************
* (c) 2018 - 2022 ZondaX AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
********************************************************************************/
package ledger_cosmos_go
import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)
func Test_ValGetVersion(t *testing.T) {
validatorApp, err := FindLedgerTendermintValidatorApp()
if err != nil {
t.Fatalf(err.Error())
}
defer validatorApp.Close()
version, err := validatorApp.GetVersion()
require.Nil(t, err, "Detected error")
assert.Equal(t, uint8(0x0), version.AppMode, "TESTING MODE NOT ENABLED")
assert.Equal(t, uint8(0x0), version.Major, "Wrong Major version")
assert.Equal(t, uint8(0x9), version.Minor, "Wrong Minor version")
assert.Equal(t, uint8(0x0), version.Patch, "Wrong Patch version")
}
func Test_ValGetPublicKey(t *testing.T) {
validatorApp, err := FindLedgerTendermintValidatorApp()
if err != nil {
t.Fatalf(err.Error())
}
defer validatorApp.Close()
path := []uint32{44, 118, 0, 0, 0}
for i := 1; i < 10; i++ {
pubKey, err := validatorApp.GetPublicKeyED25519(path)
require.Nil(t, err, "Detected error, err: %s\n", err)
assert.Equal(
t,
32,
len(pubKey),
"Public key has wrong length: %x, expected length: %x\n", pubKey, 32)
}
}
func Test_ValSignED25519(t *testing.T) {
t.Skip("Go support is still not available. Please refer to the Rust library")
}