Skip to content

Commit

Permalink
Merge pull request #48 from thetatoken/wallet
Browse files Browse the repository at this point in the history
Fix softwallet unit test
  • Loading branch information
jieyilong authored May 6, 2019
2 parents 0a6f05a + 4cda8d4 commit 481559a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion wallet/coldwallet/keystore/nano_ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (w *ledgerDriver) offline() bool {
func (w *ledgerDriver) Open(device io.ReadWriter, password string) error {
w.device, w.failure = device, nil

_, err := w.Derive(types.DefaultBaseDerivationPath)
_, err := w.Derive(types.DefaultRootDerivationPath)
if err != nil {
// Ethereum app is not running or in browser mode, nothing more to do, return
if err == errLedgerReplyInvalidHeader {
Expand Down Expand Up @@ -438,5 +438,8 @@ func (w *ledgerDriver) ledgerExchange(opcode ledgerOpcode, p1 ledgerParam1, p2 l
break
}
}
if len(reply) == 0 {
return w.ledgerExchange(opcode, p1, p2, data)
}
return reply[:len(reply)-2], nil
}
8 changes: 4 additions & 4 deletions wallet/softwallet/softwallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,17 @@ func testSoftWalletBasics(t *testing.T, ksType KeystoreType) {
err = wallet.UpdatePassword(addr, password1, password2) // update password for a closed password
assert.Nil(err)

err = wallet.Unlock(addr, password1)
err = wallet.Unlock(addr, password1, nil)
if ksType == KeystoreTypeEncrypted {
assert.NotNil(err)
}
err = wallet.Unlock(addr, password2)
err = wallet.Unlock(addr, password2, nil)
assert.Nil(err)
err = wallet.Lock(addr)
assert.Nil(err)

password3 := "Kdaw82892fDWO"
err = wallet.Unlock(addr, password2)
err = wallet.Unlock(addr, password2, nil)
assert.Nil(err)
err = wallet.UpdatePassword(addr, password2, password3) // update password for a unlocked password
assert.Nil(err)
Expand All @@ -94,7 +94,7 @@ func testSoftWalletBasics(t *testing.T, ksType KeystoreType) {
} else {
assert.Nil(err)
}
err = wallet.Unlock(addr, password3)
err = wallet.Unlock(addr, password3, nil)
assert.NotNil(err)
}

Expand Down

0 comments on commit 481559a

Please sign in to comment.