fixed loading of executive tests, unrevealed failing consensus tests

This commit is contained in:
debris
2016-03-24 01:25:59 +01:00
parent 3352b0e916
commit 1aa34e9dd4
16 changed files with 240 additions and 93 deletions

View File

@@ -19,6 +19,7 @@
use bytes::Bytes;
use hash::Address;
use uint::Uint;
use maybe::MaybeEmpty;
/// Vm call deserialization.
#[derive(Debug, PartialEq, Deserialize)]
@@ -26,7 +27,7 @@ pub struct Call {
/// Call data.
pub data: Bytes,
/// Call destination.
pub destination: Address,
pub destination: MaybeEmpty<Address>,
/// Gas limit.
#[serde(rename="gasLimit")]
pub gas_limit: Uint,

View File

@@ -23,7 +23,7 @@ use uint::Uint;
pub struct Env {
/// Address.
#[serde(rename="currentCoinbase")]
pub coinbase: Address,
pub author: Address,
/// Difficulty
#[serde(rename="currentDifficulty")]
pub difficulty: Uint,

View File

@@ -21,9 +21,11 @@ pub mod transaction;
pub mod vm;
pub mod log;
pub mod call;
pub mod test;
pub use self::env::Env;
pub use self::transaction::Transaction;
pub use self::vm::Vm;
pub use self::log::Log;
pub use self::call::Call;
pub use self::test::Test;

43
json/src/vm/test.rs Normal file
View File

@@ -0,0 +1,43 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Vm test deserializer.
use std::collections::BTreeMap;
use std::io::Read;
use serde_json;
use serde_json::Error;
use vm::Vm;
/// Vm test deserializer.
#[derive(Debug, PartialEq, Deserialize)]
pub struct Test(BTreeMap<String, Vm>);
impl IntoIterator for Test {
type Item = <BTreeMap<String, Vm> as IntoIterator>::Item;
type IntoIter = <BTreeMap<String, Vm> as IntoIterator>::IntoIter;
fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
}
}
impl Test {
/// Loads test from json.
pub fn load<R>(reader: R) -> Result<Self, Error> where R: Read {
serde_json::from_reader(reader)
}
}

View File

@@ -19,7 +19,7 @@
use bytes::Bytes;
use uint::Uint;
use blockchain::State;
use vm::{Transaction, Log, Call};
use vm::{Transaction, Log, Call, Env};
/// Reporesents vm execution environment before and after exeuction of transaction.
#[derive(Debug, PartialEq, Deserialize)]
@@ -27,23 +27,34 @@ pub struct Vm {
/// Contract calls made internaly by executed transaction.
#[serde(rename="callcreates")]
pub calls: Option<Vec<Call>>,
/// Env info.
pub env: Env,
/// Executed transaction
#[serde(rename="exec")]
pub exec: Transaction,
/// Gas.
pub gas: Uint,
pub transaction: Transaction,
/// Gas left after transaction execution.
#[serde(rename="gas")]
pub gas_left: Option<Uint>,
/// Logs created during execution of transaction.
pub logs: Vec<Log>,
pub logs: Option<Vec<Log>>,
/// Transaction output.
pub out: Bytes,
#[serde(rename="out")]
pub output: Option<Bytes>,
/// Post execution vm state.
#[serde(rename="post")]
pub post_state: State,
pub post_state: Option<State>,
/// Pre execution vm state.
#[serde(rename="pre")]
pub pre_state: State,
}
impl Vm {
/// Returns true if transaction execution run out of gas.
pub fn out_of_gas(&self) -> bool {
self.calls.is_none()
}
}
#[cfg(test)]
mod tests {
use serde_json;