refactored state tests

This commit is contained in:
debris
2016-03-25 13:08:57 +01:00
parent e1b841b526
commit cdcbc56255
9 changed files with 387 additions and 18 deletions

View File

@@ -20,6 +20,7 @@ use util::*;
use error::*;
use evm::Schedule;
use header::BlockNumber;
use ethjson;
#[derive(Debug, Clone, PartialEq, Eq)]
/// Transaction action type.
@@ -79,6 +80,23 @@ impl Transaction {
}
}
impl From<ethjson::state::Transaction> for SignedTransaction {
fn from(t: ethjson::state::Transaction) -> Self {
let to: Option<_> = t.to.into();
Transaction {
nonce: t.nonce.into(),
gas_price: t.gas_price.into(),
gas: t.gas_limit.into(),
action: match to {
Some(to) => Action::Call(to.into()),
None => Action::Create
},
value: t.value.into(),
data: t.data.into(),
}.sign(&t.secret.into())
}
}
impl FromJson for SignedTransaction {
#[cfg_attr(feature="dev", allow(single_char_pattern))]
fn from_json(json: &Json) -> SignedTransaction {