Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions ethcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ engine = { path = "./engine", features = ["test-helpers"] }
env_logger = "0.5"
ethash = { path = "../ethash" }
ethcore-accounts = { path = "../accounts" }
ethjson = { path = "../json" }
ethjson = { path = "../json", features = ["test-helpers"] }
ethkey = { path = "../accounts/ethkey" }
fetch = { path = "../util/fetch" }
kvdb-memorydb = "0.1"
Expand All @@ -89,7 +89,6 @@ machine = { path = "./machine", features = ["test-helpers"] }
macros = { path = "../util/macros" }
null-engine = { path = "./engines/null-engine" }
parity-runtime = { path = "../util/runtime" }
pod = { path = "pod" }
rlp_compress = { path = "../util/rlp-compress" }
rustc-hex = "1"
serde_json = "1.0"
Expand Down
16 changes: 0 additions & 16 deletions ethcore/pod/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,6 @@ impl PodAccount {
}
}

impl From<ethjson::blockchain::Account> for PodAccount {
Comment thread
dvdplm marked this conversation as resolved.
fn from(a: ethjson::blockchain::Account) -> Self {
PodAccount {
balance: a.balance.into(),
nonce: a.nonce.into(),
code: Some(a.code.into()),
storage: a.storage.into_iter().map(|(key, value)| {
let key: U256 = key.into();
let value: U256 = value.into();
(BigEndianHash::from_uint(&key), BigEndianHash::from_uint(&value))
}).collect(),
version: a.version.into(),
}
}
}

