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

Commit

Permalink
Type annotation for next_key() matching of json filter options (#11192)
Browse files Browse the repository at this point in the history
* type annotation for next_key matching of json filter options

* rpc tests for pending transactions

* mention git submodules in the readme
  • Loading branch information
lamafab authored and niklasad1 committed Nov 5, 2019
1 parent 6927d1d commit 469a342
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
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:
* **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 @@ -312,7 +312,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 @@ -322,6 +322,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

0 comments on commit 469a342

Please sign in to comment.