-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd07f58
commit 9a4c9f8
Showing
3 changed files
with
61 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//go:build !ledger_suite | ||
// +build !ledger_suite | ||
|
||
package keys | ||
|
||
import "testing" | ||
|
||
func TestCreateLedgerUnsupportedAlgo(t *testing.T) { | ||
t.Parallel() | ||
|
||
t.Skip("this test needs to be run with the `ledger_suite` tag enabled") | ||
} | ||
|
||
func TestCreateLedger(t *testing.T) { | ||
t.Parallel() | ||
|
||
t.Skip("this test needs to be run with the `ledger_suite` tag enabled") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//go:build ledger_suite | ||
// +build ledger_suite | ||
|
||
package keys | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestCreateLedgerUnsupportedAlgo(t *testing.T) { | ||
t.Parallel() | ||
|
||
kb := NewInMemory() | ||
_, err := kb.CreateLedger("some_account", Ed25519, "cosmos", 0, 1) | ||
assert.Error(t, err) | ||
assert.Equal(t, "unsupported signing algo: only secp256k1 is supported", err.Error()) | ||
} | ||
|
||
func TestCreateLedger(t *testing.T) { | ||
t.Parallel() | ||
|
||
kb := NewInMemory() | ||
|
||
// test_cover and test_unit will result in different answers | ||
// test_cover does not compile some dependencies so ledger is disabled | ||
// test_unit may add a ledger mock | ||
// both cases are acceptable | ||
_, err := kb.CreateLedger("some_account", Secp256k1, "cosmos", 3, 1) | ||
require.NoError(t, err) | ||
|
||
// Check that restoring the key gets the same results | ||
restoredKey, err := kb.GetByName("some_account") | ||
assert.NotNil(t, restoredKey) | ||
assert.Equal(t, "some_account", restoredKey.GetName()) | ||
assert.Equal(t, TypeLedger, restoredKey.GetType()) | ||
|
||
path, err := restoredKey.GetPath() | ||
assert.NoError(t, err) | ||
assert.Equal(t, "44'/118'/3'/0/1", path.String()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters