Skip to content

Commit fd8a4bf

Browse files
Steven Wangjorgemmsilva
authored andcommitted
accounts: fix TestUpdateKeyfileContents (ethereum#29867)
Create the directory before NewKeyStore. This ensures the watcher successfully starts on the first attempt, and waitWatcherStart functions as intended.
1 parent ffdede5 commit fd8a4bf

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

accounts/keystore/account_cache_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,11 @@ func TestUpdatedKeyfileContents(t *testing.T) {
326326

327327
// Create a temporary keystore to test with
328328
dir := filepath.Join(os.TempDir(), fmt.Sprintf("eth-keystore-updatedkeyfilecontents-test-%d-%d", os.Getpid(), rand.Int()))
329+
330+
// Create the directory
331+
os.MkdirAll(dir, 0700)
332+
defer os.RemoveAll(dir)
333+
329334
ks := NewKeyStore(dir, LightScryptN, LightScryptP)
330335

331336
list := ks.Accounts()
@@ -335,9 +340,7 @@ func TestUpdatedKeyfileContents(t *testing.T) {
335340
if !waitWatcherStart(ks) {
336341
t.Fatal("keystore watcher didn't start in time")
337342
}
338-
// Create the directory and copy a key file into it.
339-
os.MkdirAll(dir, 0700)
340-
defer os.RemoveAll(dir)
343+
// Copy a key file into it
341344
file := filepath.Join(dir, "aaa")
342345

343346
// Place one of our testfiles in there

0 commit comments

Comments
 (0)