moved keystore tests files from util to ethstore (#1352)
This commit is contained in:
@@ -19,8 +19,10 @@ extern crate ethstore;
|
||||
|
||||
mod util;
|
||||
|
||||
use std::str::FromStr;
|
||||
use ethstore::{SecretStore, EthStore};
|
||||
use ethstore::ethkey::{Random, Generator, Secret};
|
||||
use ethstore::ethkey::{Random, Generator, Secret, Address};
|
||||
use ethstore::dir::DiskDirectory;
|
||||
use util::TransientDir;
|
||||
|
||||
#[test]
|
||||
@@ -86,3 +88,40 @@ fn secret_store_remove_account() {
|
||||
assert_eq!(store.accounts().len(), 0);
|
||||
assert!(store.remove_account(&accounts[0], "").is_err());
|
||||
}
|
||||
|
||||
fn test_path() -> &'static str {
|
||||
match ::std::fs::metadata("ethstore") {
|
||||
Ok(_) => "ethstore/tests/res/geth_keystore",
|
||||
Err(_) => "tests/res/geth_keystore",
|
||||
}
|
||||
}
|
||||
|
||||
fn pat_path() -> &'static str {
|
||||
match ::std::fs::metadata("ethstore") {
|
||||
Ok(_) => "ethstore/tests/res/pat",
|
||||
Err(_) => "tests/res/pat",
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn secret_store_laod_geth_files() {
|
||||
let dir = DiskDirectory::at(test_path());
|
||||
let store = EthStore::open(Box::new(dir)).unwrap();
|
||||
assert_eq!(store.accounts(), vec![
|
||||
Address::from_str("3f49624084b67849c7b4e805c5988c21a430f9d9").unwrap(),
|
||||
Address::from_str("5ba4dcf897e97c2bdf8315b9ef26c13c085988cf").unwrap(),
|
||||
Address::from_str("63121b431a52f8043c16fcf0d1df9cb7b5f66649").unwrap(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn secret_store_load_pat_files() {
|
||||
let dir = DiskDirectory::at(pat_path());
|
||||
let store = EthStore::open(Box::new(dir)).unwrap();
|
||||
assert_eq!(store.accounts(), vec![
|
||||
Address::from_str("3f49624084b67849c7b4e805c5988c21a430f9d9").unwrap(),
|
||||
Address::from_str("5ba4dcf897e97c2bdf8315b9ef26c13c085988cf").unwrap(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"address": "3f49624084b67849c7b4e805c5988c21a430f9d9",
|
||||
"Crypto": {
|
||||
"cipher": "aes-128-ctr",
|
||||
"ciphertext": "9f27e3dd4fc73e7103ed61e5493662189a3eb52223ae49e3d1deacc04c889eae",
|
||||
"cipherparams": {
|
||||
"iv": "457494bf05f2618c397dc74dbb5181c0"
|
||||
},
|
||||
"kdf": "scrypt",
|
||||
"kdfparams": {
|
||||
"dklen": 32,
|
||||
"n": 262144,
|
||||
"p": 1,
|
||||
"r": 8,
|
||||
"salt": "db14edb18c41ee7f5ec4397df89c3a2ae4d0af60884c52bb54ce490574f8df33"
|
||||
},
|
||||
"mac": "572d24532438d31fdf513c744a3ff26c933ffda5744ee42bc71661cbe3f2112e"
|
||||
},
|
||||
"id": "62a0ad73-556d-496a-8e1c-0783d30d3ace",
|
||||
"version": 3
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"address": "5ba4dcf897e97c2bdf8315b9ef26c13c085988cf",
|
||||
"Crypto": {
|
||||
"cipher": "aes-128-ctr",
|
||||
"ciphertext": "d4a08ec930163778273920f6ad1d49b71836337be6fd9863993ac700a612fddd",
|
||||
"cipherparams": {
|
||||
"iv": "89ce5ec129fc27cd5bcbeb8c92bdad50"
|
||||
},
|
||||
"kdf": "scrypt",
|
||||
"kdfparams": {
|
||||
"dklen": 32,
|
||||
"n": 262144,
|
||||
"p": 1,
|
||||
"r": 8,
|
||||
"salt": "612ab108dc37e69ee8af37a7b24bf7f2234086d7bbf945bacdeccce331f7f84a"
|
||||
},
|
||||
"mac": "4152caa7444e06784223d735cea80cd2690b4c587ad8db3d5529442227b25695"
|
||||
},
|
||||
"id": "35086353-fb12-4029-b56b-033cd61ce35b",
|
||||
"version": 3
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"address":"63121b431a52f8043c16fcf0d1df9cb7b5f66649","crypto":{"cipher":"aes-128-ctr","ciphertext":"1dd21926c644b9983916d646f3a4f2c7f9362f7e1c9fb1abcb42494dae06fa01","cipherparams":{"iv":"c52c6ee66d89a7aa8c6839f4b6ed29c8"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"96f17c17bbf48db2dc4da00b3e7decce8e21f44a5d7963dadeeff70e1d38ad75"},"mac":"f279f3444585c2817701225e2196c1176386ad549ebaec2bcc4f94f309727fe6"},"id":"15e49cd2-51fb-4316-ba46-c3cf8db4ae44","version":3}
|
||||
21
ethstore/tests/res/pat/p1.json
Normal file
21
ethstore/tests/res/pat/p1.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"address": "3f49624084b67849c7b4e805c5988c21a430f9d9",
|
||||
"Crypto": {
|
||||
"cipher": "aes-128-ctr",
|
||||
"ciphertext": "9f27e3dd4fc73e7103ed61e5493662189a3eb52223ae49e3d1deacc04c889eae",
|
||||
"cipherparams": {
|
||||
"iv": "457494bf05f2618c397dc74dbb5181c0"
|
||||
},
|
||||
"kdf": "scrypt",
|
||||
"kdfparams": {
|
||||
"dklen": 32,
|
||||
"n": 262144,
|
||||
"p": 1,
|
||||
"r": 8,
|
||||
"salt": "db14edb18c41ee7f5ec4397df89c3a2ae4d0af60884c52bb54ce490574f8df33"
|
||||
},
|
||||
"mac": "572d24532438d31fdf513c744a3ff26c933ffda5744ee42bc71661cbe3f2112e"
|
||||
},
|
||||
"id": "62a0ad73-556d-496a-8e1c-0783d30d3ace",
|
||||
"version": 3
|
||||
}
|
||||
21
ethstore/tests/res/pat/p2.json
Normal file
21
ethstore/tests/res/pat/p2.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"address": "5ba4dcf897e97c2bdf8315b9ef26c13c085988cf",
|
||||
"Crypto": {
|
||||
"cipher": "aes-128-ctr",
|
||||
"ciphertext": "d4a08ec930163778273920f6ad1d49b71836337be6fd9863993ac700a612fddd",
|
||||
"cipherparams": {
|
||||
"iv": "89ce5ec129fc27cd5bcbeb8c92bdad50"
|
||||
},
|
||||
"kdf": "scrypt",
|
||||
"kdfparams": {
|
||||
"dklen": 32,
|
||||
"n": 262144,
|
||||
"p": 1,
|
||||
"r": 8,
|
||||
"salt": "612ab108dc37e69ee8af37a7b24bf7f2234086d7bbf945bacdeccce331f7f84a"
|
||||
},
|
||||
"mac": "4152caa7444e06784223d735cea80cd2690b4c587ad8db3d5529442227b25695"
|
||||
},
|
||||
"id": "35086353-fb12-4029-b56b-033cd61ce35b",
|
||||
"version": 3
|
||||
}
|
||||
Reference in New Issue
Block a user