parse().unwrap() -> into()

This commit is contained in:
debris 2016-08-08 11:18:48 +02:00
parent e9b42d59e8
commit 8269887949
5 changed files with 24 additions and 18 deletions

View File

@ -374,13 +374,13 @@ mod tests {
let vm_factory = Default::default(); let vm_factory = Default::default();
let mut b = OpenBlock::new(engine.deref(), &vm_factory, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap(); let mut b = OpenBlock::new(engine.deref(), &vm_factory, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap();
let mut uncle = Header::new(); let mut uncle = Header::new();
let uncle_author: Address = "ef2d6d194084c2de36e0dabfce45d046b37d1106".parse().unwrap(); let uncle_author: Address = "ef2d6d194084c2de36e0dabfce45d046b37d1106".into();
uncle.author = uncle_author.clone(); uncle.author = uncle_author.clone();
b.push_uncle(uncle).unwrap(); b.push_uncle(uncle).unwrap();
let b = b.close(); let b = b.close();
assert_eq!(b.state().balance(&Address::zero()), U256::from_str("478eae0e571ba000").unwrap()); assert_eq!(b.state().balance(&Address::zero()), "478eae0e571ba000".into());
assert_eq!(b.state().balance(&uncle_author), U256::from_str("3cb71f51fc558000").unwrap()); assert_eq!(b.state().balance(&uncle_author), "3cb71f51fc558000".into());
} }
#[test] #[test]

View File

@ -69,21 +69,21 @@ mod tests {
let mut db = db_result.take(); let mut db = db_result.take();
spec.ensure_db_good(db.as_hashdb_mut()).unwrap(); spec.ensure_db_good(db.as_hashdb_mut()).unwrap();
let s = State::from_existing(db, genesis_header.state_root.clone(), engine.account_start_nonce(), Default::default()).unwrap(); let s = State::from_existing(db, genesis_header.state_root.clone(), engine.account_start_nonce(), Default::default()).unwrap();
assert_eq!(s.balance(&"0000000000000000000000000000000000000001".parse().unwrap()), U256::from(1u64)); assert_eq!(s.balance(&"0000000000000000000000000000000000000001".into()), 1u64.into());
assert_eq!(s.balance(&"0000000000000000000000000000000000000002".parse().unwrap()), U256::from(1u64)); assert_eq!(s.balance(&"0000000000000000000000000000000000000002".into()), 1u64.into());
assert_eq!(s.balance(&"0000000000000000000000000000000000000003".parse().unwrap()), U256::from(1u64)); assert_eq!(s.balance(&"0000000000000000000000000000000000000003".into()), 1u64.into());
assert_eq!(s.balance(&"0000000000000000000000000000000000000004".parse().unwrap()), U256::from(1u64)); assert_eq!(s.balance(&"0000000000000000000000000000000000000004".into()), 1u64.into());
assert_eq!(s.balance(&"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c".parse().unwrap()), U256::from(1u64) << 200); assert_eq!(s.balance(&"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c".into()), U256::from(1u64) << 200);
assert_eq!(s.balance(&"0000000000000000000000000000000000000000".parse().unwrap()), U256::from(0u64)); assert_eq!(s.balance(&"0000000000000000000000000000000000000000".into()), 0u64.into());
} }
#[test] #[test]
fn morden() { fn morden() {
let morden = new_morden(); let morden = new_morden();
assert_eq!(morden.state_root(), H256::from_str("f3f4696bbf3b3b07775128eb7a3763279a394e382130f27c21e70233e04946a9").unwrap()); assert_eq!(morden.state_root(), "f3f4696bbf3b3b07775128eb7a3763279a394e382130f27c21e70233e04946a9".into());
let genesis = morden.genesis_block(); let genesis = morden.genesis_block();
assert_eq!(BlockView::new(&genesis).header_view().sha3(), H256::from_str("0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303").unwrap()); assert_eq!(BlockView::new(&genesis).header_view().sha3(), "0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303".into());
let _ = morden.engine; let _ = morden.engine;
} }
@ -92,9 +92,9 @@ mod tests {
fn frontier() { fn frontier() {
let frontier = new_frontier(); let frontier = new_frontier();
assert_eq!(frontier.state_root(), H256::from_str("d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544").unwrap()); assert_eq!(frontier.state_root(), "d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544".into());
let genesis = frontier.genesis_block(); let genesis = frontier.genesis_block();
assert_eq!(BlockView::new(&genesis).header_view().sha3(), H256::from_str("d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3").unwrap()); assert_eq!(BlockView::new(&genesis).header_view().sha3(), "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3".into());
let _ = frontier.engine; let _ = frontier.engine;
} }

View File

@ -361,10 +361,10 @@ fn sender_test() {
assert_eq!(t.gas_price, U256::from(0x01u64)); assert_eq!(t.gas_price, U256::from(0x01u64));
assert_eq!(t.nonce, U256::from(0x00u64)); assert_eq!(t.nonce, U256::from(0x00u64));
if let Action::Call(ref to) = t.action { if let Action::Call(ref to) = t.action {
assert_eq!(*to, "095e7baea6a6c7c4c2dfeb977efac326af552d87".parse().unwrap()); assert_eq!(*to, "095e7baea6a6c7c4c2dfeb977efac326af552d87".into());
} else { panic!(); } } else { panic!(); }
assert_eq!(t.value, U256::from(0x0au64)); assert_eq!(t.value, U256::from(0x0au64));
assert_eq!(t.sender().unwrap(), "0f65fe9276bc9a24ae7083ae28e2660ef72df99e".parse().unwrap()); assert_eq!(t.sender().unwrap(), "0f65fe9276bc9a24ae7083ae28e2660ef72df99e".into());
} }
#[test] #[test]

View File

@ -1129,6 +1129,12 @@ macro_rules! construct_uint {
Ok(()) Ok(())
} }
} }
impl From<&'static str> for $name {
fn from(s: &'static str) -> Self {
s.parse().unwrap()
}
}
); );
} }

View File

@ -124,9 +124,9 @@ mod tests {
#[test] #[test]
fn shift_bloomed() { fn shift_bloomed() {
let bloom: H2048 = "00000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002020000000000000000000000000000000000000000000008000000001000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000".parse().unwrap(); let bloom: H2048 = "00000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002020000000000000000000000000000000000000000000008000000001000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000".into();
let address: Address = "ef2d6d194084c2de36e0dabfce45d046b37d1106".parse().unwrap(); let address: Address = "ef2d6d194084c2de36e0dabfce45d046b37d1106".into();
let topic: H256 = "02c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc".parse().unwrap(); let topic: H256 = "02c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc".into();
let mut my_bloom = H2048::default(); let mut my_bloom = H2048::default();
assert!(!my_bloom.contains_bloomed(&address.sha3())); assert!(!my_bloom.contains_bloomed(&address.sha3()));