impl From<ethjson::spec::Account> for PodAccount {
fn from(a: ethjson::spec::Account) -> Self {
PodAccount {
Expand Down
7 changes: 0 additions & 7 deletions ethcore/pod/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ impl PodState {
}
}

impl From<ethjson::blockchain::State> for PodState {
fn from(s: ethjson::blockchain::State) -> PodState {
let state = s.into_iter().map(|(addr, acc)| (addr.into(), PodAccount::from(acc))).collect();
PodState(state)
}
}

impl From<ethjson::spec::State> for PodState {
fn from(s: ethjson::spec::State) -> PodState {
let state: BTreeMap<_,_> = s.into_iter()
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/json_tests/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn skip_test(name: &String) -> bool {

pub fn json_chain_test<H: FnMut(&str, HookType)>(json_data: &[u8], start_stop_hook: &mut H) -> Vec<String> {
let _ = ::env_logger::try_init();
let tests = ethjson::blockchain::Test::load(json_data).unwrap();
let tests = ethjson::test_helpers::blockchain::Test::load(json_data).unwrap();
let mut failed = Vec::new();

for (name, blockchain) in tests.into_iter() {
Expand Down Expand Up @@ -84,7 +84,7 @@ pub fn json_chain_test<H: FnMut(&str, HookType)>(json_data: &[u8], start_stop_ho
{
let db = test_helpers::new_db();
let mut config = ClientConfig::default();
if ethjson::blockchain::Engine::NoProof == blockchain.engine {
if ethjson::test_helpers::blockchain::Engine::NoProof == blockchain.engine {
config.verifier_type = VerifierType::CanonNoSeal;
config.check_seal = false;
}
Expand Down
14 changes: 9 additions & 5 deletions ethcore/src/json_tests/difficulty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.

use ethjson;
use types::header::Header;
use ethereum_types::U256;
use ethjson::test_helpers::difficulty::DifficultyTest;
use types::header::Header;
use spec::Spec;

use super::HookType;

pub fn json_difficulty_test<H: FnMut(&str, HookType)>(json_data: &[u8], spec: Spec, start_stop_hook: &mut H) -> Vec<String> {
let _ = ::env_logger::try_init();
let tests = ethjson::test::DifficultyTest::load(json_data).unwrap();
pub fn json_difficulty_test<H: FnMut(&str, HookType)>(
json_data: &[u8],
spec: Spec,
start_stop_hook: &mut H
) -> Vec<String> {
let _ = env_logger::try_init();
let tests = DifficultyTest::load(json_data).unwrap();
let engine = &spec.engine;

for (name, test) in tests.into_iter() {
Expand Down
16 changes: 10 additions & 6 deletions ethcore/src/json_tests/executive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,12 @@ fn do_json_test<H: FnMut(&str, HookType)>(json_data: &[u8], h: &mut H) -> Vec<St
.collect()
}

fn do_json_test_for<H: FnMut(&str, HookType)>(vm_type: &VMType, json_data: &[u8], start_stop_hook: &mut H) -> Vec<String> {
let tests = ethjson::vm::Test::load(json_data).unwrap();
fn do_json_test_for<H: FnMut(&str, HookType)>(
vm_type: &VMType,
json_data: &[u8],
start_stop_hook: &mut H
) -> Vec<String> {
let tests = ethjson::test_helpers::vm::Test::load(json_data).unwrap();
let mut failed = Vec::new();

for (name, vm) in tests.into_iter() {
Expand Down Expand Up @@ -336,15 +340,15 @@ fn do_json_test_for<H: FnMut(&str, HookType)>(vm_type: &VMType, json_data: &[u8]

for (address, account) in vm.post_state.unwrap().into_iter() {
let address = address.into();
let code: Vec<u8> = account.code.into();
let code: Vec<u8> = account.code.expect("code is missing from json; test should have code").into();
let found_code = try_fail!(state.code(&address));
let found_balance = try_fail!(state.balance(&address));
let found_nonce = try_fail!(state.nonce(&address));

fail_unless(found_code.as_ref().map_or_else(|| code.is_empty(), |c| &**c == &code), "code is incorrect");
fail_unless(found_balance == account.balance.into(), "balance is incorrect");
fail_unless(found_nonce == account.nonce.into(), "nonce is incorrect");
for (k, v) in account.storage {
fail_unless(account.balance.as_ref().map_or(false, |b| b.0 == found_balance), "balance is incorrect");
fail_unless(account.nonce.as_ref().map_or(false, |n| n.0 == found_nonce), "nonce is incorrect");
for (k, v) in account.storage.expect("test should have storage") {
let key: U256 = k.into();
let value: U256 = v.into();
let found_storage = try_fail!(state.storage_at(&address, &BigEndianHash::from_uint(&key)));
Expand Down
12 changes: 6 additions & 6 deletions ethcore/src/json_tests/skip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@

//! State tests to skip.

use ethjson;
use ethjson::test_helpers::skip::SkipStates;

#[cfg(feature="ci-skip-tests")]
lazy_static!{
pub static ref SKIP_TEST_STATE: ethjson::test::SkipStates = {
lazy_static! {
pub static ref SKIP_TEST_STATE: SkipStates = {
let skip_data = include_bytes!("../../res/ethereum/tests-issues/currents.json");
ethjson::test::SkipStates::load(&skip_data[..]).expect("No invalid json allowed")
SkipStates::load(&skip_data[..]).expect("No invalid json allowed")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

};
}

#[cfg(not(feature="ci-skip-tests"))]
lazy_static!{
pub static ref SKIP_TEST_STATE: ethjson::test::SkipStates = {
ethjson::test::SkipStates::empty()
pub static ref SKIP_TEST_STATE: SkipStates = {
SkipStates::empty()
};
}
2 changes: 1 addition & 1 deletion ethcore/src/json_tests/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn skip_test(subname: &str, chain: &String, number: usize) -> bool {

pub fn json_chain_test<H: FnMut(&str, HookType)>(json_data: &[u8], start_stop_hook: &mut H) -> Vec<String> {
let _ = ::env_logger::try_init();
let tests = ethjson::state::test::Test::load(json_data).unwrap();
let tests = ethjson::test_helpers::state::Test::load(json_data).unwrap();
let mut failed = Vec::new();

for (name, test) in tests.into_iter() {
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/json_tests/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn run_test_file<H: FnMut(&str, HookType)>(p: &Path, h: &mut H) {
const BLOCK_NUMBER: u64 = 0x6ffffffffffffe;

fn do_json_test<H: FnMut(&str, HookType)>(json_data: &[u8], start_stop_hook: &mut H) -> Vec<String> {
let tests = ethjson::transaction::Test::load(json_data).unwrap();
let tests = ethjson::test_helpers::transaction::Test::load(json_data).unwrap();
let mut failed = Vec::new();
for (name, test) in tests.into_iter() {
start_stop_hook(&name, HookType::OnStart);
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/json_tests/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub use self::secure::run_test_path as run_secure_test_path;
pub use self::secure::run_test_file as run_secure_test_file;

fn test_trie<H: FnMut(&str, HookType)>(json: &[u8], trie: TrieSpec, start_stop_hook: &mut H) -> Vec<String> {
let tests = ethjson::trie::Test::load(json).unwrap();
let tests = ethjson::test_helpers::trie::Test::load(json).unwrap();
let factory = TrieFactory::new(trie, ethtrie::Layout);
let mut result = vec![];

Expand Down
4 changes: 2 additions & 2 deletions ethcore/types/src/transaction/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ impl Transaction {
}
}

impl From<ethjson::state::Transaction> for SignedTransaction {
fn from(t: ethjson::state::Transaction) -> Self {
impl From<ethjson::transaction::Transaction> for SignedTransaction {
fn from(t: ethjson::transaction::Transaction) -> Self {
let to: Option<ethjson::hash::Address> = t.to.into();
let secret = t.secret.map(|s| Secret::from(s.0));
let tx = Transaction {
Expand Down
6 changes: 3 additions & 3 deletions evmbin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fn main() {
}

fn run_state_test(args: Args) {
use ethjson::state::test::Test;
use ethjson::test_helpers::state::Test;

// Parse the specified state test JSON file provided to the command `state-test <file>`.
let file = args.arg_file.expect("PATH to a state test JSON file is required");
Expand Down Expand Up @@ -443,8 +443,8 @@ fn die<T: fmt::Display>(msg: T) -> ! {
mod tests {
use common_types::transaction;
use docopt::Docopt;
use ethcore::{TrieSpec};
use ethjson::state::test::{State};
use ethcore::TrieSpec;
use ethjson::test_helpers::state::State;
use serde::Deserialize;

use super::{Args, USAGE, Address, run_call};
Expand Down
10 changes: 8 additions & 2 deletions json/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ description = "Parity Ethereum JSON Deserialization"
name = "ethjson"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

[dependencies]
ethereum-types = "0.6.0"
rustc-hex = "1.0"
serde = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_derive = "1.0"

[dev-dependencies]
macros = { path = "../util/macros" }

[features]
test-helpers = []
57 changes: 0 additions & 57 deletions json/src/blockchain/account.rs

This file was deleted.

34 changes: 0 additions & 34 deletions json/src/blockchain/state.rs

This file was deleted.

43 changes: 0 additions & 43 deletions json/src/blockchain/test.rs

This file was deleted.

Loading