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

Add a more realistic Batch test #10511

Merged
merged 2 commits into from
Mar 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}