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

Type annotation for next_key() matching of json filter options #11192

Merged
merged 3 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ To start Parity Ethereum as a regular user using `systemd` init:

## 4. Testing <a id="chapter-004"></a>

You can run tests with the following commands:
Download the required test files: `git submodule update --init --recursive`. You can run tests with the following commands:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does cargo test --all fail without this? I thought it was needed only for cargo test --all --features=json-tests but maybe I'm wrong?

Copy link
Collaborator

@niklasad1 niklasad1 Oct 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it fails we have this macro which requires the ethereum tests submodule which is used in a couple of the rpc tests

Copy link
Contributor Author

@lamafab lamafab Oct 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if with --all, but it did fail for me when running cargo test -p parity-json


* **All** packages
```
Expand Down
8 changes: 4 additions & 4 deletions ethcore/src/miner/filter_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ impl<'de> Deserialize<'de> for FilterOptions {
M: MapAccess<'de>,
{
let mut filter = FilterOptions::default();
while let Some(key) = map.next_key()? {
match key {
while let Some(key) = map.next_key::<String>()? {
match key.as_str() {
"from" => {
filter.from = map.validate_from()?;
},
Expand Down Expand Up @@ -221,8 +221,8 @@ impl<'de> Deserialize<'de> for FilterOptions {
let mut counter = 0;
let mut f_op = Wrapper::O(FilterOperator::Any);

while let Some(key) = map.next_key()? {
match key {
while let Some(key) = map.next_key::<String>()? {
match key.as_str() {
"eq" => f_op = W::O(FilterOperator::Eq(map.next_value()?)),
"gt" => f_op = W::O(FilterOperator::GreaterThan(map.next_value()?)),
"lt" => f_op = W::O(FilterOperator::LessThan(map.next_value()?)),
Expand Down
35 changes: 34 additions & 1 deletion rpc/src/v1/tests/mocked/parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ fn rpc_parity_unsigned_transactions_count_when_signer_disabled() {
}

#[test]
fn rpc_parity_pending_transactions() {
fn rpc_parity_pending_transactions_without_limit_without_filter() {
let deps = Dependencies::new();
let io = deps.default_client();

Expand All @@ -326,6 +326,39 @@ fn rpc_parity_pending_transactions() {
assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
}

#[test]
fn rpc_parity_pending_transactions_with_limit_without_filter() {
let deps = Dependencies::new();
let io = deps.default_client();

let request = r#"{"jsonrpc": "2.0", "method": "parity_pendingTransactions", "params":[5], "id": 1}"#;
let response = r#"{"jsonrpc":"2.0","result":[],"id":1}"#;

assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
}

#[test]
fn rpc_parity_pending_transactions_without_limit_with_filter() {
let deps = Dependencies::new();
let io = deps.default_client();

let request = r#"{"jsonrpc": "2.0", "method": "parity_pendingTransactions", "params":[null,{"to":{"eq":"0xe8b2d01ffa0a15736b2370b6e5064f9702c891b6"},"gas":{"gt":"0x493e0"}}], "id": 1}"#;
let response = r#"{"jsonrpc":"2.0","result":[],"id":1}"#;

assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
}

#[test]
fn rpc_parity_pending_transactions_with_limit_with_filter() {
let deps = Dependencies::new();
let io = deps.default_client();

let request = r#"{"jsonrpc": "2.0", "method": "parity_pendingTransactions", "params":[5,{"to":{"eq":"0xe8b2d01ffa0a15736b2370b6e5064f9702c891b6"},"gas":{"gt":"0x493e0"}}], "id": 1}"#;
let response = r#"{"jsonrpc":"2.0","result":[],"id":1}"#;

assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
}

#[test]
fn rpc_parity_encrypt() {
let deps = Dependencies::new();
Expand Down