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

* type annotation for next_key matching of json filter options

* rpc tests for pending transactions

* mention git submodules in the readme
This commit is contained in:
Fabio Lama 2019-10-23 14:20:47 +02:00 committed by Marek Kotewicz
parent 834585d61b
commit acf7c48d7e
3 changed files with 39 additions and 6 deletions

View File

@ -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
```

View File

@ -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()?;
},
@ -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()?)),

View File

@ -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();
@ -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();