diff options
author | obscuren <geffobscura@gmail.com> | 2015-02-13 22:05:56 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-02-13 22:05:56 +0800 |
commit | a5ea21cd85530eee6eb1bb83c37c20d009f11f74 (patch) | |
tree | e5be5bd595139ff7dfbe6261e1e659d8e7dd6f9c /crypto/key_store_test.go | |
parent | db24fb792cf0dab91bc85e79aecf6758349002a4 (diff) | |
parent | 38faf2c51a1e4a86cda5dfa1b4f7fdae4fd7f58d (diff) | |
download | dexon-a5ea21cd85530eee6eb1bb83c37c20d009f11f74.tar dexon-a5ea21cd85530eee6eb1bb83c37c20d009f11f74.tar.gz dexon-a5ea21cd85530eee6eb1bb83c37c20d009f11f74.tar.bz2 dexon-a5ea21cd85530eee6eb1bb83c37c20d009f11f74.tar.lz dexon-a5ea21cd85530eee6eb1bb83c37c20d009f11f74.tar.xz dexon-a5ea21cd85530eee6eb1bb83c37c20d009f11f74.tar.zst dexon-a5ea21cd85530eee6eb1bb83c37c20d009f11f74.zip |
merge
Diffstat (limited to 'crypto/key_store_test.go')
-rw-r--r-- | crypto/key_store_test.go | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/crypto/key_store_test.go b/crypto/key_store_test.go index 16c0e476d..0d229ab65 100644 --- a/crypto/key_store_test.go +++ b/crypto/key_store_test.go @@ -15,12 +15,12 @@ func TestKeyStorePlain(t *testing.T) { } k2 := new(Key) - k2, err = ks.GetKey(k1.Id, pass) + k2, err = ks.GetKey(k1.Address, pass) if err != nil { t.Fatal(err) } - if !reflect.DeepEqual(k1.Id, k2.Id) { + if !reflect.DeepEqual(k1.Address, k2.Address) { t.Fatal(err) } @@ -28,7 +28,7 @@ func TestKeyStorePlain(t *testing.T) { t.Fatal(err) } - err = ks.DeleteKey(k2.Id, pass) + err = ks.DeleteKey(k2.Address, pass) if err != nil { t.Fatal(err) } @@ -42,11 +42,11 @@ func TestKeyStorePassphrase(t *testing.T) { t.Fatal(err) } k2 := new(Key) - k2, err = ks.GetKey(k1.Id, pass) + k2, err = ks.GetKey(k1.Address, pass) if err != nil { t.Fatal(err) } - if !reflect.DeepEqual(k1.Id, k2.Id) { + if !reflect.DeepEqual(k1.Address, k2.Address) { t.Fatal(err) } @@ -54,7 +54,7 @@ func TestKeyStorePassphrase(t *testing.T) { t.Fatal(err) } - err = ks.DeleteKey(k2.Id, pass) // also to clean up created files + err = ks.DeleteKey(k2.Address, pass) // also to clean up created files if err != nil { t.Fatal(err) } @@ -68,17 +68,30 @@ func TestKeyStorePassphraseDecryptionFail(t *testing.T) { t.Fatal(err) } - _, err = ks.GetKey(k1.Id, "bar") // wrong passphrase + _, err = ks.GetKey(k1.Address, "bar") // wrong passphrase if err == nil { t.Fatal(err) } - err = ks.DeleteKey(k1.Id, "bar") // wrong passphrase + err = ks.DeleteKey(k1.Address, "bar") // wrong passphrase if err == nil { t.Fatal(err) } - err = ks.DeleteKey(k1.Id, pass) // to clean up + err = ks.DeleteKey(k1.Address, pass) // to clean up + if err != nil { + t.Fatal(err) + } +} + +func TestImportPreSaleKey(t *testing.T) { + // file content of a presale key file generated with: + // python pyethsaletool.py genwallet + // with password "foo" + fileContent := "{\"encseed\": \"26d87f5f2bf9835f9a47eefae571bc09f9107bb13d54ff12a4ec095d01f83897494cf34f7bed2ed34126ecba9db7b62de56c9d7cd136520a0427bfb11b8954ba7ac39b90d4650d3448e31185affcd74226a68f1e94b1108e6e0a4a91cdd83eba\", \"ethaddr\": \"d4584b5f6229b7be90727b0fc8c6b91bb427821f\", \"email\": \"gustav.simonsson@gmail.com\", \"btcaddr\": \"1EVknXyFC68kKNLkh6YnKzW41svSRoaAcx\"}" + ks := NewKeyStorePassphrase(DefaultDataDir()) + pass := "foo" + _, err := ImportPreSaleKey(ks, []byte(fileContent), pass) if err != nil { t.Fatal(err) } |