tests for deserialization of issue #835

This commit is contained in:
debris 2016-03-27 14:14:05 +02:00 committed by arkpar
parent 02dfc8632e
commit c9ac0392d8
2 changed files with 27 additions and 4 deletions

View File

@ -476,11 +476,11 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
Ok(_) => to_value(&hash),
Err(e) => {
warn!("Error sending transaction: {:?}", e);
to_value(&U256::zero())
to_value(&H256::zero())
}
}
},
Err(_) => { to_value(&U256::zero()) }
Err(_) => { to_value(&H256::zero()) }
}
})
}
@ -503,11 +503,11 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
Ok(_) => to_value(&hash),
Err(e) => {
warn!("Error sending transaction: {:?}", e);
to_value(&U256::zero())
to_value(&H256::zero())
}
}
},
Err(_) => { to_value(&U256::zero()) }
Err(_) => { to_value(&H256::zero()) }
}
})
}

View File

@ -102,4 +102,27 @@ mod tests {
nonce: None,
});
}
#[test]
fn transaction_request_deserialize_test() {
let s = r#"{
"from":"0xb5f7502a2807cb23615c7456055e1d65b2508625",
"to":"0x895d32f2db7d01ebb50053f9e48aacf26584fe40",
"data":"0x8595bab1",
"gas":"0x2fd618",
"gasPrice":"0x0ba43b7400"
}"#;
let deserialized: TransactionRequest = serde_json::from_str(s).unwrap();
assert_eq!(deserialized, TransactionRequest {
from: Address::from_str("b5f7502a2807cb23615c7456055e1d65b2508625").unwrap(),
to: Some(Address::from_str("895d32f2db7d01ebb50053f9e48aacf26584fe40").unwrap()),
gas_price: Some(U256::from_str("0ba43b7400").unwrap()),
gas: Some(U256::from_str("2fd618").unwrap()),
value: None,
data: Some(Bytes::new(vec![0x85, 0x95, 0xba, 0xb1])),
nonce: None,
});
}
}