Skip to content

Commit 63b53f9

Browse files
undefinedorjorgemmsilva
authored andcommitted
accounts: remove deprecated function NewPlaintextKeyStore (ethereum#29171)
1 parent 21d619c commit 63b53f9

File tree

3 files changed

+16
-29
lines changed

3 files changed

+16
-29
lines changed

accounts/keystore/account_cache_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func waitForAccounts(wantAccounts []accounts.Account, ks *KeyStore) error {
8686
func TestWatchNewFile(t *testing.T) {
8787
t.Parallel()
8888

89-
dir, ks := tmpKeyStore(t, false)
89+
dir, ks := tmpKeyStore(t)
9090

9191
// Ensure the watcher is started before adding any files.
9292
ks.Accounts()

accounts/keystore/keystore.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,6 @@ func NewKeyStore(keydir string, scryptN, scryptP int) *KeyStore {
8787
return ks
8888
}
8989

90-
// NewPlaintextKeyStore creates a keystore for the given directory.
91-
// Deprecated: Use NewKeyStore.
92-
func NewPlaintextKeyStore(keydir string) *KeyStore {
93-
keydir, _ = filepath.Abs(keydir)
94-
ks := &KeyStore{storage: &keyStorePlain{keydir}}
95-
ks.init(keydir)
96-
return ks
97-
}
98-
9990
func (ks *KeyStore) init(keydir string) {
10091
// Lock the mutex since the account cache might call back with events
10192
ks.mu.Lock()

accounts/keystore/keystore_test.go

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var testSigData = make([]byte, 32)
3737

3838
func TestKeyStore(t *testing.T) {
3939
t.Parallel()
40-
dir, ks := tmpKeyStore(t, true)
40+
dir, ks := tmpKeyStore(t)
4141

4242
a, err := ks.NewAccount("foo")
4343
if err != nil {
@@ -72,7 +72,7 @@ func TestKeyStore(t *testing.T) {
7272

7373
func TestSign(t *testing.T) {
7474
t.Parallel()
75-
_, ks := tmpKeyStore(t, true)
75+
_, ks := tmpKeyStore(t)
7676

7777
pass := "" // not used but required by API
7878
a1, err := ks.NewAccount(pass)
@@ -89,7 +89,7 @@ func TestSign(t *testing.T) {
8989

9090
func TestSignWithPassphrase(t *testing.T) {
9191
t.Parallel()
92-
_, ks := tmpKeyStore(t, true)
92+
_, ks := tmpKeyStore(t)
9393

9494
pass := "passwd"
9595
acc, err := ks.NewAccount(pass)
@@ -117,7 +117,7 @@ func TestSignWithPassphrase(t *testing.T) {
117117

118118
func TestTimedUnlock(t *testing.T) {
119119
t.Parallel()
120-
_, ks := tmpKeyStore(t, true)
120+
_, ks := tmpKeyStore(t)
121121

122122
pass := "foo"
123123
a1, err := ks.NewAccount(pass)
@@ -152,7 +152,7 @@ func TestTimedUnlock(t *testing.T) {
152152

153153
func TestOverrideUnlock(t *testing.T) {
154154
t.Parallel()
155-
_, ks := tmpKeyStore(t, false)
155+
_, ks := tmpKeyStore(t)
156156

157157
pass := "foo"
158158
a1, err := ks.NewAccount(pass)
@@ -193,7 +193,7 @@ func TestOverrideUnlock(t *testing.T) {
193193
// This test should fail under -race if signing races the expiration goroutine.
194194
func TestSignRace(t *testing.T) {
195195
t.Parallel()
196-
_, ks := tmpKeyStore(t, false)
196+
_, ks := tmpKeyStore(t)
197197

198198
// Create a test account.
199199
a1, err := ks.NewAccount("")
@@ -238,7 +238,7 @@ func waitForKsUpdating(t *testing.T, ks *KeyStore, wantStatus bool, maxTime time
238238
func TestWalletNotifierLifecycle(t *testing.T) {
239239
t.Parallel()
240240
// Create a temporary keystore to test with
241-
_, ks := tmpKeyStore(t, false)
241+
_, ks := tmpKeyStore(t)
242242

243243
// Ensure that the notification updater is not running yet
244244
time.Sleep(250 * time.Millisecond)
@@ -284,7 +284,7 @@ type walletEvent struct {
284284
// or deleted from the keystore.
285285
func TestWalletNotifications(t *testing.T) {
286286
t.Parallel()
287-
_, ks := tmpKeyStore(t, false)
287+
_, ks := tmpKeyStore(t)
288288

289289
// Subscribe to the wallet feed and collect events.
290290
var (
@@ -346,7 +346,7 @@ func TestWalletNotifications(t *testing.T) {
346346
// TestImportExport tests the import functionality of a keystore.
347347
func TestImportECDSA(t *testing.T) {
348348
t.Parallel()
349-
_, ks := tmpKeyStore(t, true)
349+
_, ks := tmpKeyStore(t)
350350
key, err := crypto.GenerateKey()
351351
if err != nil {
352352
t.Fatalf("failed to generate key: %v", key)
@@ -365,7 +365,7 @@ func TestImportECDSA(t *testing.T) {
365365
// TestImportECDSA tests the import and export functionality of a keystore.
366366
func TestImportExport(t *testing.T) {
367367
t.Parallel()
368-
_, ks := tmpKeyStore(t, true)
368+
_, ks := tmpKeyStore(t)
369369
acc, err := ks.NewAccount("old")
370370
if err != nil {
371371
t.Fatalf("failed to create account: %v", acc)
@@ -374,7 +374,7 @@ func TestImportExport(t *testing.T) {
374374
if err != nil {
375375
t.Fatalf("failed to export account: %v", acc)
376376
}
377-
_, ks2 := tmpKeyStore(t, true)
377+
_, ks2 := tmpKeyStore(t)
378378
if _, err = ks2.Import(json, "old", "old"); err == nil {
379379
t.Errorf("importing with invalid password succeeded")
380380
}
@@ -394,7 +394,7 @@ func TestImportExport(t *testing.T) {
394394
// This test should fail under -race if importing races.
395395
func TestImportRace(t *testing.T) {
396396
t.Parallel()
397-
_, ks := tmpKeyStore(t, true)
397+
_, ks := tmpKeyStore(t)
398398
acc, err := ks.NewAccount("old")
399399
if err != nil {
400400
t.Fatalf("failed to create account: %v", acc)
@@ -403,7 +403,7 @@ func TestImportRace(t *testing.T) {
403403
if err != nil {
404404
t.Fatalf("failed to export account: %v", acc)
405405
}
406-
_, ks2 := tmpKeyStore(t, true)
406+
_, ks2 := tmpKeyStore(t)
407407
var atom atomic.Uint32
408408
var wg sync.WaitGroup
409409
wg.Add(2)
@@ -457,11 +457,7 @@ func checkEvents(t *testing.T, want []walletEvent, have []walletEvent) {
457457
}
458458
}
459459

460-
func tmpKeyStore(t *testing.T, encrypted bool) (string, *KeyStore) {
460+
func tmpKeyStore(t *testing.T) (string, *KeyStore) {
461461
d := t.TempDir()
462-
newKs := NewPlaintextKeyStore
463-
if encrypted {
464-
newKs = func(kd string) *KeyStore { return NewKeyStore(kd, veryLightScryptN, veryLightScryptP) }
465-
}
466-
return d, newKs(d)
462+
return d, NewKeyStore(d, veryLightScryptN, veryLightScryptP)
467463
}

0 commit comments

Comments
 (0)