Merge pull request #350 from ethcore/signed_transaction

SignedTransaction structure
This commit is contained in:
Marek Kotewicz
2016-02-05 14:11:12 +01:00
12 changed files with 256 additions and 213 deletions

View File

@@ -22,7 +22,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 };
@@ -31,7 +31,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();
@@ -42,10 +42,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());
}
}