aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/accounts_test.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-03-02 20:57:15 +0800
committerFelix Lange <fjl@twurst.com>2016-04-12 21:56:49 +0800
commit85e6c40c0081bd0db80448640db648887804010c (patch)
tree326a2c3bc115a445b481624cb20f00b28e44f92a /accounts/accounts_test.go
parentdff9b4246f3ef9e6c254b57eef6d0433809f16b9 (diff)
downloadgo-tangerine-85e6c40c0081bd0db80448640db648887804010c.tar
go-tangerine-85e6c40c0081bd0db80448640db648887804010c.tar.gz
go-tangerine-85e6c40c0081bd0db80448640db648887804010c.tar.bz2
go-tangerine-85e6c40c0081bd0db80448640db648887804010c.tar.lz
go-tangerine-85e6c40c0081bd0db80448640db648887804010c.tar.xz
go-tangerine-85e6c40c0081bd0db80448640db648887804010c.tar.zst
go-tangerine-85e6c40c0081bd0db80448640db648887804010c.zip
accounts, crypto: move keystore to package accounts
The account management API was originally implemented as a thin layer around crypto.KeyStore, on the grounds that several kinds of key stores would be implemented later on. It turns out that this won't happen so KeyStore is a superflous abstraction. In this commit crypto.KeyStore and everything related to it moves to package accounts and is unexported.
Diffstat (limited to 'accounts/accounts_test.go')
-rw-r--r--accounts/accounts_test.go20
1 files changed, 9 insertions, 11 deletions
diff --git a/accounts/accounts_test.go b/accounts/accounts_test.go
index 55ddecdea..02dd74c8a 100644
--- a/accounts/accounts_test.go
+++ b/accounts/accounts_test.go
@@ -21,17 +21,14 @@ import (
"os"
"testing"
"time"
-
- "github.com/ethereum/go-ethereum/crypto"
)
var testSigData = make([]byte, 32)
func TestSign(t *testing.T) {
- dir, ks := tmpKeyStore(t, crypto.NewKeyStorePlain)
+ dir, am := tmpManager(t, false)
defer os.RemoveAll(dir)
- am := NewManager(ks)
pass := "" // not used but required by API
a1, err := am.NewAccount(pass)
am.Unlock(a1.Address, "")
@@ -43,10 +40,9 @@ func TestSign(t *testing.T) {
}
func TestTimedUnlock(t *testing.T) {
- dir, ks := tmpKeyStore(t, crypto.NewKeyStorePlain)
+ dir, am := tmpManager(t, false)
defer os.RemoveAll(dir)
- am := NewManager(ks)
pass := "foo"
a1, err := am.NewAccount(pass)
@@ -76,10 +72,9 @@ func TestTimedUnlock(t *testing.T) {
}
func TestOverrideUnlock(t *testing.T) {
- dir, ks := tmpKeyStore(t, crypto.NewKeyStorePlain)
+ dir, am := tmpManager(t, false)
defer os.RemoveAll(dir)
- am := NewManager(ks)
pass := "foo"
a1, err := am.NewAccount(pass)
@@ -115,11 +110,10 @@ func TestOverrideUnlock(t *testing.T) {
// This test should fail under -race if signing races the expiration goroutine.
func TestSignRace(t *testing.T) {
- dir, ks := tmpKeyStore(t, crypto.NewKeyStorePlain)
+ dir, am := tmpManager(t, false)
defer os.RemoveAll(dir)
// Create a test account.
- am := NewManager(ks)
a1, err := am.NewAccount("")
if err != nil {
t.Fatal("could not create the test account", err)
@@ -141,10 +135,14 @@ func TestSignRace(t *testing.T) {
t.Errorf("Account did not lock within the timeout")
}
-func tmpKeyStore(t *testing.T, new func(string) crypto.KeyStore) (string, crypto.KeyStore) {
+func tmpManager(t *testing.T, encrypted bool) (string, *Manager) {
d, err := ioutil.TempDir("", "eth-keystore-test")
if err != nil {
t.Fatal(err)
}
+ new := NewPlaintextManager
+ if encrypted {
+ new = func(kd string) *Manager { return NewManager(kd, LightScryptN, LightScryptP) }
+ }
return d, new(d)
}