Skip to content

Commit

Permalink
Merge pull request #21 from ZondaX/fix/conn_lost
Browse files Browse the repository at this point in the history
Fixing connection issues in OSX
  • Loading branch information
jleni authored Jan 29, 2019
2 parents 71aa0ab + a9bc665 commit e236ef2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 35 deletions.
34 changes: 17 additions & 17 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[[constraint]]
name = "github.com/ZondaX/ledger-go"
version = "v0.4.0"
version = "v0.5.0"

[prune]
go-tests = true
unused-packages = true
[[prune.project]]
name = "github.com/karalabe/hid"
unused-packages = false
6 changes: 3 additions & 3 deletions common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func Test_PathGeneration0(t *testing.T) {
pathBytes, err := getBip32bytes(bip32Path, 0)

if err != nil {
assert.FailNow(t, "Detected error, err: %s\n", err.Error())
t.Fatalf( "Detected error, err: %s\n", err.Error())
}

fmt.Printf("Path: %x\n", pathBytes)
Expand All @@ -52,7 +52,7 @@ func Test_PathGeneration2(t *testing.T) {
pathBytes, err := getBip32bytes(bip32Path, 2)

if err != nil {
assert.FailNow(t, "Detected error, err: %s\n", err.Error())
t.Fatalf("Detected error, err: %s\n", err.Error())
}

fmt.Printf("Path: %x\n", pathBytes)
Expand All @@ -76,7 +76,7 @@ func Test_PathGeneration3(t *testing.T) {
pathBytes, err := getBip32bytes(bip32Path, 3)

if err != nil {
assert.FailNow(t, "Detected error, err: %s\n", err.Error())
t.Fatalf("Detected error, err: %s\n", err.Error())
}

fmt.Printf("Path: %x\n", pathBytes)
Expand Down
22 changes: 11 additions & 11 deletions user_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ package ledger_cosmos_go

import (
"fmt"
secp256k1 "github.com/btcsuite/btcd/btcec"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto"
"strings"
"testing"
secp256k1 "github.com/btcsuite/btcd/btcec"
"github.com/tendermint/tendermint/crypto"
)

func Test_UserGetVersion(t *testing.T) {
userApp, err := FindLedgerCosmosUserApp()
if err != nil {
assert.Error(t, err)
t.Fatalf( err.Error())
}

userApp.api.Logging = true
Expand All @@ -49,7 +49,7 @@ func Test_UserGetVersion(t *testing.T) {
func Test_UserGetPublicKey(t *testing.T) {
userApp, err := FindLedgerCosmosUserApp()
if err != nil {
assert.Error(t, err)
t.Fatalf( err.Error())
}

userApp.api.Logging = true
Expand All @@ -58,7 +58,7 @@ func Test_UserGetPublicKey(t *testing.T) {

pubKey, err := userApp.GetPublicKeySECP256K1(path)
if err != nil {
assert.FailNow(t, "Detected error, err: %s\n", err.Error())
t.Fatalf("Detected error, err: %s\n", err.Error())
}

assert.Equal(
Expand Down Expand Up @@ -107,35 +107,35 @@ func Test_UserSign(t *testing.T) {
message := getDummyTx()
signature, err := userApp.SignSECP256K1(path, message)
if err != nil {
assert.FailNow(t,"[Sign] Error: %s\n", err.Error())
t.Fatalf("[Sign] Error: %s\n", err.Error())
}

// Verify Signature
pubKey, err := userApp.GetPublicKeySECP256K1(path)
if err != nil {
assert.FailNow(t, "Detected error, err: %s\n", err.Error())
t.Fatalf("Detected error, err: %s\n", err.Error())
}

if err != nil {
assert.FailNow(t, "[GetPK] Error: " + err.Error())
t.Fatalf( "[GetPK] Error: " + err.Error())
return
}

pub__, err := secp256k1.ParsePubKey(pubKey[:], secp256k1.S256())
if err != nil {
assert.FailNow(t, "[ParsePK] Error: " + err.Error())
t.Fatalf( "[ParsePK] Error: " + err.Error())
return
}

sig__, err := secp256k1.ParseDERSignature(signature[:], secp256k1.S256())
if err != nil {
assert.FailNow(t, "[ParseSig] Error: " + err.Error())
t.Fatalf( "[ParseSig] Error: " + err.Error())
return
}

verified := sig__.Verify(crypto.Sha256(message), pub__)
if !verified {
assert.FailNow(t, "[VerifySig] Error verifying signature: " + err.Error())
t.Fatalf( "[VerifySig] Error verifying signature: " + err.Error())
return
}
}
6 changes: 3 additions & 3 deletions validator_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
func Test_ValGetVersion(t *testing.T) {
validatorApp, err := FindLedgerCosmosValidatorApp()
if err != nil {
assert.FailNow(t, err.Error())
t.Fatalf( err.Error())
}

validatorApp.api.Logging = true
Expand All @@ -44,7 +44,7 @@ func Test_ValGetVersion(t *testing.T) {
func Test_ValGetPublicKey(t *testing.T) {
validatorApp, err := FindLedgerCosmosValidatorApp()
if err != nil {
assert.FailNow(t, err.Error())
t.Fatalf( err.Error())
}

validatorApp.api.Logging = true
Expand All @@ -67,7 +67,7 @@ func Test_ValGetPublicKey(t *testing.T) {
func Test_ValSignED25519(t *testing.T) {
validatorApp, err := FindLedgerCosmosValidatorApp()
if err != nil {
assert.FailNow(t, err.Error())
t.Fatalf( err.Error())
}

validatorApp.api.Logging = true
Expand Down

0 comments on commit e236ef2

Please sign in to comment.