Skip to content

Commit

Permalink
Wrap up skipped tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zivkovicmilos committed Apr 16, 2024
1 parent fd07f58 commit 9a4c9f8
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 32 deletions.
18 changes: 18 additions & 0 deletions tm2/pkg/crypto/keys/keybase_ledger_skipped_test.go
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")
}
43 changes: 43 additions & 0 deletions tm2/pkg/crypto/keys/keybase_ledger_test.go
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())
}
32 changes: 0 additions & 32 deletions tm2/pkg/crypto/keys/keybase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,6 @@ func TestCreateAccountInvalidMnemonic(t *testing.T) {
assert.Equal(t, "invalid mnemonic", err.Error())
}

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())
}

// TestKeyManagement makes sure we can manipulate these keys well
func TestKeyManagement(t *testing.T) {
t.Parallel()
Expand Down

0 comments on commit 9a4c9f8

Please sign in to comment.