Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Vurich committed Jun 28, 2017
1 parent c6fbf34 commit 1db1050
Show file tree
Hide file tree
Showing 25 changed files with 65 additions and 66 deletions.
4 changes: 2 additions & 2 deletions ethcore/light/src/on_demand/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ mod tests {
fn check_header_by_hash() {
let mut header = Header::new();
header.set_number(10_000);
header.set_extra_data(b"test_header".into_vec());
header.set_extra_data(b"test_header".to_vec());
let hash = header.hash();
let raw_header = encoded::Header::new(::rlp::encode(&header).into_vec());

Expand Down Expand Up @@ -953,7 +953,7 @@ mod tests {
let mut db = MemoryDB::new();
let mut header = Header::new();
header.set_number(123_456);
header.set_extra_data(b"test_header".into_vec());
header.set_extra_data(b"test_header".to_vec());

let addr = Address::random();
let rand_acc = || {
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,9 +746,9 @@ mod tests {
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let mut open_block = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes.clone(), Address::zero(), (3141562.into(), 31415620.into()), vec![], false).unwrap();
let mut uncle1_header = Header::new();
uncle1_header.set_extra_data(b"uncle1".into_vec());
uncle1_header.set_extra_data(b"uncle1".to_vec());
let mut uncle2_header = Header::new();
uncle2_header.set_extra_data(b"uncle2".into_vec());
uncle2_header.set_extra_data(b"uncle2".to_vec());
open_block.push_uncle(uncle1_header).unwrap();
open_block.push_uncle(uncle2_header).unwrap();
let b = open_block.close_and_lock().seal(engine, vec![]).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/engines/tendermint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ mod tests {
vec![
::rlp::encode(&view).into_vec(),
::rlp::encode(&H520::from(signature)).into_vec(),
::rlp::EMPTY_LIST_RLP.into_vec()
::rlp::EMPTY_LIST_RLP.to_vec()
]
}

Expand Down Expand Up @@ -812,7 +812,7 @@ mod tests {
let vote_info = message_info_rlp(&VoteStep::new(2, 0, Step::Precommit), Some(header.bare_hash()));
let signature1 = tap.sign(proposer, None, vote_info.sha3()).unwrap();

seal[1] = ::rlp::NULL_RLP.into_vec();
seal[1] = ::rlp::NULL_RLP.to_vec();
seal[2] = ::rlp::encode_list(&vec![H520::from(signature1.clone())]).into_vec();
header.set_seal(seal.clone());

Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/engines/vote_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl <M: Message + Default + Encodable + Debug> VoteCollector<M> {
guard
.iter()
.take_while(|&(r, _)| r <= round)
.map(|(_, c)| c.messages.iter().filter(|m| m.is_broadcastable()).map(|m| ::rlp::encode(m).into_vec()).collect::<Vec<_>>())
.map(|(_, c)| c.messages.iter().filter(|m| m.is_broadcastable()).map(|m| ::rlp::encode(m).to_vec()).collect::<Vec<_>>())
.fold(Vec::new(), |mut acc, mut messages| { acc.append(&mut messages); acc })
}

Expand Down Expand Up @@ -279,7 +279,7 @@ mod tests {
// Wrong round, same signature.
random_vote(&collector, signatures[1].clone(), 7, bh.clone());

assert_eq!(signatures[0..1].into_vec(), collector.round_signatures(&propose_round, &bh.unwrap()));
assert_eq!(signatures[0..1].to_vec(), collector.round_signatures(&propose_round, &bh.unwrap()));
assert_eq!(signatures[1..3].iter().collect::<HashSet<_>>(), collector.round_signatures(&commit_round, &bh.unwrap()).iter().collect::<HashSet<_>>());
}

Expand Down
8 changes: 4 additions & 4 deletions ethcore/src/evm/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl Ext for FakeExt {
sender_address: None,
receive_address: None,
value: Some(*value),
data: code.into_vec(),
data: code.to_vec(),
code_address: None
});
ContractCreateResult::Failed
Expand All @@ -146,7 +146,7 @@ impl Ext for FakeExt {
sender_address: Some(sender_address.clone()),
receive_address: Some(receive_address.clone()),
value: value,
data: data.into_vec(),
data: data.to_vec(),
code_address: Some(code_address.clone())
});
MessageCallResult::Success(*gas, ReturnData::empty())
Expand All @@ -163,7 +163,7 @@ impl Ext for FakeExt {
fn log(&mut self, topics: Vec<H256>, data: &[u8]) -> evm::Result<()> {
self.logs.push(FakeLogEntry {
topics: topics,
data: data.into_vec()
data: data.to_vec()
});
Ok(())
}
Expand Down Expand Up @@ -463,7 +463,7 @@ fn test_blockhash_eip210(factory: super::Factory) {
value: ActionValue::Transfer(0.into()),
code: Some(blockhash_contract_code.clone()),
code_hash: blockhash_contract_code_hash,
data: Some(H256::from(i - 1).into_vec()),
data: Some(H256::from(i - 1).to_vec()),
call_type: CallType::Call,
};
let mut ex = Executive::new(&mut state, &env_info, &engine);
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/json_tests/executive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl<'a, T: 'a, V: 'a, B: 'a, E: 'a> Ext for TestExt<'a, T, V, B, E>

fn create(&mut self, gas: &U256, value: &U256, code: &[u8], address: CreateContractAddress) -> ContractCreateResult {
self.callcreates.push(CallCreate {
data: code.into_vec(),
data: code.to_vec(),
destination: None,
gas_limit: *gas,
value: *value
Expand All @@ -138,7 +138,7 @@ impl<'a, T: 'a, V: 'a, B: 'a, E: 'a> Ext for TestExt<'a, T, V, B, E>
_call_type: CallType
) -> MessageCallResult {
self.callcreates.push(CallCreate {
data: data.into_vec(),
data: data.to_vec(),
destination: Some(receive_address.clone()),
gas_limit: *gas,
value: value.unwrap()
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/snapshot/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ mod tests {
assert_eq!(acc, account2);

let (acc, maybe_code) = from_fat_rlp(&mut AccountDBMut::new(db.as_hashdb_mut(), &addr1), fat_rlp1, H256::zero()).unwrap();
assert_eq!(maybe_code, Some(b"this is definitely code".into_vec()));
assert_eq!(maybe_code, Some(b"this is definitely code".to_vec()));
assert_eq!(acc, account1);
}

Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/snapshot/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ mod tests {
gas_price: U256::from(3000),
gas: U256::from(50_000),
value: U256::from(1),
data: b"Hello!".into_vec()
data: b"Hello!".to_vec()
}.fake_sign(Address::from(0x69));

let t2 = Transaction {
Expand Down
8 changes: 4 additions & 4 deletions ethcore/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1826,14 +1826,14 @@ mod tests {
let mut state = get_temp_state();
state.require_or_from(&a, false, ||Account::new_contract(42.into(), 0.into()), |_|{}).unwrap();
state.init_code(&a, vec![1, 2, 3]).unwrap();
assert_eq!(state.code(&a).unwrap(), Some(Arc::new([1u8, 2, 3].into_vec())));
assert_eq!(state.code(&a).unwrap(), Some(Arc::new(vec![1u8, 2, 3])));
state.commit().unwrap();
assert_eq!(state.code(&a).unwrap(), Some(Arc::new([1u8, 2, 3].into_vec())));
assert_eq!(state.code(&a).unwrap(), Some(Arc::new(vec![1u8, 2, 3])));
state.drop()
};

let state = State::from_existing(db, root, U256::from(0u8), Default::default()).unwrap();
assert_eq!(state.code(&a).unwrap(), Some(Arc::new([1u8, 2, 3].into_vec())));
assert_eq!(state.code(&a).unwrap(), Some(Arc::new(vec![1u8, 2, 3])));
}

#[test]
Expand Down Expand Up @@ -2040,7 +2040,7 @@ mod tests {
let mut state = get_temp_state();

let a: Address = 0xa.into();
state.init_code(&a, b"abcdefg".into_vec()).unwrap();;
state.init_code(&a, b"abcdefg".to_vec()).unwrap();;
state.add_balance(&a, &256.into(), CleanupMode::NoEmpty).unwrap();
state.set_storage(&a, 0xb.into(), 0xc.into()).unwrap();

Expand Down
6 changes: 3 additions & 3 deletions ethcore/src/types/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ fn signing() {
gas_price: U256::from(3000),
gas: U256::from(50_000),
value: U256::from(1),
data: b"Hello!".into_vec()
data: b"Hello!".to_vec()
}.sign(&key.secret(), None);
assert_eq!(Address::from(key.public().sha3()), t.sender());
assert_eq!(t.network_id(), None);
Expand All @@ -584,7 +584,7 @@ fn fake_signing() {
gas_price: U256::from(3000),
gas: U256::from(50_000),
value: U256::from(1),
data: b"Hello!".into_vec()
data: b"Hello!".to_vec()
}.fake_sign(Address::from(0x69));
assert_eq!(Address::from(0x69), t.sender());
assert_eq!(t.network_id(), None);
Expand All @@ -604,7 +604,7 @@ fn should_recover_from_network_specific_signing() {
gas_price: U256::from(3000),
gas: U256::from(50_000),
value: U256::from(1),
data: b"Hello!".into_vec()
data: b"Hello!".to_vec()
}.sign(&key.secret(), Some(69));
assert_eq!(Address::from(key.public().sha3()), t.sender());
assert_eq!(t.network_id(), Some(69));
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/verification/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ mod tests {

fn block_header_data(&self, hash: &H256) -> Option<encoded::Header> {
self.block(hash)
.map(|b| b.header_view().rlp().as_raw().into_vec())
.map(|b| b.header_view().rlp().as_raw().to_vec())
.map(encoded::Header::new)
}

Expand Down
4 changes: 2 additions & 2 deletions ethkey/src/extended.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ mod tests {
fn master_chain_basic() -> (H256, H256) {
let seed = H128::from_str("000102030405060708090a0b0c0d0e0f")
.expect("Seed should be valid H128")
.into_vec();
.to_vec();

derivation::seed_pair(&*seed)
}
Expand Down Expand Up @@ -475,7 +475,7 @@ mod tests {
fn test_seeds() {
let seed = H128::from_str("000102030405060708090a0b0c0d0e0f")
.expect("Seed should be valid H128")
.into_vec();
.to_vec();

/// private key from bitcoin test vector
/// xprv9wTYmMFdV23N2TdNG573QoEsfRrWKQgWeibmLntzniatZvR9BmLnvSxqu53Kw1UmYPxLgboyZQaXwTCg8MSY3H2EU4pWcQDnRnrVA1xe8fs
Expand Down
2 changes: 1 addition & 1 deletion ipc/nano/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ mod service_tests {
self.methods_stack.write().unwrap().push(
TestInvoke {
method_num: method_num,
params: buf.into_vec(),
params: buf.to_vec(),
});
vec![]
}
Expand Down
3 changes: 1 addition & 2 deletions parity/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ fn execute_light(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>) ->
}

// start on_demand service.
let account_start_nonce = service.client().engine().account_start_nonce(0);
let on_demand = Arc::new(::light::on_demand::OnDemand::new(cache.clone(), account_start_nonce));
let on_demand = Arc::new(::light::on_demand::OnDemand::new(cache.clone()));

// set network path.
net_conf.net_config_path = Some(db_dirs.network_path().to_string_lossy().into_owned());
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/v1/helpers/fake_sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ pub fn sign_call<B: MiningBlockChainClient, M: MinerService>(
gas: request.gas.unwrap_or(50_000_000.into()),
gas_price: request.gas_price.unwrap_or_else(|| default_gas_price(&**client, &**miner)),
value: request.value.unwrap_or(0.into()),
data: request.data.unwrap_or(Vec::new())
data: request.data.unwrap_or_default(),
}.fake_sign(from))
}
2 changes: 1 addition & 1 deletion rpc/src/v1/helpers/light_fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl LightFetch {
let action = req.to.map_or(Action::Create, Action::Call);
let gas = req.gas.unwrap_or(U256::from(10_000_000)); // better gas amount?
let value = req.value.unwrap_or_else(U256::zero);
let data = req.data.unwrap_or(Vec::new());
let data = req.data.unwrap_or_default();

future::done(match nonce {
Some(n) => Ok(EthTransaction {
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/v1/tests/mocked/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ fn should_confirm_decrypt_with_phrase() {
), Origin::Unknown).unwrap();
assert_eq!(tester.signer.requests().len(), 1);

let decrypted = serde_json::to_string(&RpcBytes::new(b"phrase".into_vec())).unwrap();
let decrypted = serde_json::to_string(&RpcBytes::new(b"phrase".to_vec())).unwrap();

// when
let request = r#"{
Expand Down
22 changes: 11 additions & 11 deletions sync/src/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ mod test {
let blocks: Vec<_> = (0..nblocks)
.map(|i| (&client as &BlockChainClient).block(BlockId::Number(i as BlockNumber)).unwrap().into_inner())
.collect();
let headers: Vec<_> = blocks.iter().map(|b| Rlp::new(b).at(0).as_raw().into_vec()).collect();
let headers: Vec<_> = blocks.iter().map(|b| Rlp::new(b).at(0).as_raw().to_vec()).collect();
let hashes: Vec<_> = headers.iter().map(|h| HeaderView::new(h).sha3()).collect();
let heads: Vec<_> = hashes.iter().enumerate().filter_map(|(i, h)| if i % 20 == 0 { Some(h.clone()) } else { None }).collect();
bc.reset_to(heads);
Expand All @@ -541,7 +541,7 @@ mod test {
assert_eq!(bc.downloading_headers.len(), 1);
assert!(bc.drain().is_empty());

bc.insert_headers(headers[0..6].into_vec());
bc.insert_headers(headers[0..6].to_vec());
assert_eq!(hashes[5], bc.heads[0]);
for h in &hashes[0..6] {
bc.clear_header_download(h)
Expand All @@ -558,13 +558,13 @@ mod test {
assert_eq!(hashes[5], h);
let (h, _) = bc.needed_headers(6, false).unwrap();
assert_eq!(hashes[20], h);
bc.insert_headers(headers[10..16].into_vec());
bc.insert_headers(headers[10..16].to_vec());
assert!(bc.drain().is_empty());
bc.insert_headers(headers[5..10].into_vec());
bc.insert_headers(headers[5..10].to_vec());
assert_eq!(&bc.drain().into_iter().map(|b| b.block).collect::<Vec<_>>()[..], &blocks[6..16]);
assert_eq!(hashes[15], bc.heads[0]);

bc.insert_headers(headers[15..].into_vec());
bc.insert_headers(headers[15..].to_vec());
bc.drain();
assert!(bc.is_empty());
}
Expand All @@ -579,16 +579,16 @@ mod test {
let blocks: Vec<_> = (0..nblocks)
.map(|i| (&client as &BlockChainClient).block(BlockId::Number(i as BlockNumber)).unwrap().into_inner())
.collect();
let headers: Vec<_> = blocks.iter().map(|b| Rlp::new(b).at(0).as_raw().into_vec()).collect();
let headers: Vec<_> = blocks.iter().map(|b| Rlp::new(b).at(0).as_raw().to_vec()).collect();
let hashes: Vec<_> = headers.iter().map(|h| HeaderView::new(h).sha3()).collect();
let heads: Vec<_> = hashes.iter().enumerate().filter_map(|(i, h)| if i % 20 == 0 { Some(h.clone()) } else { None }).collect();
bc.reset_to(heads);

bc.insert_headers(headers[2..22].into_vec());
bc.insert_headers(headers[2..22].to_vec());
assert_eq!(hashes[0], bc.heads[0]);
assert_eq!(hashes[21], bc.heads[1]);
assert!(bc.head.is_none());
bc.insert_headers(headers[0..2].into_vec());
bc.insert_headers(headers[0..2].to_vec());
assert!(bc.head.is_some());
assert_eq!(hashes[21], bc.heads[0]);
}
Expand All @@ -603,14 +603,14 @@ mod test {
let blocks: Vec<_> = (0..nblocks)
.map(|i| (&client as &BlockChainClient).block(BlockId::Number(i as BlockNumber)).unwrap().into_inner())
.collect();
let headers: Vec<_> = blocks.iter().map(|b| Rlp::new(b).at(0).as_raw().into_vec()).collect();
let headers: Vec<_> = blocks.iter().map(|b| Rlp::new(b).at(0).as_raw().to_vec()).collect();
let hashes: Vec<_> = headers.iter().map(|h| HeaderView::new(h).sha3()).collect();
let heads: Vec<_> = hashes.iter().enumerate().filter_map(|(i, h)| if i % 20 == 0 { Some(h.clone()) } else { None }).collect();
bc.reset_to(heads);

bc.insert_headers(headers[1..2].into_vec());
bc.insert_headers(headers[1..2].to_vec());
assert!(bc.drain().is_empty());
bc.insert_headers(headers[0..1].into_vec());
bc.insert_headers(headers[0..1].to_vec());
assert_eq!(bc.drain().len(), 2);
}
}
Expand Down
4 changes: 2 additions & 2 deletions sync/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2361,14 +2361,14 @@ mod tests {
rlp.out()
}
fn to_header_vec(rlp: ::chain::RlpResponseResult) -> Vec<Bytes> {
Rlp::new(&rlp.unwrap().unwrap().1.out()).iter().map(|r| r.as_raw().into_vec()).collect()
Rlp::new(&rlp.unwrap().unwrap().1.out()).iter().map(|r| r.as_raw().to_vec()).collect()
}

let mut client = TestBlockChainClient::new();
client.add_blocks(100, EachBlockWith::Nothing);
let blocks: Vec<_> = (0 .. 100)
.map(|i| (&client as &BlockChainClient).block(BlockId::Number(i as BlockNumber)).map(|b| b.into_inner()).unwrap()).collect();
let headers: Vec<_> = blocks.iter().map(|b| Rlp::new(b).at(0).as_raw().into_vec()).collect();
let headers: Vec<_> = blocks.iter().map(|b| Rlp::new(b).at(0).as_raw().to_vec()).collect();
let hashes: Vec<_> = headers.iter().map(|h| HeaderView::new(h).sha3()).collect();

let queue = RwLock::new(VecDeque::new());
Expand Down
6 changes: 3 additions & 3 deletions sync/src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ mod test {
}

fn test_manifest() -> (ManifestData, H256, Vec<Bytes>, Vec<Bytes>) {
let state_chunks: Vec<Bytes> = (0..20).map(|_| H256::random().into_vec()).collect();
let block_chunks: Vec<Bytes> = (0..20).map(|_| H256::random().into_vec()).collect();
let state_chunks: Vec<Bytes> = (0..20).map(|_| H256::random().to_vec()).collect();
let block_chunks: Vec<Bytes> = (0..20).map(|_| H256::random().to_vec()).collect();
let manifest = ManifestData {
version: 2,
state_hashes: state_chunks.iter().map(|data| data.sha3()).collect(),
Expand Down Expand Up @@ -180,7 +180,7 @@ mod test {
let (manifest, mhash, state_chunks, block_chunks) = test_manifest();
snapshot.reset_to(&manifest, &mhash);
assert_eq!(snapshot.done_chunks(), 0);
assert!(snapshot.validate_chunk(&H256::random().into_vec()).is_err());
assert!(snapshot.validate_chunk(&H256::random().to_vec()).is_err());

let requested: Vec<H256> = (0..40).map(|_| snapshot.needed_chunk().unwrap()).collect();
assert!(snapshot.needed_chunk().is_none());
Expand Down
2 changes: 1 addition & 1 deletion sync/src/tests/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn forked_with_misbehaving_peer() {
let mut net = TestNet::new(3);

let mut alt_spec = ::ethcore::spec::Spec::new_test();
alt_spec.extra_data = b"fork".into_vec();
alt_spec.extra_data = b"fork".to_vec();
// peer 0 is on a totally different chain with higher total difficulty
net.peer_mut(0).chain = Arc::new(TestBlockChainClient::new_with_spec(alt_spec));
net.peer(0).chain.add_blocks(50, EachBlockWith::Nothing);
Expand Down
4 changes: 2 additions & 2 deletions sync/src/tests/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ impl TestSnapshotService {
pub fn new_with_snapshot(num_chunks: usize, block_hash: H256, block_number: BlockNumber) -> TestSnapshotService {
let num_state_chunks = num_chunks / 2;
let num_block_chunks = num_chunks - num_state_chunks;
let state_chunks: Vec<Bytes> = (0..num_state_chunks).map(|_| H256::random().into_vec()).collect();
let block_chunks: Vec<Bytes> = (0..num_block_chunks).map(|_| H256::random().into_vec()).collect();
let state_chunks: Vec<Bytes> = (0..num_state_chunks).map(|_| H256::random().to_vec()).collect();
let block_chunks: Vec<Bytes> = (0..num_block_chunks).map(|_| H256::random().to_vec()).collect();
let manifest = ManifestData {
version: 2,
state_hashes: state_chunks.iter().map(|data| data.sha3()).collect(),
Expand Down
Loading

0 comments on commit 1db1050

Please sign in to comment.