aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/keystore
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-02-11 23:02:00 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-02-13 20:00:12 +0800
commite99c788155ddd754c73d2c81b6051dcbd42e6575 (patch)
tree1b219c22d8e288c8b12c9125adb709686664aa9e /accounts/keystore
parentc7022c1a0c2aa4c0326129ef483b27bcd6c1262d (diff)
downloadgo-tangerine-e99c788155ddd754c73d2c81b6051dcbd42e6575.tar
go-tangerine-e99c788155ddd754c73d2c81b6051dcbd42e6575.tar.gz
go-tangerine-e99c788155ddd754c73d2c81b6051dcbd42e6575.tar.bz2
go-tangerine-e99c788155ddd754c73d2c81b6051dcbd42e6575.tar.lz
go-tangerine-e99c788155ddd754c73d2c81b6051dcbd42e6575.tar.xz
go-tangerine-e99c788155ddd754c73d2c81b6051dcbd42e6575.tar.zst
go-tangerine-e99c788155ddd754c73d2c81b6051dcbd42e6575.zip
accounts: ledger and HD review fixes
- Handle a data race where a Ledger drops between list and open - Prolong Ledger tx confirmation window to 30 days from 1 minute - Simplify Ledger chainid-signature calculation and validation - Simplify Ledger USB APDU request chunking algorithm - Silence keystore account cache notifications for manual actions - Only enable self derivations if wallet open succeeds
Diffstat (limited to 'accounts/keystore')
-rw-r--r--accounts/keystore/account_cache.go9
-rw-r--r--accounts/keystore/account_cache_test.go17
-rw-r--r--accounts/keystore/keystore_test.go2
3 files changed, 2 insertions, 26 deletions
diff --git a/accounts/keystore/account_cache.go b/accounts/keystore/account_cache.go
index e2f826250..3fae3ef5b 100644
--- a/accounts/keystore/account_cache.go
+++ b/accounts/keystore/account_cache.go
@@ -113,11 +113,6 @@ func (ac *accountCache) add(newAccount accounts.Account) {
copy(ac.all[i+1:], ac.all[i:])
ac.all[i] = newAccount
ac.byAddr[newAccount.Address] = append(ac.byAddr[newAccount.Address], newAccount)
-
- select {
- case ac.notify <- struct{}{}:
- default:
- }
}
// note: removed needs to be unique here (i.e. both File and Address must be set).
@@ -131,10 +126,6 @@ func (ac *accountCache) delete(removed accounts.Account) {
} else {
ac.byAddr[removed.Address] = ba
}
- select {
- case ac.notify <- struct{}{}:
- default:
- }
}
func removeAccount(slice []accounts.Account, elem accounts.Account) []accounts.Account {
diff --git a/accounts/keystore/account_cache_test.go b/accounts/keystore/account_cache_test.go
index 3e68351ea..554196321 100644
--- a/accounts/keystore/account_cache_test.go
+++ b/accounts/keystore/account_cache_test.go
@@ -140,7 +140,7 @@ func TestCacheInitialReload(t *testing.T) {
}
func TestCacheAddDeleteOrder(t *testing.T) {
- cache, notify := newAccountCache("testdata/no-such-dir")
+ cache, _ := newAccountCache("testdata/no-such-dir")
cache.watcher.running = true // prevent unexpected reloads
accs := []accounts.Account{
@@ -176,20 +176,10 @@ func TestCacheAddDeleteOrder(t *testing.T) {
for _, a := range accs {
cache.add(a)
}
- select {
- case <-notify:
- default:
- t.Fatalf("notifications didn't fire for adding new accounts")
- }
// Add some of them twice to check that they don't get reinserted.
cache.add(accs[0])
cache.add(accs[2])
- select {
- case <-notify:
- t.Fatalf("notifications fired for adding existing accounts")
- default:
- }
// Check that the account list is sorted by filename.
wantAccounts := make([]accounts.Account, len(accs))
copy(wantAccounts, accs)
@@ -213,11 +203,6 @@ func TestCacheAddDeleteOrder(t *testing.T) {
}
cache.delete(accounts.Account{Address: common.HexToAddress("fd9bd350f08ee3c0c19b85a8e16114a11a60aa4e"), URL: accounts.URL{Scheme: KeyStoreScheme, Path: "something"}})
- select {
- case <-notify:
- default:
- t.Fatalf("notifications didn't fire for deleting accounts")
- }
// Check content again after deletion.
wantAccountsAfterDelete := []accounts.Account{
wantAccounts[1],
diff --git a/accounts/keystore/keystore_test.go b/accounts/keystore/keystore_test.go
index 1f1935be6..60f2606ee 100644
--- a/accounts/keystore/keystore_test.go
+++ b/accounts/keystore/keystore_test.go
@@ -286,7 +286,7 @@ func TestWalletNotifications(t *testing.T) {
// Randomly add and remove account and make sure events and wallets are in sync
live := make(map[common.Address]accounts.Account)
- for i := 0; i < 256; i++ {
+ for i := 0; i < 1024; i++ {
// Execute a creation or deletion and ensure event arrival
if create := len(live) == 0 || rand.Int()%4 > 0; create {
// Add a new account and ensure wallet notifications arrives