finishe signed transactions

This commit is contained in:
debris
2016-02-04 23:48:29 +01:00
parent e92c6ee719
commit eab8410402
9 changed files with 164 additions and 229 deletions

View File

@@ -33,7 +33,7 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
flush!(" - {}...", name);
let t = Transaction::from_json(&test["transaction"]);
let t = SignedTransaction::from_json(&test["transaction"]);
let env = EnvInfo::from_json(&test["env"]);
let _out = Bytes::from_json(&test["out"]);
let post_state_root = xjson!(&test["postStateRoot"]);

View File

@@ -6,7 +6,7 @@ fn do_json_test(json_data: &[u8]) -> Vec<String> {
let mut failed = Vec::new();
let old_schedule = evm::Schedule::new_frontier();
let new_schedule = evm::Schedule::new_homestead();
let ot = RefCell::new(Transaction::new());
let ot = RefCell::new(None);
for (name, test) in json.as_object().unwrap() {
let mut fail = false;
let mut fail_unless = |cond: bool| if !cond && !fail { failed.push(name.clone()); println!("Transaction: {:?}", ot.borrow()); fail = true };
@@ -15,7 +15,7 @@ fn do_json_test(json_data: &[u8]) -> Vec<String> {
.and_then(|s| BlockNumber::from_str(s).ok())
.unwrap_or(0) { x if x < 1_000_000 => &old_schedule, _ => &new_schedule };
let rlp = Bytes::from_json(&test["rlp"]);
let res = UntrustedRlp::new(&rlp).as_val().map_err(From::from).and_then(|t: Transaction| t.validate(schedule, schedule.have_delegate_call));
let res = UntrustedRlp::new(&rlp).as_val().map_err(From::from).and_then(|t: SignedTransaction| t.validate(schedule, schedule.have_delegate_call));
fail_unless(test.find("transaction").is_none() == res.is_err());
if let (Some(&Json::Object(ref tx)), Some(&Json::String(ref expect_sender))) = (test.find("transaction"), test.find("sender")) {
let t = res.unwrap();
@@ -26,10 +26,10 @@ fn do_json_test(json_data: &[u8]) -> Vec<String> {
fail_unless(t.nonce == xjson!(&tx["nonce"]));
fail_unless(t.value == xjson!(&tx["value"]));
if let Action::Call(ref to) = t.action {
*ot.borrow_mut() = t.clone();
*ot.borrow_mut() = Some(t.clone());
fail_unless(to == &xjson!(&tx["to"]));
} else {
*ot.borrow_mut() = t.clone();
*ot.borrow_mut() = Some(t.clone());
fail_unless(Bytes::from_json(&tx["to"]).is_empty());
}
}