Skip to content

Commit

Permalink
accounts/keystore: don't modify cachetestAccounts in parallel tests
Browse files Browse the repository at this point in the history
  • Loading branch information
darioush committed Apr 11, 2024
1 parent 2ecbbbd commit cbadfc4
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions accounts/keystore/account_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,12 @@ func TestWatchNoDir(t *testing.T) {
}

// ks should see the account.
wantAccounts := []accounts.Account{cachetestAccounts[0]}
wantAccounts[0].URL = accounts.URL{Scheme: KeyStoreScheme, Path: file}
wantAccounts := []accounts.Account{
{
Address: cachetestAccounts[0].Address,
URL: accounts.URL{Scheme: KeyStoreScheme, Path: file},
},
}
for d := 200 * time.Millisecond; d < 8*time.Second; d *= 2 {
list = ks.Accounts()
if reflect.DeepEqual(list, wantAccounts) {
Expand Down Expand Up @@ -356,8 +360,12 @@ func TestUpdatedKeyfileContents(t *testing.T) {
}

// ks should see the account.
wantAccounts := []accounts.Account{cachetestAccounts[0]}
wantAccounts[0].URL = accounts.URL{Scheme: KeyStoreScheme, Path: file}
wantAccounts := []accounts.Account{
{
Address: cachetestAccounts[0].Address,
URL: accounts.URL{Scheme: KeyStoreScheme, Path: file},
},
}
if err := waitForAccounts(wantAccounts, ks); err != nil {
t.Error(err)
return
Expand All @@ -370,8 +378,12 @@ func TestUpdatedKeyfileContents(t *testing.T) {
t.Fatal(err)
return
}
wantAccounts = []accounts.Account{cachetestAccounts[1]}
wantAccounts[0].URL = accounts.URL{Scheme: KeyStoreScheme, Path: file}
wantAccounts = []accounts.Account{
{
Address: cachetestAccounts[1].Address,
URL: accounts.URL{Scheme: KeyStoreScheme, Path: file},
},
}
if err := waitForAccounts(wantAccounts, ks); err != nil {
t.Errorf("First replacement failed")
t.Error(err)
Expand All @@ -386,8 +398,12 @@ func TestUpdatedKeyfileContents(t *testing.T) {
t.Fatal(err)
return
}
wantAccounts = []accounts.Account{cachetestAccounts[2]}
wantAccounts[0].URL = accounts.URL{Scheme: KeyStoreScheme, Path: file}
wantAccounts = []accounts.Account{
{
Address: cachetestAccounts[2].Address,
URL: accounts.URL{Scheme: KeyStoreScheme, Path: file},
},
}
if err := waitForAccounts(wantAccounts, ks); err != nil {
t.Errorf("Second replacement failed")
t.Error(err)
Expand Down

0 comments on commit cbadfc4

Please sign in to comment.