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

Commit

Permalink
Add a more realistic Batch test (#10511)
Browse files Browse the repository at this point in the history
* Remove unrealistic tests

* Add test that more closely resembles real usage
  • Loading branch information
HCastano authored Mar 25, 2019
1 parent 023e511 commit 6cf3ba7
Showing 1 changed file with 10 additions and 25 deletions.
35 changes: 10 additions & 25 deletions ethcore/light/src/types/request/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,7 @@ mod tests {
}

#[test]
#[should_panic]
fn batch_tx_index_backreference_wrong_output() {
fn batch_tx_index_backreference_public_api() {
let mut builder = Builder::default();
builder.push(Request::HeaderProof(IncompleteHeaderProofRequest {
num: 100.into(), // header proof puts hash at output 0.
Expand All @@ -286,11 +285,16 @@ mod tests {
})).unwrap();

let mut batch = builder.build();
batch.requests[1].fill(|_req_idx, _out_idx| Ok(Output::Number(42)));

batch.next_complete();
batch.answered += 1;
batch.next_complete();
assert!(batch.next_complete().is_some());
let hdr_proof_res = header_proof::Response {
proof: vec![],
hash: 12.into(),
td: 21.into(),
};
batch.supply_response_unchecked(&hdr_proof_res);

assert!(batch.next_complete().is_some());
}

#[test]
Expand All @@ -310,23 +314,4 @@ mod tests {
batch.answered += 1;
assert!(batch.next_complete().is_some());
}

#[test]
#[should_panic]
fn batch_receipts_backreference_wrong_output() {
let mut builder = Builder::default();
builder.push(Request::HeaderProof(IncompleteHeaderProofRequest {
num: 100.into(), // header proof puts hash at output 0.
})).unwrap();
builder.push(Request::Receipts(IncompleteReceiptsRequest {
hash: Field::BackReference(0, 0),
})).unwrap();

let mut batch = builder.build();
batch.requests[1].fill(|_req_idx, _out_idx| Ok(Output::Number(42)));

batch.next_complete();
batch.answered += 1;
batch.next_complete();
}
}

0 comments on commit 6cf3ba7

Please sign in to comment.