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

Commit

Permalink
2.4.3 beta backports (#10508)
Browse files Browse the repository at this point in the history
* version: bump beta

* Add additional request tests (#10503)
  • Loading branch information
soc1c authored Mar 22, 2019
1 parent e1c1ecf commit 33860c3
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 10 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description = "Parity Ethereum client"
name = "parity-ethereum"
# NOTE Make sure to update util/version/Cargo.toml as well
version = "2.4.2"
version = "2.4.3"
license = "GPL-3.0"
authors = ["Parity Technologies <admin@parity.io>"]

Expand Down
74 changes: 74 additions & 0 deletions ethcore/light/src/types/request/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,78 @@ mod tests {
hash: Field::BackReference(0, 0),
})).unwrap();
}

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

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

assert!(batch.next_complete().is_some());
batch.answered += 1;
assert!(batch.next_complete().is_some());
}

#[test]
#[should_panic]
fn batch_tx_index_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::TransactionIndex(IncompleteTransactionIndexRequest {
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();
}

#[test]
fn batch_receipts_backreference() {
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::Hash(42.into())));

assert!(batch.next_complete().is_some());
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();
}
}
4 changes: 2 additions & 2 deletions ethcore/light/src/types/request/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ pub mod transaction_index {
fn fill<F>(&mut self, oracle: F) where F: Fn(usize, usize) -> Result<Output, NoSuchOutput> {
if let Field::BackReference(req, idx) = self.hash {
self.hash = match oracle(req, idx) {
Ok(Output::Number(hash)) => Field::Scalar(hash.into()),
Ok(Output::Hash(hash)) => Field::Scalar(hash.into()),
_ => Field::BackReference(req, idx),
}
}
Expand Down Expand Up @@ -982,7 +982,7 @@ pub mod block_receipts {
fn fill<F>(&mut self, oracle: F) where F: Fn(usize, usize) -> Result<Output, NoSuchOutput> {
if let Field::BackReference(req, idx) = self.hash {
self.hash = match oracle(req, idx) {
Ok(Output::Number(hash)) => Field::Scalar(hash.into()),
Ok(Output::Hash(hash)) => Field::Scalar(hash.into()),
_ => Field::BackReference(req, idx),
}
}
Expand Down
2 changes: 1 addition & 1 deletion util/version/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[package]
name = "parity-version"
# NOTE: this value is used for Parity Ethereum version string (via env CARGO_PKG_VERSION)
version = "2.4.2"
version = "2.4.3"
authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs"

Expand Down

0 comments on commit 33860c3

Please sign in to comment.