accounts/keystore: fix double import race (#20915)
* accounts/keystore: fix race in Import/ImportECDSA * accounts/keystore: added import/export tests * cmd/geth: improved TestAccountImport test * accounts/keystore: added import/export tests * accounts/keystore: fixed naming * accounts/keystore: fixed typo * accounts/keystore: use mutex instead of rwmutex * accounts: use errors instead of fmt
This commit is contained in:
committed by
GitHub
parent
2ec7232191
commit
38aab0aa83
@ -89,18 +89,23 @@ Path of the secret key file: .*UTC--.+--[0-9a-f]{40}
|
||||
}
|
||||
|
||||
func TestAccountImport(t *testing.T) {
|
||||
tests := []struct{ key, output string }{
|
||||
tests := []struct{ name, key, output string }{
|
||||
{
|
||||
name: "correct account",
|
||||
key: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
|
||||
output: "Address: {fcad0b19bb29d4674531d6f115237e16afce377c}\n",
|
||||
},
|
||||
{
|
||||
name: "invalid character",
|
||||
key: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef1",
|
||||
output: "Fatal: Failed to load the private key: invalid character '1' at end of key file\n",
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
importAccountWithExpect(t, test.key, test.output)
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
importAccountWithExpect(t, test.key, test.output)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user