diff --git a/.travis.yml b/.travis.yml index 03b4edf9d..6428ccecf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ git: matrix: include: - rust: stable - env: RUN_TESTS="true" + env: RUN_TESTS="true" TEST_OPTIONS="--no-release" - rust: beta env: RUN_COVERAGE="true" - rust: stable @@ -30,6 +30,7 @@ env: - RUN_TESTS="false" - RUN_COVERAGE="false" - RUN_DOCS="false" + - TEST_OPTIONS="" # GH_TOKEN for documentation - secure: bumJASbZSU8bxJ0EyPUJmu16AiV9EXOpyOj86Jlq/Ty9CfwGqsSXt96uDyE+OUJf34RUFQMsw0nk37/zC4lcn6kqk2wpuH3N/o85Zo/cVZY/NusBWLQqtT5VbYWsV+u2Ua4Tmmsw8yVYQhYwU2ZOejNpflL+Cs9XGgORp1L+/gMRMC2y5Se6ZhwnKPQlRJ8LGsG1dzjQULxzADIt3/zuspNBS8a2urJwlHfGMkvHDoUWCviP/GXoSqw3TZR7FmKyxE19I8n9+iSvm9+oZZquvcgfUxMHn8Gq/b44UbPvjtFOg2yam4xdWXF/RyWCHdc/R9EHorSABeCbefIsm+zcUF3/YQxwpSxM4IZEeH2rTiC7dcrsKw3XsO16xFQz5YI5Bay+CT/wTdMmJd7DdYz7Dyf+pOvcM9WOf/zorxYWSBOMYy0uzbusU2iyIghQ82s7E/Ahg+WARtPgkuTLSB5aL1oCTBKHqQscMr7lo5Ti6RpWLxEdTQMBznc+bMr+6dEtkEcG9zqc6cE9XX+ox3wTU6+HVMfQ1ltCntJ4UKcw3A6INEbw9wgocQa812CIASQ2fE+SCAbz6JxBjIAlFUnD1lUB7S8PdMPwn9plfQgKQ2A5YZqg6FnBdf0rQXIJYxQWKHXj/rBHSUCT0tHACDlzTA+EwWggvkP5AGIxRxm8jhw= - KCOV_CMD="./kcov-master/tmp/usr/local/bin/kcov" @@ -64,7 +65,7 @@ install: ) script: - - if [ "$RUN_TESTS" = "true" ]; then ./test.sh --verbose; fi + - if [ "$RUN_TESTS" = "true" ]; then ./test.sh $TEST_OPTIONS --verbose; fi - if [ "$RUN_COVERAGE" = "true" ]; then ./scripts/cov.sh "$KCOV_CMD"; fi after_success: | diff --git a/Cargo.lock b/Cargo.lock index 79bb6dba9..980b2dbf7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,6 +70,14 @@ dependencies = [ "syntex_syntax 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "aster" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "syntex_syntax 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "bigint" version = "0.1.0" @@ -173,7 +181,7 @@ version = "1.1.1" source = "git+https://github.com/ethcore/rust-ctrlc.git#f4927770f89eca80ec250911eea3adcbf579ac48" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -182,7 +190,7 @@ name = "daemonize" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -203,6 +211,11 @@ dependencies = [ "strsim 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "dtoa" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "elastic-array" version = "0.4.0" @@ -224,21 +237,21 @@ source = "git+https://github.com/ethcore/rust-secp256k1#a9a0b1be1f39560ca86e8fc8 dependencies = [ "arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "gcc 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ethabi" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_codegen 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -289,11 +302,11 @@ name = "ethcore-dapps" version = "1.4.0" dependencies = [ "clippy 0.0.85 (registry+https://github.com/rust-lang/crates.io-index)", - "ethabi 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-rpc 1.4.0", "ethcore-util 1.4.0", "hyper 0.9.4 (git+https://github.com/ethcore/hyper)", - "jsonrpc-core 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-http-server 6.1.0 (git+https://github.com/ethcore/jsonrpc-http-server.git)", "linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -304,9 +317,9 @@ dependencies = [ "parity-dapps-wallet 1.4.0 (git+https://github.com/ethcore/parity-ui.git)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_codegen 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "zip 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", @@ -410,7 +423,7 @@ dependencies = [ "ethcrypto 0.1.0", "ethkey 0.2.0", "igd 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.5.1 (git+https://github.com/ethcore/mio?branch=v0.5.x)", "parking_lot 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -438,13 +451,13 @@ dependencies = [ "ethstore 0.1.0", "ethsync 1.4.0", "json-ipc-server 0.2.4 (git+https://github.com/ethcore/json-ipc-server.git)", - "jsonrpc-core 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-http-server 6.1.0 (git+https://github.com/ethcore/jsonrpc-http-server.git)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_codegen 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "transient-hashmap 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -458,7 +471,7 @@ dependencies = [ "ethcore-io 1.4.0", "ethcore-rpc 1.4.0", "ethcore-util 1.4.0", - "jsonrpc-core 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-dapps-signer 1.4.0 (git+https://github.com/ethcore/parity-ui.git)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", @@ -477,7 +490,7 @@ dependencies = [ "ethcore-ipc-nano 1.4.0", "ethcore-util 1.4.0", "json-tcp-server 0.1.0 (git+https://github.com/ethcore/json-tcp-server)", - "jsonrpc-core 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.5.1 (git+https://github.com/ethcore/mio?branch=v0.5.x)", @@ -499,7 +512,7 @@ dependencies = [ "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", @@ -533,9 +546,9 @@ version = "0.1.0" dependencies = [ "ethcore-util 1.4.0", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_codegen 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -558,13 +571,13 @@ dependencies = [ "ethkey 0.2.0", "itertools 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_codegen 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -594,7 +607,7 @@ dependencies = [ name = "fdlimit" version = "0.1.0" dependencies = [ - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -602,7 +615,7 @@ name = "flate2" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -711,7 +724,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -720,14 +733,19 @@ name = "itertools" version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "itoa" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "json-ipc-server" version = "0.2.4" -source = "git+https://github.com/ethcore/json-ipc-server.git#56b6307130710ebc73cb9be087b6ed0b6c400bcf" +source = "git+https://github.com/ethcore/json-ipc-server.git#5fbd0253750d3097b9a8fb27effa84c18d630bbb" dependencies = [ "bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -738,11 +756,11 @@ dependencies = [ [[package]] name = "json-tcp-server" version = "0.1.0" -source = "git+https://github.com/ethcore/json-tcp-server#05c186ea100e2107c1f9f83ca4c62cb6ed2c68bd" +source = "git+https://github.com/ethcore/json-tcp-server#c2858522274ae56042472bb5d22845a1b85e5338" dependencies = [ "bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -751,22 +769,24 @@ dependencies = [ [[package]] name = "jsonrpc-core" -version = "2.1.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_codegen 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-http-server" version = "6.1.0" -source = "git+https://github.com/ethcore/jsonrpc-http-server.git#4e3f93eb79125e91a46e04d77c25ff8885498b86" +source = "git+https://github.com/ethcore/jsonrpc-http-server.git#339f7209b01d26aea01722b3a69127235287d6a9" dependencies = [ "hyper 0.9.4 (git+https://github.com/ethcore/hyper)", - "jsonrpc-core 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -791,7 +811,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -814,7 +834,7 @@ name = "memchr" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -842,7 +862,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -851,7 +871,7 @@ version = "0.5.1" source = "git+https://github.com/ethcore/mio?branch=v0.5.x#3842d3b250ffd7bd9b16f9586b875ddcbac2b0dd" dependencies = [ "bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", @@ -867,7 +887,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", @@ -883,7 +903,7 @@ version = "0.6.0-dev" source = "git+https://github.com/carllerche/mio?rev=62ec763c9cc34d8a452ed0392c575c50ddd5fc8d#62ec763c9cc34d8a452ed0392c575c50ddd5fc8d" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", @@ -918,7 +938,7 @@ name = "nanomsg" version = "0.5.1" source = "git+https://github.com/ethcore/nanomsg.rs.git#c40fe442c9afaea5b38009a3d992ca044dcceb00" dependencies = [ - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "nanomsg-sys 0.5.0 (git+https://github.com/ethcore/nanomsg.rs.git)", ] @@ -928,7 +948,7 @@ version = "0.5.0" source = "git+https://github.com/ethcore/nanomsg.rs.git#c40fe442c9afaea5b38009a3d992ca044dcceb00" dependencies = [ "gcc 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -938,7 +958,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -949,7 +969,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -959,7 +979,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1049,7 +1069,7 @@ name = "num_cpus" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1117,7 +1137,7 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1210,6 +1230,15 @@ dependencies = [ "syntex_syntax 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "quasi" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "syntex_errors 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "quasi_codegen" version = "0.11.0" @@ -1220,6 +1249,17 @@ dependencies = [ "syntex_syntax 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "quasi_codegen" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aster 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.42.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_errors 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "quick-error" version = "1.1.0" @@ -1235,7 +1275,7 @@ name = "rand" version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1270,7 +1310,7 @@ name = "rocksdb" version = "0.4.5" source = "git+https://github.com/ethcore/rust-rocksdb#485dd747a2c9a9f910fc8ac696fc9edf5fa22aa3" dependencies = [ - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "rocksdb-sys 0.3.0 (git+https://github.com/ethcore/rust-rocksdb)", ] @@ -1280,7 +1320,7 @@ version = "0.3.0" source = "git+https://github.com/ethcore/rust-rocksdb#485dd747a2c9a9f910fc8ac696fc9edf5fa22aa3" dependencies = [ "gcc 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1300,7 +1340,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "termios 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1311,7 +1351,7 @@ version = "0.2.36" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1345,28 +1385,40 @@ dependencies = [ [[package]] name = "serde" -version = "0.7.9" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_codegen" -version = "0.7.9" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aster 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quasi 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quasi_codegen 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_syntax 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", + "aster 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quasi 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quasi_codegen 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen_internals 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.42.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_codegen_internals" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "syntex_errors 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_json" -version = "0.7.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "dtoa 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1433,19 +1485,64 @@ dependencies = [ "syntex_syntax 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syntex" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "syntex_errors 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syntex_errors" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_pos 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syntex_pos" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "syntex_syntax" version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syntex_syntax" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_errors 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_pos 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "table" version = "0.1.0" @@ -1464,12 +1561,21 @@ dependencies = [ "winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "term" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "termios" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1478,7 +1584,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1495,7 +1601,7 @@ version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1663,6 +1769,7 @@ dependencies = [ "checksum ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1f46cd5b1d660c938e3f92dfe7a73d832b3281479363dd0cd9c1c2fbf60f7962" "checksum arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "16e3bdb2f54b3ace0285975d59a97cf8ed3855294b2b6bc651fcf22a9c352975" "checksum aster 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07d344974f0a155f091948aa389fb1b912d3a58414fbdb9c8d446d193ee3496a" +"checksum aster 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4df293303e8a52e1df7984ac1415e195f5fcbf51e4bb7bda54557861a3954a08" "checksum bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9bf6104718e80d7b26a68fdbacff3481cfc05df670821affc7e9cbc1884400c" "checksum bit-vec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5b97c2c8e8bbb4251754f559df8af22fb264853c7d009084a576cdf12565089d" "checksum bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dead7461c1127cf637931a1e50934eb6eee8bff2f74433ac7909e9afcee04a3" @@ -1680,10 +1787,11 @@ dependencies = [ "checksum daemonize 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "271ec51b7e0bee92f0d04601422c73eb76ececf197026711c97ad25038a010cf" "checksum deque 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1614659040e711785ed8ea24219140654da1729f3ec8a47a9719d041112fe7bf" "checksum docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4cc0acb4ce0828c6a5a11d47baa432fe885881c27428c3a4e473e454ffe57a76" +"checksum dtoa 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0dd841b58510c9618291ffa448da2e4e0f699d984d436122372f446dae62263d" "checksum elastic-array 0.4.0 (git+https://github.com/ethcore/elastic-array)" = "" "checksum env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "aba65b63ffcc17ffacd6cf5aa843da7c5a25e3bd4bbe0b7def8b214e411250e5" "checksum eth-secp256k1 0.5.4 (git+https://github.com/ethcore/rust-secp256k1)" = "" -"checksum ethabi 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bc7789d1518abba0c61606826a5229284d47a9d0934feb62a1ee218882780a9b" +"checksum ethabi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0c53453517f620847be51943db329276ae52f2e210cfc659e81182864be2f" "checksum flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "3eeb481e957304178d2e782f2da1257f1434dfecbae883bafb61ada2a9fea3bb" "checksum gcc 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)" = "3da3a2cbaeb01363c8e3704fd9fd0eb2ceb17c6f27abd4c1ef040fb57d20dc79" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" @@ -1697,14 +1805,15 @@ dependencies = [ "checksum igd 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c8c12b1795b8b168f577c45fa10379b3814dcb11b7ab702406001f0d63f40484" "checksum isatty 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7408a548dc0e406b7912d9f84c261cc533c1866e047644a811c133c56041ac0c" "checksum itertools 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "086e1fa5fe48840b1cfdef3a20c7e3115599f8d5c4c87ef32a794a7cdd184d76" +"checksum itoa 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae3088ea4baeceb0284ee9eea42f591226e6beaecf65373e41b38d95a1b8e7a1" "checksum json-ipc-server 0.2.4 (git+https://github.com/ethcore/json-ipc-server.git)" = "" "checksum json-tcp-server 0.1.0 (git+https://github.com/ethcore/json-tcp-server)" = "" -"checksum jsonrpc-core 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ec4477e4e8218da23caa5dd31f4eb39999aa0ea9035660617eccfb19a23bf5ad" +"checksum jsonrpc-core 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e913b3c809aab9378889da8b990b4a46b98bd4794c8117946a1cf63c5f87bcde" "checksum jsonrpc-http-server 6.1.0 (git+https://github.com/ethcore/jsonrpc-http-server.git)" = "" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "49247ec2a285bb3dcb23cbd9c35193c025e7251bfce77c1d5da97e6362dffe7f" -"checksum libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "97def9dc7ce1d8e153e693e3a33020bc69972181adb2f871e87e888876feae49" +"checksum libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "23e3757828fa702a20072c37ff47938e9dd331b92fac6e223d26d4b7a55f7ee2" "checksum linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d262045c5b87c0861b3f004610afd0e2c851e2908d08b6c870cbb9d5f494ecd" "checksum log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ab83497bf8bf4ed2a74259c1c802351fcd67a65baa86394b6ba73c36f4838054" "checksum matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "15305656809ce5a4805b1ff2946892810992197ce1270ff79baded852187942e" @@ -1751,7 +1860,9 @@ dependencies = [ "checksum primal-estimate 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "56ea4531dde757b56906493c8604641da14607bf9cdaa80fb9c9cabd2429f8d5" "checksum primal-sieve 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7aa73fd87e5984a00bdb4c1b14d3d5d6d0bad01b2caaaf924c16ab7260ac946c" "checksum quasi 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b26543b563704e7d87f3ec7cfafb713010a905c5f1b155a8ab66863af43ca578" +"checksum quasi 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb7eaef226a434a570fa336bc99502c4f5878208c1ebdd83b2d0bc37b1b1c34c" "checksum quasi_codegen 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0881d9a45d5f9ebe4a7e77742f8c604f3658c212baf8dd711a692dd000bc648c" +"checksum quasi_codegen 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "62e90381b315dfd00bfe6efbfeeec9f03a6d66159c3a5c8411b6c550d24b08fd" "checksum quick-error 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0aad603e8d7fb67da22dbdf1f4b826ce8829e406124109e73cf1b2454b93a71c" "checksum quine-mc_cluskey 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6683b0e23d80813b1a535841f0048c1537d3f86d63c999e8373b39a9b0eb74a" "checksum rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "2791d88c6defac799c3f20d74f094ca33b9332612d9aef9078519c82e4fe04a5" @@ -1767,9 +1878,10 @@ dependencies = [ "checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" "checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" "checksum semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2d5b7638a1f03815d94e88cb3b3c08e87f0db4d683ef499d1836aaf70a45623f" -"checksum serde 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b76133a8a02f1c6ebd3fb9a2ecaab3d54302565a51320e80931adba571aadb1b" -"checksum serde_codegen 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c5b74ff4fb34013cc0b917dd182fefc05ee9af233b9d0d557078334554284d0e" -"checksum serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c88a751caa8f0000058fb971cd443ed2e6b653f33f5a47f29892a8bd44ca4c1" +"checksum serde 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b1dfda9ebb31d29fa8b94d7eb3031a86a8dcec065f0fe268a30f98867bf45775" +"checksum serde_codegen 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e422ae53d7933f59c6ff57e7b5870b5c9094b1f473f78ec33d89f8a692c3ec02" +"checksum serde_codegen_internals 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f877e2781ed0a323295d1c9f0e26556117b5a11489fc47b1848dfb98b3173d21" +"checksum serde_json 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e10f8a9d94b06cf5d3bef66475f04c8ff90950f1be7004c357ff9472ccbaebc" "checksum sha1 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cc30b1e1e8c40c121ca33b86c23308a090d19974ef001b4bf6e61fd1a0fb095c" "checksum slab 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d807fd58c4181bbabed77cb3b891ba9748241a552bcc5be698faaebefc54f46e" "checksum slab 0.2.0 (git+https://github.com/carllerche/slab?rev=5476efcafb)" = "" @@ -1780,9 +1892,14 @@ dependencies = [ "checksum stable-heap 0.1.0 (git+https://github.com/carllerche/stable-heap?rev=3c5cd1ca47)" = "" "checksum strsim 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e4d73a2c36a4d095ed1a6df5cbeac159863173447f7a82b3f4757426844ab825" "checksum syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "393b6dd0889df2b064beeea954cfda6bc2571604ac460deeae0fed55a53988af" +"checksum syntex 0.42.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0a30b08a6b383a22e5f6edc127d169670d48f905bb00ca79a00ea3e442ebe317" +"checksum syntex_errors 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)" = "04c48f32867b6114449155b2a82114b86d4b09e1bddb21c47ff104ab9172b646" +"checksum syntex_pos 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd49988e52451813c61fecbe9abb5cfd4e1b7bb6cdbb980a6fbcbab859171a6" "checksum syntex_syntax 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44bded3cabafc65c90b663b1071bd2d198a9ab7515e6ce729e4570aaf53c407e" +"checksum syntex_syntax 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7628a0506e8f9666fdabb5f265d0059b059edac9a3f810bda077abb5d826bd8d" "checksum target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c63f48baada5c52e65a29eef93ab4f8982681b67f9e8d29c7b05abcfec2b9ffe" "checksum term 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "f2077e54d38055cf1ca0fd7933a2e00cd3ec8f6fed352b2a377f06dcdaaf3281" +"checksum term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3deff8a2b3b6607d6d7cc32ac25c0b33709453ca9cceac006caac51e963cf94a" "checksum termios 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d5d9cf598a6d7ce700a4e6a9199da127e6819a61e64b68609683cc9a01b5683a" "checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" "checksum thread_local 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0694f51610ef7cfac7a1b81de7f1602ee5356e76541bcd62c40e71933338cab1" diff --git a/dapps/Cargo.toml b/dapps/Cargo.toml index 1f5a0c491..6344d67d6 100644 --- a/dapps/Cargo.toml +++ b/dapps/Cargo.toml @@ -11,17 +11,17 @@ build = "build.rs" [dependencies] rand = "0.3.14" log = "0.3" -jsonrpc-core = "2.1" +jsonrpc-core = "3.0" jsonrpc-http-server = { git = "https://github.com/ethcore/jsonrpc-http-server.git" } hyper = { default-features = false, git = "https://github.com/ethcore/hyper" } unicase = "1.3" url = "1.0" rustc-serialize = "0.3" -serde = "0.7.0" -serde_json = "0.7.0" -serde_macros = { version = "0.7.0", optional = true } +serde = "0.8" +serde_json = "0.8" +serde_macros = { version = "0.8", optional = true } zip = { version = "0.1", default-features = false } -ethabi = "0.2.1" +ethabi = "0.2.2" linked-hash-map = "0.3" ethcore-rpc = { path = "../rpc" } ethcore-util = { path = "../util" } @@ -34,7 +34,7 @@ mime_guess = { version = "1.6.1" } clippy = { version = "0.0.85", optional = true} [build-dependencies] -serde_codegen = { version = "0.7.0", optional = true } +serde_codegen = { version = "0.8", optional = true } [features] default = ["serde_codegen", "extra-dapps"] diff --git a/dapps/src/apps/fetcher.rs b/dapps/src/apps/fetcher.rs index e31aae55d..939022e7f 100644 --- a/dapps/src/apps/fetcher.rs +++ b/dapps/src/apps/fetcher.rs @@ -26,7 +26,7 @@ use std::sync::Arc; use std::sync::atomic::{AtomicBool}; use rustc_serialize::hex::FromHex; -use hyper::Control; +use hyper; use hyper::status::StatusCode; use random_filename; @@ -85,7 +85,7 @@ impl AppFetcher { } } - pub fn to_handler(&self, path: EndpointPath, control: Control) -> Box { + pub fn to_async_handler(&self, path: EndpointPath, control: hyper::Control) -> Box { let mut dapps = self.dapps.lock(); let app_id = path.app_id.clone(); @@ -94,7 +94,7 @@ impl AppFetcher { match status { // Just server dapp Some(&mut ContentStatus::Ready(ref endpoint)) => { - (None, endpoint.to_handler(path)) + (None, endpoint.to_async_handler(path, control)) }, // App is already being fetched Some(&mut ContentStatus::Fetching(_)) => { diff --git a/dapps/src/endpoint.rs b/dapps/src/endpoint.rs index dbb02a3d3..51e863f19 100644 --- a/dapps/src/endpoint.rs +++ b/dapps/src/endpoint.rs @@ -16,7 +16,7 @@ //! URL Endpoint traits -use hyper::{server, net}; +use hyper::{self, server, net}; use std::collections::BTreeMap; #[derive(Debug, PartialEq, Default, Clone)] @@ -43,4 +43,8 @@ pub trait Endpoint : Send + Sync { fn info(&self) -> Option<&EndpointInfo> { None } fn to_handler(&self, path: EndpointPath) -> Box; + + fn to_async_handler(&self, path: EndpointPath, _control: hyper::Control) -> Box { + self.to_handler(path) + } } diff --git a/dapps/src/router/mod.rs b/dapps/src/router/mod.rs index 94d0a0fc0..9eae83b36 100644 --- a/dapps/src/router/mod.rs +++ b/dapps/src/router/mod.rs @@ -73,20 +73,20 @@ impl server::Handler for Router { // Choose proper handler depending on path / domain let url = extract_url(&req); let endpoint = extract_endpoint(&url); + let control = self.control.take().expect("on_request is called only once; control is always defined at start; qed"); self.handler = match endpoint { // First check special endpoints (ref path, ref endpoint) if self.special.contains_key(endpoint) => { - self.special.get(endpoint).unwrap().to_handler(path.clone().unwrap_or_default()) + self.special.get(endpoint).unwrap().to_async_handler(path.clone().unwrap_or_default(), control) }, // Then delegate to dapp (Some(ref path), _) if self.endpoints.contains_key(&path.app_id) => { - self.endpoints.get(&path.app_id).unwrap().to_handler(path.clone()) + self.endpoints.get(&path.app_id).unwrap().to_async_handler(path.clone(), control) }, // Try to resolve and fetch the dapp (Some(ref path), _) if self.fetch.contains(&path.app_id) => { - let control = self.control.take().expect("on_request is called only once, thus control is always defined."); - self.fetch.to_handler(path.clone(), control) + self.fetch.to_async_handler(path.clone(), control) }, // Redirection to main page (maybe 404 instead?) (Some(ref path), _) if *req.method() == hyper::method::Method::Get => { @@ -100,7 +100,7 @@ impl server::Handler for Router { }, // RPC by default _ => { - self.special.get(&SpecialEndpoint::Rpc).unwrap().to_handler(EndpointPath::default()) + self.special.get(&SpecialEndpoint::Rpc).unwrap().to_async_handler(EndpointPath::default(), control) } }; @@ -135,7 +135,7 @@ impl Router { allowed_hosts: Option>, ) -> Self { - let handler = special.get(&SpecialEndpoint::Rpc).unwrap().to_handler(EndpointPath::default()); + let handler = special.get(&SpecialEndpoint::Api).unwrap().to_handler(EndpointPath::default()); Router { control: Some(control), main_page: main_page, diff --git a/dapps/src/rpc.rs b/dapps/src/rpc.rs index 04470bcc1..4fbc37772 100644 --- a/dapps/src/rpc.rs +++ b/dapps/src/rpc.rs @@ -15,6 +15,7 @@ // along with Parity. If not, see . use std::sync::{Arc, Mutex}; +use hyper; use jsonrpc_core::IoHandler; use jsonrpc_http_server::{ServerHandler, PanicHandler, AccessControlAllowOrigin}; use endpoint::{Endpoint, EndpointPath, Handler}; @@ -38,7 +39,17 @@ struct RpcEndpoint { impl Endpoint for RpcEndpoint { fn to_handler(&self, _path: EndpointPath) -> Box { + panic!("RPC Endpoint is asynchronous and requires Control object."); + } + + fn to_async_handler(&self, _path: EndpointPath, control: hyper::Control) -> Box { let panic_handler = PanicHandler { handler: self.panic_handler.clone() }; - Box::new(ServerHandler::new(self.handler.clone(), self.cors_domain.clone(), self.allowed_hosts.clone(), panic_handler)) + Box::new(ServerHandler::new( + self.handler.clone(), + self.cors_domain.clone(), + self.allowed_hosts.clone(), + panic_handler, + control, + )) } } diff --git a/ethstore/Cargo.toml b/ethstore/Cargo.toml index 1842456fd..7fa2a6890 100644 --- a/ethstore/Cargo.toml +++ b/ethstore/Cargo.toml @@ -8,9 +8,9 @@ build = "build.rs" libc = "0.2.11" rand = "0.3.14" ethkey = { path = "../ethkey" } -serde = "0.7" -serde_json = "0.7" -serde_macros = { version = "0.7", optional = true } +serde = "0.8" +serde_json = "0.8" +serde_macros = { version = "0.8", optional = true } rustc-serialize = "0.3" rust-crypto = "0.2.36" tiny-keccak = "1.0" @@ -21,7 +21,7 @@ itertools = "0.4" ethcrypto = { path = "../ethcrypto" } [build-dependencies] -serde_codegen = { version = "0.7", optional = true } +serde_codegen = { version = "0.8", optional = true } [features] default = ["serde_codegen"] diff --git a/ethstore/src/json/crypto.rs b/ethstore/src/json/crypto.rs index 9ff8c1e44..e6ecef81f 100644 --- a/ethstore/src/json/crypto.rs +++ b/ethstore/src/json/crypto.rs @@ -16,7 +16,6 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer, Error}; use serde::de::{Visitor, MapVisitor}; -use serde::ser; use super::{Cipher, CipherSer, CipherSerParams, Kdf, KdfSer, KdfSerParams, H256}; #[derive(Debug, PartialEq)] @@ -141,60 +140,26 @@ impl Serialize for Crypto { fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> where S: Serializer { - serializer.serialize_struct("Crypto", CryptoMapVisitor { - value: self, - state: 0, - }) - } -} - -struct CryptoMapVisitor<'a> { - value: &'a Crypto, - state: u8, -} - -impl<'a> ser::MapVisitor for CryptoMapVisitor<'a> { - fn visit(&mut self, serializer: &mut S) -> Result, S::Error> - where S: Serializer - { - match self.state { - 0 => { - self.state += 1; - match self.value.cipher { - Cipher::Aes128Ctr(_) => Ok(Some(try!(serializer.serialize_struct_elt("cipher", &CipherSer::Aes128Ctr)))), - } + let mut state = try!(serializer.serialize_struct("Crypto", 6)); + match self.cipher { + Cipher::Aes128Ctr(ref params) => { + try!(serializer.serialize_struct_elt(&mut state, "cipher", &CipherSer::Aes128Ctr)); + try!(serializer.serialize_struct_elt(&mut state, "cipherparams", params)); }, - 1 => { - self.state += 1; - match self.value.cipher { - Cipher::Aes128Ctr(ref params) => Ok(Some(try!(serializer.serialize_struct_elt("cipherparams", params)))), - } - }, - 2 => { - self.state += 1; - Ok(Some(try!(serializer.serialize_struct_elt("ciphertext", &self.value.ciphertext)))) - }, - 3 => { - self.state += 1; - match self.value.kdf { - Kdf::Pbkdf2(_) => Ok(Some(try!(serializer.serialize_struct_elt("kdf", &KdfSer::Pbkdf2)))), - Kdf::Scrypt(_) => Ok(Some(try!(serializer.serialize_struct_elt("kdf", &KdfSer::Scrypt)))), - } - }, - 4 => { - self.state += 1; - match self.value.kdf { - Kdf::Pbkdf2(ref params) => Ok(Some(try!(serializer.serialize_struct_elt("kdfparams", params)))), - Kdf::Scrypt(ref params) => Ok(Some(try!(serializer.serialize_struct_elt("kdfparams", params)))), - } - }, - 5 => { - self.state += 1; - Ok(Some(try!(serializer.serialize_struct_elt("mac", &self.value.mac)))) - }, - _ => { - Ok(None) - } } + try!(serializer.serialize_struct_elt(&mut state, "ciphertext", &self.ciphertext)); + match self.kdf { + Kdf::Pbkdf2(ref params) => { + try!(serializer.serialize_struct_elt(&mut state, "kdf", &KdfSer::Pbkdf2)); + try!(serializer.serialize_struct_elt(&mut state, "kdfparams", params)); + }, + Kdf::Scrypt(ref params) => { + try!(serializer.serialize_struct_elt(&mut state, "kdf", &KdfSer::Scrypt)); + try!(serializer.serialize_struct_elt(&mut state, "kdfparams", params)); + }, + } + + try!(serializer.serialize_struct_elt(&mut state, "mac", &self.mac)); + serializer.serialize_struct_end(state) } } diff --git a/json/Cargo.toml b/json/Cargo.toml index b5eb7afdd..3c66e1317 100644 --- a/json/Cargo.toml +++ b/json/Cargo.toml @@ -7,13 +7,13 @@ build = "build.rs" [dependencies] ethcore-util = { path = "../util" } rustc-serialize = "0.3" -serde = "0.7.0" -serde_json = "0.7.0" -serde_macros = { version = "0.7.0", optional = true } +serde = "0.8" +serde_json = "0.8" +serde_macros = { version = "0.8", optional = true } clippy = { version = "0.0.85", optional = true} [build-dependencies] -serde_codegen = { version = "0.7.0", optional = true } +serde_codegen = { version = "0.8", optional = true } [features] default = ["serde_codegen"] diff --git a/json/src/blockchain/blockchain.rs b/json/src/blockchain/blockchain.rs index 5d8933a07..3899f23e8 100644 --- a/json/src/blockchain/blockchain.rs +++ b/json/src/blockchain/blockchain.rs @@ -178,5 +178,5 @@ mod tests { }"#; let _deserialized: BlockChain = serde_json::from_str(s).unwrap(); // TODO: validate all fields - //} + } } diff --git a/json/src/bytes.rs b/json/src/bytes.rs index 8772cd207..c162d08ce 100644 --- a/json/src/bytes.rs +++ b/json/src/bytes.rs @@ -56,7 +56,7 @@ impl FromStr for Bytes { 2 if value.starts_with("0x") => vec![], _ if value.starts_with("0x") && value.len() % 2 == 1 => { let v = "0".to_owned() + &value[2..]; - FromHex::from_hex(v.as_ref() as &str).unwrap_or(vec![]), + FromHex::from_hex(v.as_str()).unwrap_or(vec![]) }, _ if value.starts_with("0x") => FromHex::from_hex(&value[2..]).unwrap_or(vec![]), _ => FromHex::from_hex(value).unwrap_or(vec![]), diff --git a/json/src/vm/call.rs b/json/src/vm/call.rs index 855853c40..ad226048e 100644 --- a/json/src/vm/call.rs +++ b/json/src/vm/call.rs @@ -39,9 +39,8 @@ pub struct Call { mod tests { use serde_json; use vm::Call; - use util::U256; + use util::{U256, H160 as Hash160}; use uint::Uint; - use util::hash::Address as Hash160; use hash::Address; use maybe::MaybeEmpty; use std::str::FromStr; diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index ac1fd96c5..11dc0bbe3 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -10,9 +10,9 @@ build = "build.rs" [dependencies] log = "0.3" -serde = "0.7.0" -serde_json = "0.7.0" -jsonrpc-core = "2.1" +serde = "0.8" +serde_json = "0.8" +jsonrpc-core = "3.0" jsonrpc-http-server = { git = "https://github.com/ethcore/jsonrpc-http-server.git" } ethcore-io = { path = "../util/io" } ethcore-util = { path = "../util" } @@ -25,14 +25,14 @@ ethjson = { path = "../json" } ethcore-devtools = { path = "../devtools" } rustc-serialize = "0.3" transient-hashmap = "0.1" -serde_macros = { version = "0.7.0", optional = true } +serde_macros = { version = "0.8.0", optional = true } clippy = { version = "0.0.85", optional = true} json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" } ethcore-ipc = { path = "../ipc/rpc" } time = "0.1" [build-dependencies] -serde_codegen = { version = "0.7.0", optional = true } +serde_codegen = { version = "0.8.0", optional = true } [features] default = ["serde_codegen"] diff --git a/rpc/src/v1/helpers/dispatch.rs b/rpc/src/v1/helpers/dispatch.rs index b26dca8dc..f96ba8f08 100644 --- a/rpc/src/v1/helpers/dispatch.rs +++ b/rpc/src/v1/helpers/dispatch.rs @@ -50,13 +50,13 @@ pub fn dispatch_transaction(client: &C, miner: &M, signed_transaction: Sig import .map_err(errors::from_transaction_error) - .and_then(|_| to_value(&hash)) + .map(|_| to_value(&hash)) } pub fn signature_with_password(accounts: &AccountProvider, address: Address, hash: H256, pass: String) -> Result { accounts.sign_with_password(address, pass, hash) .map_err(errors::from_password_error) - .and_then(|hash| to_value(&RpcH520::from(hash))) + .map(|hash| to_value(&RpcH520::from(hash))) } pub fn unlock_sign_and_dispatch(client: &C, miner: &M, request: TransactionRequest, account_provider: &AccountProvider, password: String) -> Result diff --git a/rpc/src/v1/helpers/errors.rs b/rpc/src/v1/helpers/errors.rs index fbd134e33..8a11f2466 100644 --- a/rpc/src/v1/helpers/errors.rs +++ b/rpc/src/v1/helpers/errors.rs @@ -38,7 +38,8 @@ mod codes { pub const ACCOUNT_ERROR: i64 = -32023; pub const SIGNER_DISABLED: i64 = -32030; pub const REQUEST_REJECTED: i64 = -32040; - pub const REQUEST_NOT_FOUND: i64 = -32041; + pub const REQUEST_REJECTED_LIMIT: i64 = -32041; + pub const REQUEST_NOT_FOUND: i64 = -32042; pub const COMPILATION_ERROR: i64 = -32050; } @@ -66,6 +67,13 @@ pub fn request_rejected() -> Error { } } +pub fn request_rejected_limit() -> Error { + Error { + code: ErrorCode::ServerError(codes::REQUEST_REJECTED_LIMIT), + message: "Request has been rejected because of queue limit.".into(), + data: None, + } +} pub fn account(error: &str, details: T) -> Error { Error { diff --git a/rpc/src/v1/helpers/signing_queue.rs b/rpc/src/v1/helpers/signing_queue.rs index 616d35364..22e15d0d6 100644 --- a/rpc/src/v1/helpers/signing_queue.rs +++ b/rpc/src/v1/helpers/signing_queue.rs @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -use std::thread; -use std::time::{Instant, Duration}; +use std::mem; +use std::cell::RefCell; use std::sync::{mpsc, Arc}; use std::collections::BTreeMap; use jsonrpc_core; @@ -47,14 +47,23 @@ pub enum QueueError { ReceiverError(mpsc::RecvError), } +/// Defines possible errors when inserting to queue +#[derive(Debug, PartialEq)] +pub enum QueueAddError { + LimitReached, +} + /// Message Receiver type pub type QueueEventReceiver = mpsc::Receiver; +// TODO [todr] to consider: timeout instead of limit? +const QUEUE_LIMIT: usize = 50; + /// A queue of transactions awaiting to be confirmed and signed. pub trait SigningQueue: Send + Sync { /// Add new request to the queue. /// Returns a `ConfirmationPromise` that can be used to await for resolution of given request. - fn add_request(&self, request: ConfirmationPayload) -> ConfirmationPromise; + fn add_request(&self, request: ConfirmationPayload) -> Result; /// Removes a request from the queue. /// Notifies possible token holders that request was rejected. @@ -88,42 +97,45 @@ pub enum ConfirmationResult { Confirmed(RpcResult), } -/// Time you need to confirm the request in UI. -/// This is the amount of time token holder will wait before -/// returning `None`. -/// Unless we have a multi-threaded RPC this will lock -/// any other incoming call! -const QUEUE_TIMEOUT_DURATION_SEC : u64 = 20; +type Listener = Box) + Send>; /// A handle to submitted request. /// Allows to block and wait for a resolution of that request. pub struct ConfirmationToken { result: Arc>, - handle: thread::Thread, + listeners: Arc>>, request: ConfirmationRequest, - timeout: Duration, } pub struct ConfirmationPromise { id: U256, result: Arc>, - timeout: Duration, + listeners: Arc>>, } impl ConfirmationToken { /// Submit solution to all listeners fn resolve(&self, result: Option) { - let mut res = self.result.lock(); - *res = result.map_or(ConfirmationResult::Rejected, |h| ConfirmationResult::Confirmed(h)); + let wrapped = result.clone().map_or(ConfirmationResult::Rejected, |h| ConfirmationResult::Confirmed(h)); + { + let mut res = self.result.lock(); + *res = wrapped.clone(); + } // Notify listener - self.handle.unpark(); + let listeners = { + let mut listeners = self.listeners.lock(); + mem::replace(&mut *listeners, Vec::new()) + }; + for mut listener in listeners { + listener(result.clone()); + } } fn as_promise(&self) -> ConfirmationPromise { ConfirmationPromise { id: self.request.id, result: self.result.clone(), - timeout: self.timeout, + listeners: self.listeners.clone(), } } } @@ -132,49 +144,31 @@ impl ConfirmationPromise { /// Get the ID for this request. pub fn id(&self) -> U256 { self.id } - /// Blocks current thread and awaits for - /// resolution of the transaction (rejected / confirmed) - /// Returns `None` if transaction was rejected or timeout reached. - /// Returns `Some(result)` if transaction was confirmed. - pub fn wait_with_timeout(&self) -> Option { - let res = self.wait_until(Instant::now() + self.timeout); - match res { - ConfirmationResult::Confirmed(h) => Some(h), - ConfirmationResult::Rejected | ConfirmationResult::Waiting => None, - } + /// Just get the result, assuming it exists. + pub fn result(&self) -> ConfirmationResult { + self.result.lock().clone() } - /// Just get the result, assuming it exists. - pub fn result(&self) -> ConfirmationResult { self.wait_until(Instant::now()) } - - /// Blocks current thread and awaits for - /// resolution of the request (rejected / confirmed) - /// Returns `None` if request was rejected or timeout reached. - /// Returns `Some(result)` if request was confirmed. - pub fn wait_until(&self, deadline: Instant) -> ConfirmationResult { + pub fn wait_for_result(self, callback: F) where F: FnOnce(Option) + Send + 'static { trace!(target: "own_tx", "Signer: Awaiting confirmation... ({:?}).", self.id); - loop { - let now = Instant::now(); - // Check the result... - match *self.result.lock() { - // Waiting and deadline not yet passed continue looping. - ConfirmationResult::Waiting if now < deadline => {} - // Anything else - return. - ref a => return a.clone(), - } - // wait a while longer - maybe the solution will arrive. - thread::park_timeout(deadline - now); - } + let _result = self.result.lock(); + let mut listeners = self.listeners.lock(); + // TODO [todr] Overcoming FnBox unstability + let callback = RefCell::new(Some(callback)); + listeners.push(Box::new(move |result| { + let ref mut f = *callback.borrow_mut(); + f.take().expect("Callbacks are called only once.")(result) + })); } } + /// Queue for all unconfirmed requests. pub struct ConfirmationsQueue { id: Mutex, queue: RwLock>, sender: Mutex>, receiver: Mutex>>, - timeout: Duration, } impl Default for ConfirmationsQueue { @@ -186,19 +180,11 @@ impl Default for ConfirmationsQueue { queue: RwLock::new(BTreeMap::new()), sender: Mutex::new(send), receiver: Mutex::new(Some(recv)), - timeout: Duration::from_secs(QUEUE_TIMEOUT_DURATION_SEC), } } } impl ConfirmationsQueue { - #[cfg(test)] - /// Creates new confirmations queue with specified timeout - pub fn with_timeout(timeout: Duration) -> Self { - let mut queue = Self::default(); - queue.timeout = timeout; - queue - } /// Blocks the thread and starts listening for notifications regarding all actions in the queue. /// For each event, `listener` callback will be invoked. @@ -260,7 +246,11 @@ impl Drop for ConfirmationsQueue { } impl SigningQueue for ConfirmationsQueue { - fn add_request(&self, request: ConfirmationPayload) -> ConfirmationPromise { + fn add_request(&self, request: ConfirmationPayload) -> Result { + if self.len() > QUEUE_LIMIT { + return Err(QueueAddError::LimitReached); + } + // Increment id let id = { let mut last_id = self.id.lock(); @@ -275,19 +265,17 @@ impl SigningQueue for ConfirmationsQueue { let mut queue = self.queue.write(); queue.insert(id, ConfirmationToken { result: Arc::new(Mutex::new(ConfirmationResult::Waiting)), - handle: thread::current(), + listeners: Default::default(), request: ConfirmationRequest { id: id, payload: request, }, - timeout: self.timeout, }); queue.get(&id).map(|token| token.as_promise()).expect("Token was just inserted.") }; // Notify listeners self.notify(QueueEvent::NewRequest(id)); - res - + Ok(res) } fn peek(&self, id: &U256) -> Option { @@ -325,7 +313,7 @@ impl SigningQueue for ConfirmationsQueue { mod test { use std::time::Duration; use std::thread; - use std::sync::Arc; + use std::sync::{mpsc, Arc}; use util::{Address, U256, H256, Mutex}; use v1::helpers::{SigningQueue, ConfirmationsQueue, QueueEvent, FilledTransactionRequest, ConfirmationPayload}; use v1::types::H256 as NH256; @@ -352,8 +340,12 @@ mod test { // when let q = queue.clone(); let handle = thread::spawn(move || { - let v = q.add_request(request); - v.wait_with_timeout().expect("Should return hash") + let v = q.add_request(request).unwrap(); + let (tx, rx) = mpsc::channel(); + v.wait_for_result(move |res| { + tx.send(res).unwrap(); + }); + rx.recv().unwrap().expect("Should return hash") }); let id = U256::from(1); @@ -361,10 +353,10 @@ mod test { // Just wait for the other thread to start thread::sleep(Duration::from_millis(100)); } - queue.request_confirmed(id, to_value(&NH256::from(H256::from(1)))); + queue.request_confirmed(id, Ok(to_value(&NH256::from(H256::from(1))))); // then - assert_eq!(handle.join().expect("Thread should finish nicely"), to_value(&NH256::from(H256::from(1)))); + assert_eq!(handle.join().expect("Thread should finish nicely"), Ok(to_value(&NH256::from(H256::from(1))))); } #[test] @@ -383,7 +375,7 @@ mod test { *v = Some(notification); }).expect("Should be closed nicely.") }); - queue.add_request(request); + queue.add_request(request).unwrap(); queue.finish(); // then @@ -399,7 +391,7 @@ mod test { let request = request(); // when - queue.add_request(request.clone()); + queue.add_request(request.clone()).unwrap(); let all = queue.requests(); // then diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index d805d57ee..be69a221d 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -131,7 +131,7 @@ impl EthClient where }, extra_data: Bytes::new(view.extra_data()) }; - to_value(&block) + Ok(to_value(&block)) }, _ => Ok(Value::Null) } @@ -139,7 +139,7 @@ impl EthClient where fn transaction(&self, id: TransactionID) -> Result { match take_weak!(self.client).transaction(id) { - Some(t) => to_value(&Transaction::from(t)), + Some(t) => Ok(to_value(&Transaction::from(t))), None => Ok(Value::Null) } } @@ -177,7 +177,7 @@ impl EthClient where uncles: vec![], transactions: BlockTransactions::Hashes(vec![]), }; - to_value(&block) + Ok(to_value(&block)) } fn sign_call(&self, request: CRequest) -> Result { @@ -270,28 +270,28 @@ impl Eth for EthClient where } } }; - to_value(&res) + Ok(to_value(&res)) } fn author(&self, params: Params) -> Result { try!(self.active()); try!(expect_no_params(params)); - to_value(&RpcH160::from(take_weak!(self.miner).author())) + Ok(to_value(&RpcH160::from(take_weak!(self.miner).author()))) } fn is_mining(&self, params: Params) -> Result { try!(self.active()); try!(expect_no_params(params)); - to_value(&(take_weak!(self.miner).is_sealing())) + Ok(to_value(&(take_weak!(self.miner).is_sealing()))) } fn hashrate(&self, params: Params) -> Result { try!(self.active()); try!(expect_no_params(params)); - to_value(&RpcU256::from(self.external_miner.hashrate())) + Ok(to_value(&RpcU256::from(self.external_miner.hashrate()))) } fn gas_price(&self, params: Params) -> Result { @@ -299,7 +299,7 @@ impl Eth for EthClient where try!(expect_no_params(params)); let (client, miner) = (take_weak!(self.client), take_weak!(self.miner)); - to_value(&RpcU256::from(default_gas_price(&*client, &*miner))) + Ok(to_value(&RpcU256::from(default_gas_price(&*client, &*miner)))) } fn accounts(&self, params: Params) -> Result { @@ -308,14 +308,14 @@ impl Eth for EthClient where let store = take_weak!(self.accounts); let accounts = try!(store.accounts().map_err(|e| errors::internal("Could not fetch accounts.", e))); - to_value(&accounts.into_iter().map(Into::into).collect::>()) + Ok(to_value(&accounts.into_iter().map(Into::into).collect::>())) } fn block_number(&self, params: Params) -> Result { try!(self.active()); try!(expect_no_params(params)); - to_value(&RpcU256::from(take_weak!(self.client).chain_info().best_block_number)) + Ok(to_value(&RpcU256::from(take_weak!(self.client).chain_info().best_block_number))) } fn balance(&self, params: Params) -> Result { @@ -324,9 +324,9 @@ impl Eth for EthClient where .and_then(|(address, block_number,)| { let address: Address = RpcH160::into(address); match block_number { - BlockNumber::Pending => to_value(&RpcU256::from(take_weak!(self.miner).balance(&*take_weak!(self.client), &address))), + BlockNumber::Pending => Ok(to_value(&RpcU256::from(take_weak!(self.miner).balance(&*take_weak!(self.client), &address)))), id => match take_weak!(self.client).balance(&address, id.into()) { - Some(balance) => to_value(&RpcU256::from(balance)), + Some(balance) => Ok(to_value(&RpcU256::from(balance))), None => Err(errors::state_pruned()), } } @@ -340,9 +340,9 @@ impl Eth for EthClient where let address: Address = RpcH160::into(address); let position: U256 = RpcU256::into(position); match block_number { - BlockNumber::Pending => to_value(&RpcU256::from(take_weak!(self.miner).storage_at(&*take_weak!(self.client), &address, &H256::from(position)))), + BlockNumber::Pending => Ok(to_value(&RpcU256::from(take_weak!(self.miner).storage_at(&*take_weak!(self.client), &address, &H256::from(position))))), id => match take_weak!(self.client).storage_at(&address, &H256::from(position), id.into()) { - Some(s) => to_value(&RpcH256::from(s)), + Some(s) => Ok(to_value(&RpcH256::from(s))), None => Err(errors::state_pruned()), } } @@ -356,9 +356,9 @@ impl Eth for EthClient where .and_then(|(address, block_number,)| { let address: Address = RpcH160::into(address); match block_number { - BlockNumber::Pending => to_value(&RpcU256::from(take_weak!(self.miner).nonce(&*take_weak!(self.client), &address))), + BlockNumber::Pending => Ok(to_value(&RpcU256::from(take_weak!(self.miner).nonce(&*take_weak!(self.client), &address)))), id => match take_weak!(self.client).nonce(&address, id.into()) { - Some(nonce) => to_value(&RpcU256::from(nonce)), + Some(nonce) => Ok(to_value(&RpcU256::from(nonce))), None => Err(errors::state_pruned()), } } @@ -370,18 +370,18 @@ impl Eth for EthClient where from_params::<(RpcH256,)>(params) .and_then(|(hash,)| // match take_weak!(self.client).block(BlockID::Hash(hash.into())) - .map_or(Ok(Value::Null), |bytes| to_value(&RpcU256::from(BlockView::new(&bytes).transactions_count())))) + .map_or(Ok(Value::Null), |bytes| Ok(to_value(&RpcU256::from(BlockView::new(&bytes).transactions_count()))))) } fn block_transaction_count_by_number(&self, params: Params) -> Result { try!(self.active()); from_params::<(BlockNumber,)>(params) .and_then(|(block_number,)| match block_number { - BlockNumber::Pending => to_value( + BlockNumber::Pending => Ok(to_value( &RpcU256::from(take_weak!(self.miner).status().transactions_in_pending_block) - ), + )), _ => take_weak!(self.client).block(block_number.into()) - .map_or(Ok(Value::Null), |bytes| to_value(&RpcU256::from(BlockView::new(&bytes).transactions_count()))) + .map_or(Ok(Value::Null), |bytes| Ok(to_value(&RpcU256::from(BlockView::new(&bytes).transactions_count())))) }) } @@ -390,16 +390,16 @@ impl Eth for EthClient where from_params::<(RpcH256,)>(params) .and_then(|(hash,)| take_weak!(self.client).block(BlockID::Hash(hash.into())) - .map_or(Ok(Value::Null), |bytes| to_value(&RpcU256::from(BlockView::new(&bytes).uncles_count())))) + .map_or(Ok(Value::Null), |bytes| Ok(to_value(&RpcU256::from(BlockView::new(&bytes).uncles_count()))))) } fn block_uncles_count_by_number(&self, params: Params) -> Result { try!(self.active()); from_params::<(BlockNumber,)>(params) .and_then(|(block_number,)| match block_number { - BlockNumber::Pending => to_value(&RpcU256::from(0)), + BlockNumber::Pending => Ok(to_value(&RpcU256::from(0))), _ => take_weak!(self.client).block(block_number.into()) - .map_or(Ok(Value::Null), |bytes| to_value(&RpcU256::from(BlockView::new(&bytes).uncles_count()))) + .map_or(Ok(Value::Null), |bytes| Ok(to_value(&RpcU256::from(BlockView::new(&bytes).uncles_count())))) }) } @@ -409,9 +409,9 @@ impl Eth for EthClient where .and_then(|(address, block_number,)| { let address: Address = RpcH160::into(address); match block_number { - BlockNumber::Pending => to_value(&take_weak!(self.miner).code(&*take_weak!(self.client), &address).map_or_else(Bytes::default, Bytes::new)), + BlockNumber::Pending => Ok(to_value(&take_weak!(self.miner).code(&*take_weak!(self.client), &address).map_or_else(Bytes::default, Bytes::new))), _ => match take_weak!(self.client).code(&address, block_number.into()) { - Some(code) => to_value(&code.map_or_else(Bytes::default, Bytes::new)), + Some(code) => Ok(to_value(&code.map_or_else(Bytes::default, Bytes::new))), None => Err(errors::state_pruned()), }, } @@ -437,7 +437,7 @@ impl Eth for EthClient where let miner = take_weak!(self.miner); let hash: H256 = hash.into(); match miner.transaction(&hash) { - Some(pending_tx) => to_value(&Transaction::from(pending_tx)), + Some(pending_tx) => Ok(to_value(&Transaction::from(pending_tx))), None => self.transaction(TransactionID::Hash(hash)) } }) @@ -462,11 +462,11 @@ impl Eth for EthClient where let miner = take_weak!(self.miner); let hash: H256 = hash.into(); match (miner.pending_receipt(&hash), self.options.allow_pending_receipt_query) { - (Some(receipt), true) => to_value(&Receipt::from(receipt)), + (Some(receipt), true) => Ok(to_value(&Receipt::from(receipt))), _ => { let client = take_weak!(self.client); let receipt = client.transaction_receipt(TransactionID::Hash(hash)); - to_value(&receipt.map(Receipt::from)) + Ok(to_value(&receipt.map(Receipt::from))) } } }) @@ -492,7 +492,7 @@ impl Eth for EthClient where if Command::new(SOLC).output().is_ok() { compilers.push("solidity".to_owned()) } - to_value(&compilers) + Ok(to_value(&compilers)) } fn logs(&self, params: Params) -> Result { @@ -511,7 +511,7 @@ impl Eth for EthClient where logs.extend(pending); } - to_value(&logs) + Ok(to_value(&logs)) }) } @@ -550,9 +550,9 @@ impl Eth for EthClient where Err(errors::no_new_work()) } else if self.options.send_block_number_in_get_work { let block_number = RpcU256::from(b.block().header().number()); - to_value(&(RpcH256::from(pow_hash), RpcH256::from(seed_hash), RpcH256::from(target), block_number)) + Ok(to_value(&(RpcH256::from(pow_hash), RpcH256::from(seed_hash), RpcH256::from(target), block_number))) } else { - to_value(&(RpcH256::from(pow_hash), RpcH256::from(seed_hash), RpcH256::from(target))) + Ok(to_value(&(RpcH256::from(pow_hash), RpcH256::from(seed_hash), RpcH256::from(target)))) } }).unwrap_or(Err(Error::internal_error())) // no work found. } @@ -568,7 +568,7 @@ impl Eth for EthClient where let client = take_weak!(self.client); let seal = vec![encode(&mix_hash).to_vec(), encode(&nonce).to_vec()]; let r = miner.submit_seal(&*client, pow_hash, seal); - to_value(&r.is_ok()) + Ok(to_value(&r.is_ok())) }) } @@ -576,7 +576,7 @@ impl Eth for EthClient where try!(self.active()); from_params::<(RpcU256, RpcH256)>(params).and_then(|(rate, id)| { self.external_miner.submit_hashrate(rate.into(), id.into()); - to_value(&true) + Ok(to_value(&true)) }) } @@ -587,7 +587,7 @@ impl Eth for EthClient where let raw_transaction = raw_transaction.to_vec(); match UntrustedRlp::new(&raw_transaction).as_val() { Ok(signed_transaction) => dispatch_transaction(&*take_weak!(self.client), &*take_weak!(self.miner), signed_transaction), - Err(_) => to_value(&RpcH256::from(H256::from(0))), + Err(_) => Ok(to_value(&RpcH256::from(H256::from(0)))), } }) } @@ -602,7 +602,7 @@ impl Eth for EthClient where BlockNumber::Pending => take_weak!(self.miner).call(&*take_weak!(self.client), &signed, Default::default()), block_number => take_weak!(self.client).call(&signed, block_number.into(), Default::default()), }; - to_value(&r.map(|e| Bytes(e.output)).unwrap_or(Bytes::new(vec![]))) + Ok(to_value(&r.map(|e| Bytes(e.output)).unwrap_or(Bytes::new(vec![])))) }) } @@ -616,7 +616,7 @@ impl Eth for EthClient where BlockNumber::Pending => take_weak!(self.miner).call(&*take_weak!(self.client), &signed, Default::default()), block => take_weak!(self.client).call(&signed, block.into(), Default::default()), }; - to_value(&RpcU256::from(r.map(|res| res.gas_used + res.refunded).unwrap_or(From::from(0)))) + Ok(to_value(&RpcU256::from(r.map(|res| res.gas_used + res.refunded).unwrap_or(From::from(0))))) }) } @@ -653,7 +653,7 @@ impl Eth for EthClient where let s = String::from_utf8_lossy(&output.stdout); if let Some(hex) = s.lines().skip_while(|ref l| !l.contains("Binary")).skip(1).next() { - to_value(&Bytes::new(hex.from_hex().unwrap_or(vec![]))) + Ok(to_value(&Bytes::new(hex.from_hex().unwrap_or(vec![])))) } else { Err(errors::compilation("Unexpected output.")) } diff --git a/rpc/src/v1/impls/eth_filter.rs b/rpc/src/v1/impls/eth_filter.rs index 973e23e0b..a4c834e99 100644 --- a/rpc/src/v1/impls/eth_filter.rs +++ b/rpc/src/v1/impls/eth_filter.rs @@ -70,7 +70,7 @@ impl EthFilter for EthFilterClient where let mut polls = self.polls.lock(); let block_number = take_weak!(self.client).chain_info().best_block_number; let id = polls.create_poll(PollFilter::Logs(block_number, Default::default(), filter)); - to_value(&RpcU256::from(id)) + Ok(to_value(&RpcU256::from(id))) }) } @@ -80,7 +80,7 @@ impl EthFilter for EthFilterClient where let mut polls = self.polls.lock(); let id = polls.create_poll(PollFilter::Block(take_weak!(self.client).chain_info().best_block_number)); - to_value(&RpcU256::from(id)) + Ok(to_value(&RpcU256::from(id))) } fn new_pending_transaction_filter(&self, params: Params) -> Result { @@ -91,7 +91,7 @@ impl EthFilter for EthFilterClient where let pending_transactions = take_weak!(self.miner).pending_transactions_hashes(); let id = polls.create_poll(PollFilter::PendingTransaction(pending_transactions)); - to_value(&RpcU256::from(id)) + Ok(to_value(&RpcU256::from(id))) } fn filter_changes(&self, params: Params) -> Result { @@ -114,7 +114,7 @@ impl EthFilter for EthFilterClient where *block_number = current_number; - to_value(&hashes) + Ok(to_value(&hashes)) }, PollFilter::PendingTransaction(ref mut previous_hashes) => { // get hashes of pending transactions @@ -137,7 +137,7 @@ impl EthFilter for EthFilterClient where *previous_hashes = current_hashes; // return new hashes - to_value(&new_hashes) + Ok(to_value(&new_hashes)) }, PollFilter::Logs(ref mut block_number, ref mut previous_logs, ref filter) => { // retrive the current block number @@ -178,7 +178,7 @@ impl EthFilter for EthFilterClient where // we want to get logs *block_number = current_number + 1; - to_value(&logs) + Ok(to_value(&logs)) } } } @@ -203,7 +203,7 @@ impl EthFilter for EthFilterClient where logs.extend(pending_logs(&*take_weak!(self.miner), &filter)); } - to_value(&logs) + Ok(to_value(&logs)) }, // just empty array _ => Ok(Value::Array(vec![] as Vec)), @@ -214,7 +214,7 @@ impl EthFilter for EthFilterClient where fn uninstall_filter(&self, params: Params) -> Result { try!(self.active()); from_params::<(Index,)>(params) - .and_then(|(index,)| { + .map(|(index,)| { self.polls.lock().remove_poll(&index.value()); to_value(&true) }) diff --git a/rpc/src/v1/impls/eth_signing.rs b/rpc/src/v1/impls/eth_signing.rs index 98aec52a2..c19b5819d 100644 --- a/rpc/src/v1/impls/eth_signing.rs +++ b/rpc/src/v1/impls/eth_signing.rs @@ -53,6 +53,11 @@ pub struct EthSigningQueueClient where C: MiningBlockChainClient, M: Miner const MAX_PENDING_DURATION: u64 = 60 * 60; +pub enum DispatchResult { + Promise(ConfirmationPromise), + Value(Value), +} + impl EthSigningQueueClient where C: MiningBlockChainClient, M: MinerService { /// Creates a new signing queue client given shared signing queue. pub fn new(queue: &Arc, client: &Arc, miner: &Arc, accounts: &Arc) -> Self { @@ -71,23 +76,24 @@ impl EthSigningQueueClient where C: MiningBlockChainClient, M: Miner Ok(()) } - fn dispatch_sign Result>(&self, params: Params, f: F) -> Result { + fn dispatch_sign(&self, params: Params) -> Result { from_params::<(RpcH160, RpcH256)>(params).and_then(|(address, msg)| { let address: Address = address.into(); let msg: H256 = msg.into(); let accounts = take_weak!(self.accounts); if accounts.is_unlocked(address) { - return to_value(&accounts.sign(address, msg).ok().map_or_else(RpcH520::default, Into::into)); + return Ok(DispatchResult::Value(to_value(&accounts.sign(address, msg).ok().map_or_else(RpcH520::default, Into::into)))) } let queue = take_weak!(self.queue); - let promise = queue.add_request(ConfirmationPayload::Sign(address, msg)); - f(promise) + queue.add_request(ConfirmationPayload::Sign(address, msg)) + .map(DispatchResult::Promise) + .map_err(|_| errors::request_rejected_limit()) }) } - fn dispatch_transaction Result>(&self, params: Params, f: F) -> Result { + fn dispatch_transaction(&self, params: Params) -> Result { from_params::<(TransactionRequest, )>(params) .and_then(|(request, )| { let request: TRequest = request.into(); @@ -96,13 +102,14 @@ impl EthSigningQueueClient where C: MiningBlockChainClient, M: Miner if accounts.is_unlocked(request.from) { let sender = request.from; - return sign_and_dispatch(&*client, &*miner, request, &*accounts, sender); + return sign_and_dispatch(&*client, &*miner, request, &*accounts, sender).map(DispatchResult::Value); } let queue = take_weak!(self.queue); let request = fill_optional_fields(request, &*client, &*miner); - let promise = queue.add_request(ConfirmationPayload::Transaction(request)); - f(promise) + queue.add_request(ConfirmationPayload::Transaction(request)) + .map(DispatchResult::Promise) + .map_err(|_| errors::request_rejected_limit()) }) } } @@ -111,35 +118,53 @@ impl EthSigning for EthSigningQueueClient where C: MiningBlockChainClient + 'static, M: MinerService + 'static { - fn sign(&self, params: Params) -> Result { - try!(self.active()); - self.dispatch_sign(params, |promise| { - promise.wait_with_timeout().unwrap_or_else(|| to_value(&RpcH520::default())) - }) + fn sign(&self, params: Params, ready: Ready) { + let res = self.active().and_then(|_| self.dispatch_sign(params)); + match res { + Ok(DispatchResult::Promise(promise)) => { + promise.wait_for_result(move |result| { + ready.ready(result.unwrap_or_else(|| Err(errors::request_rejected()))) + }) + }, + Ok(DispatchResult::Value(v)) => ready.ready(Ok(v)), + Err(e) => ready.ready(Err(e)), + } } fn post_sign(&self, params: Params) -> Result { try!(self.active()); - self.dispatch_sign(params, |promise| { - let id = promise.id(); - self.pending.lock().insert(id, promise); - to_value(&RpcU256::from(id)) + self.dispatch_sign(params).map(|result| match result { + DispatchResult::Value(v) => v, + DispatchResult::Promise(promise) => { + let id = promise.id(); + self.pending.lock().insert(id, promise); + to_value(&RpcU256::from(id)) + }, }) } - fn send_transaction(&self, params: Params) -> Result { - try!(self.active()); - self.dispatch_transaction(params, |promise| { - promise.wait_with_timeout().unwrap_or_else(|| to_value(&RpcH256::default())) - }) + fn send_transaction(&self, params: Params, ready: Ready) { + let res = self.active().and_then(|_| self.dispatch_transaction(params)); + match res { + Ok(DispatchResult::Promise(promise)) => { + promise.wait_for_result(move |result| { + ready.ready(result.unwrap_or_else(|| Err(errors::request_rejected()))) + }) + }, + Ok(DispatchResult::Value(v)) => ready.ready(Ok(v)), + Err(e) => ready.ready(Err(e)), + } } fn post_transaction(&self, params: Params) -> Result { try!(self.active()); - self.dispatch_transaction(params, |promise| { - let id = promise.id(); - self.pending.lock().insert(id, promise); - to_value(&RpcU256::from(id)) + self.dispatch_transaction(params).map(|result| match result { + DispatchResult::Value(v) => v, + DispatchResult::Promise(promise) => { + let id = promise.id(); + self.pending.lock().insert(id, promise); + to_value(&RpcU256::from(id)) + }, }) } @@ -196,23 +221,24 @@ impl EthSigning for EthSigningUnsafeClient where C: MiningBlockChainClient + 'static, M: MinerService + 'static { - fn sign(&self, params: Params) -> Result { - try!(self.active()); - from_params::<(RpcH160, RpcH256)>(params).and_then(|(address, msg)| { - let address: Address = address.into(); - let msg: H256 = msg.into(); - to_value(&take_weak!(self.accounts).sign(address, msg).ok().map_or_else(RpcH520::default, Into::into)) - }) + fn sign(&self, params: Params, ready: Ready) { + ready.ready(self.active() + .and_then(|_| from_params::<(RpcH160, RpcH256)>(params)) + .and_then(|(address, msg)| { + let address: Address = address.into(); + let msg: H256 = msg.into(); + Ok(to_value(&take_weak!(self.accounts).sign(address, msg).ok().map_or_else(RpcH520::default, Into::into))) + })) } - fn send_transaction(&self, params: Params) -> Result { - try!(self.active()); - from_params::<(TransactionRequest, )>(params) + fn send_transaction(&self, params: Params, ready: Ready) { + ready.ready(self.active() + .and_then(|_| from_params::<(TransactionRequest, )>(params)) .and_then(|(request, )| { let request: TRequest = request.into(); let sender = request.from; sign_and_dispatch(&*take_weak!(self.client), &*take_weak!(self.miner), request, &*take_weak!(self.accounts), sender) - }) + })) } fn post_sign(&self, _: Params) -> Result { diff --git a/rpc/src/v1/impls/ethcore.rs b/rpc/src/v1/impls/ethcore.rs index 16b0f1931..ee352e65a 100644 --- a/rpc/src/v1/impls/ethcore.rs +++ b/rpc/src/v1/impls/ethcore.rs @@ -82,50 +82,50 @@ impl Ethcore for EthcoreClient where M: MinerService + fn transactions_limit(&self, params: Params) -> Result { try!(self.active()); try!(expect_no_params(params)); - to_value(&take_weak!(self.miner).transactions_limit()) + Ok(to_value(&take_weak!(self.miner).transactions_limit())) } fn min_gas_price(&self, params: Params) -> Result { try!(self.active()); try!(expect_no_params(params)); - to_value(&U256::from(take_weak!(self.miner).minimal_gas_price())) + Ok(to_value(&U256::from(take_weak!(self.miner).minimal_gas_price()))) } fn extra_data(&self, params: Params) -> Result { try!(self.active()); try!(expect_no_params(params)); - to_value(&Bytes::new(take_weak!(self.miner).extra_data())) + Ok(to_value(&Bytes::new(take_weak!(self.miner).extra_data()))) } fn gas_floor_target(&self, params: Params) -> Result { try!(self.active()); try!(expect_no_params(params)); - to_value(&U256::from(take_weak!(self.miner).gas_floor_target())) + Ok(to_value(&U256::from(take_weak!(self.miner).gas_floor_target()))) } fn gas_ceil_target(&self, params: Params) -> Result { try!(self.active()); try!(expect_no_params(params)); - to_value(&U256::from(take_weak!(self.miner).gas_ceil_target())) + Ok(to_value(&U256::from(take_weak!(self.miner).gas_ceil_target()))) } fn dev_logs(&self, params: Params) -> Result { try!(self.active()); try!(expect_no_params(params)); let logs = self.logger.logs(); - to_value(&logs.as_slice()) + Ok(to_value(&logs.as_slice())) } fn dev_logs_levels(&self, params: Params) -> Result { try!(self.active()); try!(expect_no_params(params)); - to_value(&self.logger.levels()) + Ok(to_value(&self.logger.levels())) } fn net_chain(&self, params: Params) -> Result { try!(self.active()); try!(expect_no_params(params)); - to_value(&self.settings.chain) + Ok(to_value(&self.settings.chain)) } fn net_peers(&self, params: Params) -> Result { @@ -135,23 +135,23 @@ impl Ethcore for EthcoreClient where M: MinerService + let sync_status = take_weak!(self.sync).status(); let net_config = take_weak!(self.net).network_config(); - to_value(&Peers { + Ok(to_value(&Peers { active: sync_status.num_active_peers, connected: sync_status.num_peers, max: sync_status.current_max_peers(net_config.min_peers, net_config.max_peers), - }) + })) } fn net_port(&self, params: Params) -> Result { try!(self.active()); try!(expect_no_params(params)); - to_value(&self.settings.network_port) + Ok(to_value(&self.settings.network_port)) } fn node_name(&self, params: Params) -> Result { try!(self.active()); try!(expect_no_params(params)); - to_value(&self.settings.name) + Ok(to_value(&self.settings.name)) } fn registry_address(&self, params: Params) -> Result { @@ -162,7 +162,7 @@ impl Ethcore for EthcoreClient where M: MinerService + .get("registrar") .and_then(|s| Address::from_str(s).ok()) .map(|s| H160::from(s)); - to_value(&r) + Ok(to_value(&r)) } fn rpc_settings(&self, params: Params) -> Result { @@ -178,7 +178,7 @@ impl Ethcore for EthcoreClient where M: MinerService + fn default_extra_data(&self, params: Params) -> Result { try!(self.active()); try!(expect_no_params(params)); - to_value(&Bytes::new(version_data())) + Ok(to_value(&Bytes::new(version_data()))) } fn gas_price_statistics(&self, params: Params) -> Result { @@ -186,10 +186,10 @@ impl Ethcore for EthcoreClient where M: MinerService + try!(expect_no_params(params)); match take_weak!(self.client).gas_price_statistics(100, 8) { - Ok(stats) => to_value(&stats + Ok(stats) => Ok(to_value(&stats .into_iter() - .map(|x| to_value(&U256::from(x)).expect("x must be U256; qed")) - .collect::>()), + .map(|x| to_value(&U256::from(x))) + .collect::>())), _ => Err(Error::internal_error()), } } @@ -200,7 +200,7 @@ impl Ethcore for EthcoreClient where M: MinerService + match self.confirmations_queue { None => Err(errors::signer_disabled()), - Some(ref queue) => to_value(&queue.len()), + Some(ref queue) => Ok(to_value(&queue.len())), } } @@ -208,12 +208,12 @@ impl Ethcore for EthcoreClient where M: MinerService + try!(self.active()); try!(expect_no_params(params)); - to_value(&random_phrase(12)) + Ok(to_value(&random_phrase(12))) } fn phrase_to_address(&self, params: Params) -> Result { try!(self.active()); - from_params::<(String,)>(params).and_then(|(phrase,)| + from_params::<(String,)>(params).map(|(phrase,)| to_value(&H160::from(Brain::new(phrase).generate().unwrap().address())) ) } diff --git a/rpc/src/v1/impls/ethcore_set.rs b/rpc/src/v1/impls/ethcore_set.rs index a5e037b5f..35b97f785 100644 --- a/rpc/src/v1/impls/ethcore_set.rs +++ b/rpc/src/v1/impls/ethcore_set.rs @@ -62,7 +62,7 @@ impl EthcoreSet for EthcoreSetClient where try!(self.active()); from_params::<(U256,)>(params).and_then(|(gas_price,)| { take_weak!(self.miner).set_minimal_gas_price(gas_price.into()); - to_value(&true) + Ok(to_value(&true)) }) } @@ -70,7 +70,7 @@ impl EthcoreSet for EthcoreSetClient where try!(self.active()); from_params::<(U256,)>(params).and_then(|(target,)| { take_weak!(self.miner).set_gas_floor_target(target.into()); - to_value(&true) + Ok(to_value(&true)) }) } @@ -78,7 +78,7 @@ impl EthcoreSet for EthcoreSetClient where try!(self.active()); from_params::<(U256,)>(params).and_then(|(target,)| { take_weak!(self.miner).set_gas_ceil_target(target.into()); - to_value(&true) + Ok(to_value(&true)) }) } @@ -86,7 +86,7 @@ impl EthcoreSet for EthcoreSetClient where try!(self.active()); from_params::<(Bytes,)>(params).and_then(|(extra_data,)| { take_weak!(self.miner).set_extra_data(extra_data.to_vec()); - to_value(&true) + Ok(to_value(&true)) }) } @@ -94,7 +94,7 @@ impl EthcoreSet for EthcoreSetClient where try!(self.active()); from_params::<(H160,)>(params).and_then(|(author,)| { take_weak!(self.miner).set_author(author.into()); - to_value(&true) + Ok(to_value(&true)) }) } @@ -102,7 +102,7 @@ impl EthcoreSet for EthcoreSetClient where try!(self.active()); from_params::<(usize,)>(params).and_then(|(limit,)| { take_weak!(self.miner).set_transactions_limit(limit); - to_value(&true) + Ok(to_value(&true)) }) } @@ -110,7 +110,7 @@ impl EthcoreSet for EthcoreSetClient where try!(self.active()); from_params::<(U256,)>(params).and_then(|(limit,)| { take_weak!(self.miner).set_tx_gas_limit(limit.into()); - to_value(&true) + Ok(to_value(&true)) }) } @@ -118,7 +118,7 @@ impl EthcoreSet for EthcoreSetClient where try!(self.active()); from_params::<(String,)>(params).and_then(|(peer,)| { match take_weak!(self.net).add_reserved_peer(peer) { - Ok(()) => to_value(&true), + Ok(()) => Ok(to_value(&true)), Err(e) => Err(errors::invalid_params("Peer address", e)), } }) @@ -128,7 +128,7 @@ impl EthcoreSet for EthcoreSetClient where try!(self.active()); from_params::<(String,)>(params).and_then(|(peer,)| { match take_weak!(self.net).remove_reserved_peer(peer) { - Ok(()) => to_value(&true), + Ok(()) => Ok(to_value(&true)), Err(e) => Err(errors::invalid_params("Peer address", e)), } }) @@ -138,14 +138,14 @@ impl EthcoreSet for EthcoreSetClient where try!(self.active()); try!(expect_no_params(params)); take_weak!(self.net).deny_unreserved_peers(); - to_value(&true) + Ok(to_value(&true)) } fn accept_non_reserved_peers(&self, params: Params) -> Result { try!(self.active()); try!(expect_no_params(params)); take_weak!(self.net).accept_unreserved_peers(); - to_value(&true) + Ok(to_value(&true)) } fn start_network(&self, params: Params) -> Result { diff --git a/rpc/src/v1/impls/personal.rs b/rpc/src/v1/impls/personal.rs index 4d7008e09..009f173b3 100644 --- a/rpc/src/v1/impls/personal.rs +++ b/rpc/src/v1/impls/personal.rs @@ -63,9 +63,9 @@ impl Personal for PersonalClient where C: MiningBl try!(self.active()); try!(expect_no_params(params)); - self.signer_port + Ok(self.signer_port .map(|v| to_value(&v)) - .unwrap_or_else(|| to_value(&false)) + .unwrap_or_else(|| to_value(&false))) } fn accounts(&self, params: Params) -> Result { @@ -74,7 +74,7 @@ impl Personal for PersonalClient where C: MiningBl let store = take_weak!(self.accounts); let accounts = try!(store.accounts().map_err(|e| errors::internal("Could not fetch accounts.", e))); - to_value(&accounts.into_iter().map(Into::into).collect::>()) + Ok(to_value(&accounts.into_iter().map(Into::into).collect::>())) } fn new_account(&self, params: Params) -> Result { @@ -83,7 +83,7 @@ impl Personal for PersonalClient where C: MiningBl |(pass, )| { let store = take_weak!(self.accounts); match store.new_account(&pass) { - Ok(address) => to_value(&RpcH160::from(address)), + Ok(address) => Ok(to_value(&RpcH160::from(address))), Err(e) => Err(errors::account("Could not create account.", e)), } } @@ -96,7 +96,7 @@ impl Personal for PersonalClient where C: MiningBl |(phrase, pass, )| { let store = take_weak!(self.accounts); match store.insert_account(*Brain::new(phrase).generate().unwrap().secret(), &pass) { - Ok(address) => to_value(&RpcH160::from(address)), + Ok(address) => Ok(to_value(&RpcH160::from(address))), Err(e) => Err(errors::account("Could not create account.", e)), } } @@ -109,7 +109,7 @@ impl Personal for PersonalClient where C: MiningBl |(json, pass, )| { let store = take_weak!(self.accounts); match store.import_presale(json.as_bytes(), &pass).or_else(|_| store.import_wallet(json.as_bytes(), &pass)) { - Ok(address) => to_value(&RpcH160::from(address)), + Ok(address) => Ok(to_value(&RpcH160::from(address))), Err(e) => Err(errors::account("Could not create account.", e)), } } @@ -174,10 +174,10 @@ impl Personal for PersonalClient where C: MiningBl let other = store.addresses_info().expect("addresses_info always returns Ok; qed"); Ok(Value::Object(info.into_iter().chain(other.into_iter()).map(|(a, v)| { let m = map![ - "name".to_owned() => to_value(&v.name).unwrap(), - "meta".to_owned() => to_value(&v.meta).unwrap(), + "name".to_owned() => to_value(&v.name), + "meta".to_owned() => to_value(&v.meta), "uuid".to_owned() => if let &Some(ref uuid) = &v.uuid { - to_value(uuid).unwrap() + to_value(uuid) } else { Value::Null } @@ -190,16 +190,16 @@ impl Personal for PersonalClient where C: MiningBl try!(self.active()); try!(expect_no_params(params)); let store = take_weak!(self.accounts); - to_value(&store.list_geth_accounts(false).into_iter().map(Into::into).collect::>()) + Ok(to_value(&store.list_geth_accounts(false).into_iter().map(Into::into).collect::>())) } fn import_geth_accounts(&self, params: Params) -> Result { from_params::<(Vec,)>(params).and_then(|(addresses,)| { let store = take_weak!(self.accounts); - to_value(&try!(store + Ok(to_value(&try!(store .import_geth_accounts(addresses.into_iter().map(Into::into).collect(), false) .map_err(|e| errors::account("Couldn't import Geth accounts", e)) - ).into_iter().map(Into::into).collect::>()) + ).into_iter().map(Into::into).collect::>())) }) } } diff --git a/rpc/src/v1/impls/personal_signer.rs b/rpc/src/v1/impls/personal_signer.rs index bd58fde7d..5cfda9a65 100644 --- a/rpc/src/v1/impls/personal_signer.rs +++ b/rpc/src/v1/impls/personal_signer.rs @@ -60,7 +60,7 @@ impl PersonalSigner for SignerClient where C: Mini try!(self.active()); try!(expect_no_params(params)); let queue = take_weak!(self.queue); - to_value(&queue.requests().into_iter().map(From::from).collect::>()) + Ok(to_value(&queue.requests().into_iter().map(From::from).collect::>())) } fn confirm_request(&self, params: Params) -> Result { @@ -104,7 +104,7 @@ impl PersonalSigner for SignerClient where C: Mini |(id, )| { let queue = take_weak!(self.queue); let res = queue.request_rejected(id.into()); - to_value(&res.is_some()) + Ok(to_value(&res.is_some())) } ) } diff --git a/rpc/src/v1/impls/traces.rs b/rpc/src/v1/impls/traces.rs index e5f84d9ef..acbedd3c2 100644 --- a/rpc/src/v1/impls/traces.rs +++ b/rpc/src/v1/impls/traces.rs @@ -80,7 +80,7 @@ impl Traces for TracesClient where C: BlockChainClient + 'static, M: let client = take_weak!(self.client); let traces = client.filter_traces(filter.into()); let traces = traces.map_or_else(Vec::new, |traces| traces.into_iter().map(LocalizedTrace::from).collect()); - to_value(&traces) + Ok(to_value(&traces)) }) } @@ -91,7 +91,7 @@ impl Traces for TracesClient where C: BlockChainClient + 'static, M: let client = take_weak!(self.client); let traces = client.block_traces(block_number.into()); let traces = traces.map_or_else(Vec::new, |traces| traces.into_iter().map(LocalizedTrace::from).collect()); - to_value(&traces) + Ok(to_value(&traces)) }) } @@ -102,7 +102,7 @@ impl Traces for TracesClient where C: BlockChainClient + 'static, M: let client = take_weak!(self.client); let traces = client.transaction_traces(TransactionID::Hash(transaction_hash.into())); let traces = traces.map_or_else(Vec::new, |traces| traces.into_iter().map(LocalizedTrace::from).collect()); - to_value(&traces) + Ok(to_value(&traces)) }) } @@ -117,7 +117,7 @@ impl Traces for TracesClient where C: BlockChainClient + 'static, M: }; let trace = client.trace(id); let trace = trace.map(LocalizedTrace::from); - to_value(&trace) + Ok(to_value(&trace)) }) } @@ -128,7 +128,7 @@ impl Traces for TracesClient where C: BlockChainClient + 'static, M: let request = CallRequest::into(request); let signed = try!(self.sign_call(request)); match take_weak!(self.client).call(&signed, block.into(), to_call_analytics(flags)) { - Ok(e) => to_value(&TraceResults::from(e)), + Ok(e) => Ok(to_value(&TraceResults::from(e))), _ => Ok(Value::Null), } }) @@ -141,7 +141,7 @@ impl Traces for TracesClient where C: BlockChainClient + 'static, M: let raw_transaction = Bytes::to_vec(raw_transaction); match UntrustedRlp::new(&raw_transaction).as_val() { Ok(signed) => match take_weak!(self.client).call(&signed, block.into(), to_call_analytics(flags)) { - Ok(e) => to_value(&TraceResults::from(e)), + Ok(e) => Ok(to_value(&TraceResults::from(e))), _ => Ok(Value::Null), }, Err(e) => Err(errors::invalid_params("Transaction is not valid RLP", e)), @@ -154,7 +154,7 @@ impl Traces for TracesClient where C: BlockChainClient + 'static, M: from_params::<(H256, _)>(params) .and_then(|(transaction_hash, flags)| { match take_weak!(self.client).replay(TransactionID::Hash(transaction_hash.into()), to_call_analytics(flags)) { - Ok(e) => to_value(&TraceResults::from(e)), + Ok(e) => Ok(to_value(&TraceResults::from(e))), _ => Ok(Value::Null), } }) diff --git a/rpc/src/v1/impls/web3.rs b/rpc/src/v1/impls/web3.rs index d4ff4f7aa..3f987d27e 100644 --- a/rpc/src/v1/impls/web3.rs +++ b/rpc/src/v1/impls/web3.rs @@ -37,7 +37,7 @@ impl Web3 for Web3Client { } fn sha3(&self, params: Params) -> Result { - from_params::<(Bytes,)>(params).and_then( + from_params::<(Bytes,)>(params).map( |(data,)| { let Bytes(ref vec) = data; let sha3 = vec.sha3(); diff --git a/rpc/src/v1/tests/eth.rs b/rpc/src/v1/tests/eth.rs index 301492540..117b783db 100644 --- a/rpc/src/v1/tests/eth.rs +++ b/rpc/src/v1/tests/eth.rs @@ -157,7 +157,7 @@ fn eth_get_balance() { "id": 1 }"#; let res_latest = r#"{"jsonrpc":"2.0","result":"0x09","id":1}"#.to_owned(); - assert_eq!(tester.handler.handle_request(req_latest).unwrap(), res_latest); + assert_eq!(tester.handler.handle_request_sync(req_latest).unwrap(), res_latest); // non-existant account let req_new_acc = r#"{ @@ -168,7 +168,7 @@ fn eth_get_balance() { }"#; let res_new_acc = r#"{"jsonrpc":"2.0","result":"0x00","id":3}"#.to_owned(); - assert_eq!(tester.handler.handle_request(req_new_acc).unwrap(), res_new_acc); + assert_eq!(tester.handler.handle_request_sync(req_new_acc).unwrap(), res_new_acc); } #[test] @@ -183,7 +183,7 @@ fn eth_block_number() { }"#; let res_number = r#"{"jsonrpc":"2.0","result":"0x20","id":1}"#.to_owned(); - assert_eq!(tester.handler.handle_request(req_number).unwrap(), res_number); + assert_eq!(tester.handler.handle_request_sync(req_number).unwrap(), res_number); } // a frontier-like test with an expanded gas limit and balance on known account. @@ -299,7 +299,7 @@ fn eth_transaction_count() { let res_before = r#"{"jsonrpc":"2.0","result":"0x00","id":15}"#; - assert_eq!(tester.handler.handle_request(&req_before).unwrap(), res_before); + assert_eq!(tester.handler.handle_request_sync(&req_before).unwrap(), res_before); let req_send_trans = r#"{ "jsonrpc": "2.0", @@ -315,7 +315,7 @@ fn eth_transaction_count() { }"#; // dispatch the transaction. - tester.handler.handle_request(&req_send_trans).unwrap(); + tester.handler.handle_request_sync(&req_send_trans).unwrap(); // we have submitted the transaction -- but this shouldn't be reflected in a "latest" query. let req_after_latest = r#"{ @@ -327,7 +327,7 @@ fn eth_transaction_count() { let res_after_latest = r#"{"jsonrpc":"2.0","result":"0x00","id":17}"#; - assert_eq!(&tester.handler.handle_request(&req_after_latest).unwrap(), res_after_latest); + assert_eq!(&tester.handler.handle_request_sync(&req_after_latest).unwrap(), res_after_latest); // the pending transactions should have been updated. let req_after_pending = r#"{ @@ -339,7 +339,7 @@ fn eth_transaction_count() { let res_after_pending = r#"{"jsonrpc":"2.0","result":"0x01","id":18}"#; - assert_eq!(&tester.handler.handle_request(&req_after_pending).unwrap(), res_after_pending); + assert_eq!(&tester.handler.handle_request_sync(&req_after_pending).unwrap(), res_after_pending); } fn verify_transaction_counts(name: String, chain: BlockChain) { @@ -400,12 +400,12 @@ fn verify_transaction_counts(name: String, chain: BlockChain) { let number = b.header_view().number(); let (req, res) = by_hash(hash, count, &mut id); - assert_eq!(tester.handler.handle_request(&req), Some(res)); + assert_eq!(tester.handler.handle_request_sync(&req), Some(res)); // uncles can share block numbers, so skip them. if tester.client.block_hash(BlockID::Number(number)) == Some(hash) { let (req, res) = by_number(number, count, &mut id); - assert_eq!(tester.handler.handle_request(&req), Some(res)); + assert_eq!(tester.handler.handle_request_sync(&req), Some(res)); } } } @@ -415,7 +415,7 @@ fn starting_nonce_test() { let tester = EthTester::from_spec(Spec::load(POSITIVE_NONCE_SPEC)); let address = Address::from(10); - let sample = tester.handler.handle_request(&(r#" + let sample = tester.handler.handle_request_sync(&(r#" { "jsonrpc": "2.0", "method": "eth_getTransactionCount", diff --git a/rpc/src/v1/tests/mocked/eth.rs b/rpc/src/v1/tests/mocked/eth.rs index d7d93137f..a6b5a1ef7 100644 --- a/rpc/src/v1/tests/mocked/eth.rs +++ b/rpc/src/v1/tests/mocked/eth.rs @@ -97,7 +97,7 @@ fn rpc_eth_protocol_version() { let request = r#"{"jsonrpc": "2.0", "method": "eth_protocolVersion", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":"63","id":1}"#; - assert_eq!(EthTester::default().io.handle_request(request), Some(response.to_owned())); + assert_eq!(EthTester::default().io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -107,7 +107,7 @@ fn rpc_eth_syncing() { let tester = EthTester::default(); let false_res = r#"{"jsonrpc":"2.0","result":false,"id":1}"#; - assert_eq!(tester.io.handle_request(request), Some(false_res.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(false_res.to_owned())); { let mut status = tester.sync.status.write(); @@ -123,7 +123,7 @@ fn rpc_eth_syncing() { } let true_res = r#"{"jsonrpc":"2.0","result":{"currentBlock":"0x03e8","highestBlock":"0x09c4","startingBlock":"0x00"},"id":1}"#; - assert_eq!(tester.io.handle_request(request), Some(true_res.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(true_res.to_owned())); { // finish "syncing" @@ -133,7 +133,7 @@ fn rpc_eth_syncing() { } } - assert_eq!(tester.io.handle_request(request), Some(false_res.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(false_res.to_owned())); } #[test] @@ -146,7 +146,7 @@ fn rpc_eth_hashrate() { let request = r#"{"jsonrpc": "2.0", "method": "eth_hashrate", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":"0xfffc","id":1}"#; - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -163,7 +163,7 @@ fn rpc_eth_submit_hashrate() { }"#; let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#; - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); assert_eq!(tester.hashrates.lock().get(&H256::from("0x59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c")).cloned().unwrap().1, U256::from(0x500_000)); } @@ -188,7 +188,7 @@ fn rpc_eth_sign() { }"#; let res = r#"{"jsonrpc":"2.0","result":""#.to_owned() + &format!("0x{}", signed) + r#"","id":1}"#; - assert_eq!(tester.io.handle_request(&req), Some(res)); + assert_eq!(tester.io.handle_request_sync(&req), Some(res)); } #[test] @@ -203,13 +203,13 @@ fn rpc_eth_author() { "id": 1 }"#; - assert_eq!(tester.io.handle_request(req), Some(make_res(Address::zero()))); + assert_eq!(tester.io.handle_request_sync(req), Some(make_res(Address::zero()))); for i in 0..20 { let addr = tester.accounts_provider.new_account(&format!("{}", i)).unwrap(); tester.miner.set_author(addr.clone()); - assert_eq!(tester.io.handle_request(req), Some(make_res(addr))); + assert_eq!(tester.io.handle_request_sync(req), Some(make_res(addr))); } } @@ -220,7 +220,7 @@ fn rpc_eth_mining() { let request = r#"{"jsonrpc": "2.0", "method": "eth_mining", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":false,"id":1}"#; - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -228,7 +228,7 @@ fn rpc_eth_gas_price() { let request = r#"{"jsonrpc": "2.0", "method": "eth_gasPrice", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":"0x04a817c800","id":1}"#; - assert_eq!(EthTester::default().io.handle_request(request), Some(response.to_owned())); + assert_eq!(EthTester::default().io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -239,7 +239,7 @@ fn rpc_eth_accounts() { let request = r#"{"jsonrpc": "2.0", "method": "eth_accounts", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":[""#.to_owned() + &format!("0x{:?}", address) + r#""],"id":1}"#; - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -250,7 +250,7 @@ fn rpc_eth_block_number() { let request = r#"{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":"0x0a","id":1}"#; - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -266,7 +266,7 @@ fn rpc_eth_balance() { }"#; let response = r#"{"jsonrpc":"2.0","result":"0x05","id":1}"#; - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -286,7 +286,7 @@ fn rpc_eth_balance_pending() { // miner. let response = r#"{"jsonrpc":"2.0","result":"0x00","id":1}"#; - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -302,7 +302,7 @@ fn rpc_eth_storage_at() { }"#; let response = r#"{"jsonrpc":"2.0","result":"0x0000000000000000000000000000000000000000000000000000000000000007","id":1}"#; - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -315,7 +315,7 @@ fn rpc_eth_transaction_count() { }"#; let response = r#"{"jsonrpc":"2.0","result":"0x00","id":1}"#; - assert_eq!(EthTester::default().io.handle_request(request), Some(response.to_owned())); + assert_eq!(EthTester::default().io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -328,7 +328,7 @@ fn rpc_eth_block_transaction_count_by_hash() { }"#; let response = r#"{"jsonrpc":"2.0","result":null,"id":1}"#; - assert_eq!(EthTester::default().io.handle_request(request), Some(response.to_owned())); + assert_eq!(EthTester::default().io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -341,7 +341,7 @@ fn rpc_eth_transaction_count_by_number() { }"#; let response = r#"{"jsonrpc":"2.0","result":"0x00","id":1}"#; - assert_eq!(EthTester::default().io.handle_request(request), Some(response.to_owned())); + assert_eq!(EthTester::default().io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -354,7 +354,7 @@ fn rpc_eth_transaction_count_by_number_pending() { }"#; let response = r#"{"jsonrpc":"2.0","result":"0x01","id":1}"#; - assert_eq!(EthTester::default().io.handle_request(request), Some(response.to_owned())); + assert_eq!(EthTester::default().io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -375,7 +375,7 @@ fn rpc_eth_pending_transaction_by_hash() { "params": ["0x0000000000000000000000000000000000000000000000000000000000000000"], "id": 1 }"#; - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } @@ -389,7 +389,7 @@ fn rpc_eth_uncle_count_by_block_hash() { }"#; let response = r#"{"jsonrpc":"2.0","result":null,"id":1}"#; - assert_eq!(EthTester::default().io.handle_request(request), Some(response.to_owned())); + assert_eq!(EthTester::default().io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -402,7 +402,7 @@ fn rpc_eth_uncle_count_by_block_number() { }"#; let response = r#"{"jsonrpc":"2.0","result":"0x00","id":1}"#; - assert_eq!(EthTester::default().io.handle_request(request), Some(response.to_owned())); + assert_eq!(EthTester::default().io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -418,7 +418,7 @@ fn rpc_eth_code() { }"#; let response = r#"{"jsonrpc":"2.0","result":"0xff21","id":1}"#; - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -453,7 +453,7 @@ fn rpc_eth_call_latest() { }"#; let response = r#"{"jsonrpc":"2.0","result":"0x1234ff","id":1}"#; - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -488,7 +488,7 @@ fn rpc_eth_call() { }"#; let response = r#"{"jsonrpc":"2.0","result":"0x1234ff","id":1}"#; - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -522,7 +522,7 @@ fn rpc_eth_call_default_block() { }"#; let response = r#"{"jsonrpc":"2.0","result":"0x1234ff","id":1}"#; - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -557,7 +557,7 @@ fn rpc_eth_estimate_gas() { }"#; let response = r#"{"jsonrpc":"2.0","result":"0xff35","id":1}"#; - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -591,7 +591,7 @@ fn rpc_eth_estimate_gas_default_block() { }"#; let response = r#"{"jsonrpc":"2.0","result":"0xff35","id":1}"#; - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -625,7 +625,7 @@ fn rpc_eth_send_transaction() { let response = r#"{"jsonrpc":"2.0","result":""#.to_owned() + format!("0x{:?}", t.hash()).as_ref() + r#"","id":1}"#; - assert_eq!(tester.io.handle_request(&request), Some(response)); + assert_eq!(tester.io.handle_request_sync(&request), Some(response)); tester.miner.last_nonces.write().insert(address.clone(), U256::zero()); @@ -642,7 +642,7 @@ fn rpc_eth_send_transaction() { let response = r#"{"jsonrpc":"2.0","result":""#.to_owned() + format!("0x{:?}", t.hash()).as_ref() + r#"","id":1}"#; - assert_eq!(tester.io.handle_request(&request), Some(response)); + assert_eq!(tester.io.handle_request_sync(&request), Some(response)); } #[test] fn rpc_eth_send_transaction_with_bad_to() { @@ -663,7 +663,7 @@ fn rpc_eth_send_transaction_with_bad_to() { let response = r#"{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params","data":null},"id":1}"#; - assert_eq!(tester.io.handle_request(&request), Some(response.into())); + assert_eq!(tester.io.handle_request_sync(&request), Some(response.into())); } @@ -685,7 +685,7 @@ fn rpc_eth_send_transaction_error() { }"#; let response = r#"{"jsonrpc":"2.0","error":{"code":-32020,"message":"Your account is locked. Unlock the account via CLI, personal_unlockAccount or use Trusted Signer.","data":"NotUnlocked"},"id":1}"#; - assert_eq!(tester.io.handle_request(&request), Some(response.into())); + assert_eq!(tester.io.handle_request_sync(&request), Some(response.into())); } #[test] @@ -718,7 +718,7 @@ fn rpc_eth_send_raw_transaction() { let res = r#"{"jsonrpc":"2.0","result":""#.to_owned() + &format!("0x{:?}", t.hash()) + r#"","id":1}"#; - assert_eq!(tester.io.handle_request(&req), Some(res)); + assert_eq!(tester.io.handle_request_sync(&req), Some(res)); } #[test] @@ -760,7 +760,7 @@ fn rpc_eth_transaction_receipt() { }"#; let response = r#"{"jsonrpc":"2.0","result":{"blockHash":"0xed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5","blockNumber":"0x04510c","contractAddress":null,"cumulativeGasUsed":"0x20","gasUsed":"0x10","logs":[{"address":"0x33990122638b9132ca29c723bdf037f1a891a70c","blockHash":"0xed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5","blockNumber":"0x04510c","data":"0x","logIndex":"0x01","topics":["0xa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc","0x4861736852656700000000000000000000000000000000000000000000000000"],"transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":"0x00","type":"mined"}],"transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":"0x00"},"id":1}"#; - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -775,7 +775,7 @@ fn rpc_eth_transaction_receipt_null() { }"#; let response = r#"{"jsonrpc":"2.0","result":null,"id":1}"#; - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } // These tests are incorrect: their output is undefined as long as eth_getCompilers is []. @@ -788,7 +788,7 @@ fn rpc_eth_compilers() { let request = r#"{"jsonrpc": "2.0", "method": "eth_getCompilers", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":[],"id":1}"#; - assert_eq!(EthTester::default().io.handle_request(request), Some(response.to_owned())); + assert_eq!(EthTester::default().io.handle_request_sync(request), Some(response.to_owned())); } #[ignore] @@ -797,7 +797,7 @@ fn rpc_eth_compile_lll() { let request = r#"{"jsonrpc": "2.0", "method": "eth_compileLLL", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","error":{"code":-32603,"message":"Internal error","data":null},"id":1}"#; - assert_eq!(EthTester::default().io.handle_request(request), Some(response.to_owned())); + assert_eq!(EthTester::default().io.handle_request_sync(request), Some(response.to_owned())); } #[ignore] @@ -806,7 +806,7 @@ fn rpc_eth_compile_solidity() { let request = r#"{"jsonrpc": "2.0", "method": "eth_compileSolidity", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","error":{"code":-32603,"message":"Internal error","data":null},"id":1}"#; - assert_eq!(EthTester::default().io.handle_request(request), Some(response.to_owned())); + assert_eq!(EthTester::default().io.handle_request_sync(request), Some(response.to_owned())); } #[ignore] @@ -815,7 +815,7 @@ fn rpc_eth_compile_serpent() { let request = r#"{"jsonrpc": "2.0", "method": "eth_compileSerpent", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","error":{"code":-32603,"message":"Internal error","data":null},"id":1}"#; - assert_eq!(EthTester::default().io.handle_request(request), Some(response.to_owned())); + assert_eq!(EthTester::default().io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -826,7 +826,7 @@ fn rpc_get_work_returns_no_work_if_cant_mine() { let request = r#"{"jsonrpc": "2.0", "method": "eth_getWork", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","error":{"code":-32001,"message":"Still syncing.","data":null},"id":1}"#; - assert_eq!(eth_tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(eth_tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -837,7 +837,7 @@ fn rpc_get_work_returns_correct_work_package() { let request = r#"{"jsonrpc": "2.0", "method": "eth_getWork", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":["0x3bbe93f74e7b97ae00784aeff8819c5cb600dd87e8b282a5d3446f3f871f0347","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000800000000000000000000000000000000000000000000000000000000000","0x01"],"id":1}"#; - assert_eq!(eth_tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(eth_tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -851,7 +851,7 @@ fn rpc_get_work_should_not_return_block_number() { let request = r#"{"jsonrpc": "2.0", "method": "eth_getWork", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":["0x3bbe93f74e7b97ae00784aeff8819c5cb600dd87e8b282a5d3446f3f871f0347","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000800000000000000000000000000000000000000000000000000000000000"],"id":1}"#; - assert_eq!(eth_tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(eth_tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -867,7 +867,7 @@ fn rpc_get_work_should_timeout() { r#"{{"jsonrpc":"2.0","result":["0x{:?}","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000800000000000000000000000000000000000000000000000000000000000","0x01"],"id":1}}"#, hash, ); - assert_eq!(eth_tester.io.handle_request(request), Some(work_response.to_owned())); + assert_eq!(eth_tester.io.handle_request_sync(request), Some(work_response.to_owned())); // Request with timeout of 0 seconds. This should work since we're disabling timeout. let request = r#"{"jsonrpc": "2.0", "method": "eth_getWork", "params": ["0"], "id": 1}"#; @@ -875,14 +875,14 @@ fn rpc_get_work_should_timeout() { r#"{{"jsonrpc":"2.0","result":["0x{:?}","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000800000000000000000000000000000000000000000000000000000000000","0x01"],"id":1}}"#, hash, ); - assert_eq!(eth_tester.io.handle_request(request), Some(work_response.to_owned())); + assert_eq!(eth_tester.io.handle_request_sync(request), Some(work_response.to_owned())); // Request with timeout of 10K seconds. This should work. let request = r#"{"jsonrpc": "2.0", "method": "eth_getWork", "params": ["10000"], "id": 1}"#; - assert_eq!(eth_tester.io.handle_request(request), Some(work_response.to_owned())); + assert_eq!(eth_tester.io.handle_request_sync(request), Some(work_response.to_owned())); // Request with timeout of 10 seconds. This should fail. let request = r#"{"jsonrpc": "2.0", "method": "eth_getWork", "params": ["10"], "id": 1}"#; let err_response = r#"{"jsonrpc":"2.0","error":{"code":-32003,"message":"Work has not changed.","data":null},"id":1}"#; - assert_eq!(eth_tester.io.handle_request(request), Some(err_response.to_owned())); + assert_eq!(eth_tester.io.handle_request_sync(request), Some(err_response.to_owned())); } diff --git a/rpc/src/v1/tests/mocked/eth_signing.rs b/rpc/src/v1/tests/mocked/eth_signing.rs index 96cb1ec92..e9316da61 100644 --- a/rpc/src/v1/tests/mocked/eth_signing.rs +++ b/rpc/src/v1/tests/mocked/eth_signing.rs @@ -16,13 +16,13 @@ use std::str::FromStr; use std::sync::Arc; -use std::time::Duration; use jsonrpc_core::{IoHandler, to_value}; use v1::impls::EthSigningQueueClient; use v1::traits::EthSigning; use v1::helpers::{ConfirmationsQueue, SigningQueue}; +use v1::types::{H256 as RpcH256, H520 as RpcH520}; use v1::tests::helpers::TestMinerService; -use util::{Address, FixedHash, Uint, U256, H256}; +use util::{Address, FixedHash, Uint, U256, H256, H520}; use ethcore::account_provider::AccountProvider; use ethcore::client::TestBlockChainClient; use ethcore::transaction::{Transaction, Action}; @@ -37,7 +37,7 @@ struct EthSigningTester { impl Default for EthSigningTester { fn default() -> Self { - let queue = Arc::new(ConfirmationsQueue::with_timeout(Duration::from_millis(1))); + let queue = Arc::new(ConfirmationsQueue::default()); let client = Arc::new(TestBlockChainClient::default()); let miner = Arc::new(TestMinerService::default()); let accounts = Arc::new(AccountProvider::transient_provider()); @@ -78,8 +78,13 @@ fn should_add_sign_to_queue() { let response = r#"{"jsonrpc":"2.0","result":"0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","id":1}"#; // then - assert_eq!(tester.io.handle_request(&request), Some(response.to_owned())); + let async_result = tester.io.handle_request(&request).unwrap(); assert_eq!(tester.queue.requests().len(), 1); + // respond + tester.queue.request_confirmed(U256::from(1), Ok(to_value(&RpcH520::from(H520::default())))); + assert!(async_result.on_result(move |res| { + assert_eq!(res, response.to_owned()); + })); } #[test] @@ -102,7 +107,7 @@ fn should_post_sign_to_queue() { let response = r#"{"jsonrpc":"2.0","result":"0x01","id":1}"#; // then - assert_eq!(tester.io.handle_request(&request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(&request), Some(response.to_owned())); assert_eq!(tester.queue.requests().len(), 1); } @@ -120,7 +125,7 @@ fn should_check_status_of_request() { ], "id": 1 }"#; - tester.io.handle_request(&request).expect("Sent"); + tester.io.handle_request_sync(&request).expect("Sent"); // when let request = r#"{ @@ -132,7 +137,7 @@ fn should_check_status_of_request() { let response = r#"{"jsonrpc":"2.0","result":null,"id":1}"#; // then - assert_eq!(tester.io.handle_request(&request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(&request), Some(response.to_owned())); } #[test] @@ -149,8 +154,8 @@ fn should_check_status_of_request_when_its_resolved() { ], "id": 1 }"#; - tester.io.handle_request(&request).expect("Sent"); - tester.queue.request_confirmed(U256::from(1), to_value(&"Hello World!")); + tester.io.handle_request_sync(&request).expect("Sent"); + tester.queue.request_confirmed(U256::from(1), Ok(to_value(&"Hello World!"))); // when let request = r#"{ @@ -162,7 +167,7 @@ fn should_check_status_of_request_when_its_resolved() { let response = r#"{"jsonrpc":"2.0","result":"Hello World!","id":1}"#; // then - assert_eq!(tester.io.handle_request(&request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(&request), Some(response.to_owned())); } #[test] @@ -186,7 +191,7 @@ fn should_sign_if_account_is_unlocked() { "id": 1 }"#; let response = r#"{"jsonrpc":"2.0","result":""#.to_owned() + format!("0x{}", signature).as_ref() + r#"","id":1}"#; - assert_eq!(tester.io.handle_request(&request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(&request), Some(response.to_owned())); assert_eq!(tester.queue.requests().len(), 0); } @@ -213,8 +218,13 @@ fn should_add_transaction_to_queue() { let response = r#"{"jsonrpc":"2.0","result":"0x0000000000000000000000000000000000000000000000000000000000000000","id":1}"#; // then - assert_eq!(tester.io.handle_request(&request), Some(response.to_owned())); + let async_result = tester.io.handle_request(&request).unwrap(); assert_eq!(tester.queue.requests().len(), 1); + // respond + tester.queue.request_confirmed(U256::from(1), Ok(to_value(&RpcH256::from(H256::default())))); + assert!(async_result.on_result(move |res| { + assert_eq!(res, response.to_owned()); + })); } #[test] @@ -251,5 +261,5 @@ fn should_dispatch_transaction_if_account_is_unlock() { let response = r#"{"jsonrpc":"2.0","result":""#.to_owned() + format!("0x{:?}", t.hash()).as_ref() + r#"","id":1}"#; // then - assert_eq!(tester.io.handle_request(&request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(&request), Some(response.to_owned())); } diff --git a/rpc/src/v1/tests/mocked/ethcore.rs b/rpc/src/v1/tests/mocked/ethcore.rs index cf7bb8eb1..056bdf25d 100644 --- a/rpc/src/v1/tests/mocked/ethcore.rs +++ b/rpc/src/v1/tests/mocked/ethcore.rs @@ -80,7 +80,7 @@ fn rpc_ethcore_extra_data() { let request = r#"{"jsonrpc": "2.0", "method": "ethcore_extraData", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":"0x01020304","id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -98,7 +98,7 @@ fn rpc_ethcore_default_extra_data() { let request = r#"{"jsonrpc": "2.0", "method": "ethcore_defaultExtraData", "params": [], "id": 1}"#; let response = format!(r#"{{"jsonrpc":"2.0","result":"0x{}","id":1}}"#, misc::version_data().to_hex()); - assert_eq!(io.handle_request(request), Some(response)); + assert_eq!(io.handle_request_sync(request), Some(response)); } #[test] @@ -113,7 +113,7 @@ fn rpc_ethcore_gas_floor_target() { let request = r#"{"jsonrpc": "2.0", "method": "ethcore_gasFloorTarget", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":"0x3039","id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -128,7 +128,7 @@ fn rpc_ethcore_min_gas_price() { let request = r#"{"jsonrpc": "2.0", "method": "ethcore_minGasPrice", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":"0x01312d00","id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -147,7 +147,7 @@ fn rpc_ethcore_dev_logs() { let request = r#"{"jsonrpc": "2.0", "method": "ethcore_devLogs", "params":[], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":["b","a"],"id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -162,7 +162,7 @@ fn rpc_ethcore_dev_logs_levels() { let request = r#"{"jsonrpc": "2.0", "method": "ethcore_devLogsLevels", "params":[], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":"rpc=trace","id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -177,7 +177,7 @@ fn rpc_ethcore_transactions_limit() { let request = r#"{"jsonrpc": "2.0", "method": "ethcore_transactionsLimit", "params":[], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":1024,"id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -192,7 +192,7 @@ fn rpc_ethcore_net_chain() { let request = r#"{"jsonrpc": "2.0", "method": "ethcore_netChain", "params":[], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":"testchain","id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -207,7 +207,7 @@ fn rpc_ethcore_net_peers() { let request = r#"{"jsonrpc": "2.0", "method": "ethcore_netPeers", "params":[], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":{"active":0,"connected":120,"max":50},"id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -222,7 +222,7 @@ fn rpc_ethcore_net_port() { let request = r#"{"jsonrpc": "2.0", "method": "ethcore_netPort", "params":[], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":30303,"id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -237,7 +237,7 @@ fn rpc_ethcore_rpc_settings() { let request = r#"{"jsonrpc": "2.0", "method": "ethcore_rpcSettings", "params":[], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":{"enabled":true,"interface":"all","port":8545},"id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -252,7 +252,7 @@ fn rpc_ethcore_node_name() { let request = r#"{"jsonrpc": "2.0", "method": "ethcore_nodeName", "params":[], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":"mynode","id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -269,7 +269,7 @@ fn rpc_ethcore_unsigned_transactions_count() { let request = r#"{"jsonrpc": "2.0", "method": "ethcore_unsignedTransactionsCount", "params":[], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":0,"id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -284,5 +284,5 @@ fn rpc_ethcore_unsigned_transactions_count_when_signer_disabled() { let request = r#"{"jsonrpc": "2.0", "method": "ethcore_unsignedTransactionsCount", "params":[], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","error":{"code":-32030,"message":"Trusted Signer is disabled. This API is not available.","data":null},"id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } diff --git a/rpc/src/v1/tests/mocked/ethcore_set.rs b/rpc/src/v1/tests/mocked/ethcore_set.rs index 2582b85b7..eaa4cb0cb 100644 --- a/rpc/src/v1/tests/mocked/ethcore_set.rs +++ b/rpc/src/v1/tests/mocked/ethcore_set.rs @@ -53,7 +53,7 @@ fn rpc_ethcore_set_min_gas_price() { let request = r#"{"jsonrpc": "2.0", "method": "ethcore_setMinGasPrice", "params":["0xcd1722f3947def4cf144679da39c4c32bdc35681"], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); assert_eq!(miner.minimal_gas_price(), U256::from_str("cd1722f3947def4cf144679da39c4c32bdc35681").unwrap()); } @@ -68,7 +68,7 @@ fn rpc_ethcore_set_gas_floor_target() { let request = r#"{"jsonrpc": "2.0", "method": "ethcore_setGasFloorTarget", "params":["0xcd1722f3947def4cf144679da39c4c32bdc35681"], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); assert_eq!(miner.gas_floor_target(), U256::from_str("cd1722f3947def4cf144679da39c4c32bdc35681").unwrap()); } @@ -83,7 +83,7 @@ fn rpc_ethcore_set_extra_data() { let request = r#"{"jsonrpc": "2.0", "method": "ethcore_setExtraData", "params":["0xcd1722f3947def4cf144679da39c4c32bdc35681"], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); assert_eq!(miner.extra_data(), "cd1722f3947def4cf144679da39c4c32bdc35681".from_hex().unwrap()); } @@ -98,7 +98,7 @@ fn rpc_ethcore_set_author() { let request = r#"{"jsonrpc": "2.0", "method": "ethcore_setAuthor", "params":["0xcd1722f3947def4cf144679da39c4c32bdc35681"], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); assert_eq!(miner.author(), Address::from_str("cd1722f3947def4cf144679da39c4c32bdc35681").unwrap()); } @@ -113,6 +113,6 @@ fn rpc_ethcore_set_transactions_limit() { let request = r#"{"jsonrpc": "2.0", "method": "ethcore_setTransactionsLimit", "params":[10240240], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); assert_eq!(miner.transactions_limit(), 10_240_240); } diff --git a/rpc/src/v1/tests/mocked/net.rs b/rpc/src/v1/tests/mocked/net.rs index 836246686..3bc341dcb 100644 --- a/rpc/src/v1/tests/mocked/net.rs +++ b/rpc/src/v1/tests/mocked/net.rs @@ -36,7 +36,7 @@ fn rpc_net_version() { let request = r#"{"jsonrpc": "2.0", "method": "net_version", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":"3","id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -49,7 +49,7 @@ fn rpc_net_peer_count() { let request = r#"{"jsonrpc": "2.0", "method": "net_peerCount", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":"0x78","id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -62,5 +62,5 @@ fn rpc_net_listening() { let request = r#"{"jsonrpc": "2.0", "method": "net_listening", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } diff --git a/rpc/src/v1/tests/mocked/personal.rs b/rpc/src/v1/tests/mocked/personal.rs index 3c6a28d74..aa4bf29c1 100644 --- a/rpc/src/v1/tests/mocked/personal.rs +++ b/rpc/src/v1/tests/mocked/personal.rs @@ -76,7 +76,7 @@ fn should_return_false_if_signer_is_disabled() { // then - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -90,7 +90,7 @@ fn should_return_port_number_if_signer_is_enabled() { // then - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -100,7 +100,7 @@ fn accounts() { let request = r#"{"jsonrpc": "2.0", "method": "personal_listAccounts", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":[""#.to_owned() + &format!("0x{:?}", address) + r#""],"id":1}"#; - assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -108,7 +108,7 @@ fn new_account() { let tester = setup(None); let request = r#"{"jsonrpc": "2.0", "method": "personal_newAccount", "params": ["pass"], "id": 1}"#; - let res = tester.io.handle_request(request); + let res = tester.io.handle_request_sync(request); let accounts = tester.accounts.accounts().unwrap(); assert_eq!(accounts.len(), 1); @@ -131,7 +131,7 @@ fn should_be_able_to_get_account_info() { tester.accounts.set_account_meta(address.clone(), "{foo: 69}".to_owned()).unwrap(); let request = r#"{"jsonrpc": "2.0", "method": "personal_accountsInfo", "params": [], "id": 1}"#; - let res = tester.io.handle_request(request); + let res = tester.io.handle_request_sync(request); let response = format!("{{\"jsonrpc\":\"2.0\",\"result\":{{\"0x{}\":{{\"meta\":\"{{foo: 69}}\",\"name\":\"Test\",\"uuid\":\"{}\"}}}},\"id\":1}}", address.hex(), uuid); assert_eq!(res, Some(response)); } @@ -146,13 +146,13 @@ fn should_be_able_to_set_name() { let request = format!(r#"{{"jsonrpc": "2.0", "method": "personal_setAccountName", "params": ["0x{}", "Test"], "id": 1}}"#, address.hex()); let response = r#"{"jsonrpc":"2.0","result":null,"id":1}"#; - let res = tester.io.handle_request(&request); + let res = tester.io.handle_request_sync(&request); assert_eq!(res, Some(response.into())); let uuid = tester.accounts.accounts_info().unwrap().get(&address).unwrap().uuid.as_ref().unwrap().clone(); let request = r#"{"jsonrpc": "2.0", "method": "personal_accountsInfo", "params": [], "id": 1}"#; - let res = tester.io.handle_request(request); + let res = tester.io.handle_request_sync(request); let response = format!("{{\"jsonrpc\":\"2.0\",\"result\":{{\"0x{}\":{{\"meta\":\"{{}}\",\"name\":\"Test\",\"uuid\":\"{}\"}}}},\"id\":1}}", address.hex(), uuid); assert_eq!(res, Some(response)); } @@ -167,13 +167,13 @@ fn should_be_able_to_set_meta() { let request = format!(r#"{{"jsonrpc": "2.0", "method": "personal_setAccountMeta", "params": ["0x{}", "{{foo: 69}}"], "id": 1}}"#, address.hex()); let response = r#"{"jsonrpc":"2.0","result":null,"id":1}"#; - let res = tester.io.handle_request(&request); + let res = tester.io.handle_request_sync(&request); assert_eq!(res, Some(response.into())); let uuid = tester.accounts.accounts_info().unwrap().get(&address).unwrap().uuid.as_ref().unwrap().clone(); let request = r#"{"jsonrpc": "2.0", "method": "personal_accountsInfo", "params": [], "id": 1}"#; - let res = tester.io.handle_request(request); + let res = tester.io.handle_request_sync(request); let response = format!("{{\"jsonrpc\":\"2.0\",\"result\":{{\"0x{}\":{{\"meta\":\"{{foo: 69}}\",\"name\":\"{}\",\"uuid\":\"{}\"}}}},\"id\":1}}", address.hex(), uuid, uuid); assert_eq!(res, Some(response)); } @@ -197,7 +197,7 @@ fn sign_and_send_transaction_with_invalid_password() { let response = r#"{"jsonrpc":"2.0","error":{"code":-32021,"message":"Account password is invalid or account does not exist.","data":"SStore(InvalidPassword)"},"id":1}"#; - assert_eq!(tester.io.handle_request(request.as_ref()), Some(response.into())); + assert_eq!(tester.io.handle_request_sync(request.as_ref()), Some(response.into())); } #[test] @@ -232,7 +232,7 @@ fn sign_and_send_transaction() { let response = r#"{"jsonrpc":"2.0","result":""#.to_owned() + format!("0x{:?}", t.hash()).as_ref() + r#"","id":1}"#; - assert_eq!(tester.io.handle_request(request.as_ref()), Some(response)); + assert_eq!(tester.io.handle_request_sync(request.as_ref()), Some(response)); tester.miner.last_nonces.write().insert(address.clone(), U256::zero()); @@ -250,5 +250,5 @@ fn sign_and_send_transaction() { let response = r#"{"jsonrpc":"2.0","result":""#.to_owned() + format!("0x{:?}", t.hash()).as_ref() + r#"","id":1}"#; - assert_eq!(tester.io.handle_request(request.as_ref()), Some(response)); + assert_eq!(tester.io.handle_request_sync(request.as_ref()), Some(response)); } diff --git a/rpc/src/v1/tests/mocked/personal_signer.rs b/rpc/src/v1/tests/mocked/personal_signer.rs index 9410ab84e..eacbf2404 100644 --- a/rpc/src/v1/tests/mocked/personal_signer.rs +++ b/rpc/src/v1/tests/mocked/personal_signer.rs @@ -79,8 +79,8 @@ fn should_return_list_of_items_to_confirm() { value: U256::from(1), data: vec![], nonce: None, - })); - tester.queue.add_request(ConfirmationPayload::Sign(1.into(), 5.into())); + })).unwrap(); + tester.queue.add_request(ConfirmationPayload::Sign(1.into(), 5.into())).unwrap(); // when let request = r#"{"jsonrpc":"2.0","method":"personal_requestsToConfirm","params":[],"id":1}"#; @@ -92,7 +92,7 @@ fn should_return_list_of_items_to_confirm() { ); // then - assert_eq!(tester.io.handle_request(&request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(&request), Some(response.to_owned())); } @@ -108,7 +108,7 @@ fn should_reject_transaction_from_queue_without_dispatching() { value: U256::from(1), data: vec![], nonce: None, - })); + })).unwrap(); assert_eq!(tester.queue.requests().len(), 1); // when @@ -116,7 +116,7 @@ fn should_reject_transaction_from_queue_without_dispatching() { let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#; // then - assert_eq!(tester.io.handle_request(&request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(&request), Some(response.to_owned())); assert_eq!(tester.queue.requests().len(), 0); assert_eq!(tester.miner.imported_transactions.lock().len(), 0); } @@ -133,7 +133,7 @@ fn should_not_remove_transaction_if_password_is_invalid() { value: U256::from(1), data: vec![], nonce: None, - })); + })).unwrap(); assert_eq!(tester.queue.requests().len(), 1); // when @@ -141,7 +141,7 @@ fn should_not_remove_transaction_if_password_is_invalid() { let response = r#"{"jsonrpc":"2.0","error":{"code":-32021,"message":"Account password is invalid or account does not exist.","data":"SStore(InvalidAccount)"},"id":1}"#; // then - assert_eq!(tester.io.handle_request(&request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(&request), Some(response.to_owned())); assert_eq!(tester.queue.requests().len(), 1); } @@ -149,7 +149,7 @@ fn should_not_remove_transaction_if_password_is_invalid() { fn should_not_remove_sign_if_password_is_invalid() { // given let tester = signer_tester(); - tester.queue.add_request(ConfirmationPayload::Sign(0.into(), 5.into())); + tester.queue.add_request(ConfirmationPayload::Sign(0.into(), 5.into())).unwrap(); assert_eq!(tester.queue.requests().len(), 1); // when @@ -157,7 +157,7 @@ fn should_not_remove_sign_if_password_is_invalid() { let response = r#"{"jsonrpc":"2.0","error":{"code":-32021,"message":"Account password is invalid or account does not exist.","data":"SStore(InvalidAccount)"},"id":1}"#; // then - assert_eq!(tester.io.handle_request(&request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(&request), Some(response.to_owned())); assert_eq!(tester.queue.requests().len(), 1); } @@ -175,7 +175,7 @@ fn should_confirm_transaction_and_dispatch() { value: U256::from(1), data: vec![], nonce: None, - })); + })).unwrap(); let t = Transaction { nonce: U256::zero(), @@ -201,7 +201,7 @@ fn should_confirm_transaction_and_dispatch() { let response = r#"{"jsonrpc":"2.0","result":""#.to_owned() + format!("0x{:?}", t.hash()).as_ref() + r#"","id":1}"#; // then - assert_eq!(tester.io.handle_request(&request), Some(response.to_owned())); + assert_eq!(tester.io.handle_request_sync(&request), Some(response.to_owned())); assert_eq!(tester.queue.requests().len(), 0); assert_eq!(tester.miner.imported_transactions.lock().len(), 1); } diff --git a/rpc/src/v1/tests/mocked/rpc.rs b/rpc/src/v1/tests/mocked/rpc.rs index 4415f39e5..b2c340d94 100644 --- a/rpc/src/v1/tests/mocked/rpc.rs +++ b/rpc/src/v1/tests/mocked/rpc.rs @@ -36,7 +36,7 @@ fn modules() { let request = r#"{"jsonrpc": "2.0", "method": "modules", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":{"rpc":"1.0","web3":"1.0"},"id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -48,5 +48,5 @@ fn rpc_modules() { let request = r#"{"jsonrpc": "2.0", "method": "rpc_modules", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":{"ethcore":"1.0","rpc":"1.0","web3":"1.0"},"id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } diff --git a/rpc/src/v1/tests/mocked/web3.rs b/rpc/src/v1/tests/mocked/web3.rs index bb77b24a2..b9f80b0a8 100644 --- a/rpc/src/v1/tests/mocked/web3.rs +++ b/rpc/src/v1/tests/mocked/web3.rs @@ -29,7 +29,7 @@ fn rpc_web3_version() { let request = r#"{"jsonrpc": "2.0", "method": "web3_clientVersion", "params": [], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":"VER","id":1}"#.to_owned().replace("VER", v.as_ref()); - assert_eq!(io.handle_request(request), Some(response)); + assert_eq!(io.handle_request_sync(request), Some(response)); } #[test] @@ -41,7 +41,7 @@ fn rpc_web3_sha3() { let request = r#"{"jsonrpc": "2.0", "method": "web3_sha3", "params": ["0x00"], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":"0xbc36789e7a1e281436464229828f817d6612f7b477d66591ff96a9e064bcc98a","id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } #[test] @@ -53,5 +53,5 @@ fn rpc_web3_sha3_wiki() { let request = r#"{"jsonrpc": "2.0", "method": "web3_sha3", "params": ["0x68656c6c6f20776f726c64"], "id": 1}"#; let response = r#"{"jsonrpc":"2.0","result":"0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad","id":1}"#; - assert_eq!(io.handle_request(request), Some(response.to_owned())); + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } diff --git a/rpc/src/v1/traits/eth.rs b/rpc/src/v1/traits/eth.rs index 60b482916..610591f1f 100644 --- a/rpc/src/v1/traits/eth.rs +++ b/rpc/src/v1/traits/eth.rs @@ -204,7 +204,7 @@ pub trait EthFilter: Sized + Send + Sync + 'static { /// Signing methods implementation relying on unlocked accounts. pub trait EthSigning: Sized + Send + Sync + 'static { /// Signs the data with given address signature. - fn sign(&self, _: Params) -> Result; + fn sign(&self, _: Params, _: Ready); /// Posts sign request asynchronously. /// Will return a confirmation ID for later use with check_transaction. @@ -214,7 +214,7 @@ pub trait EthSigning: Sized + Send + Sync + 'static { /// transaction hash. /// If it cannot yet be signed, it will return a transaction ID for /// later use with check_transaction. - fn send_transaction(&self, _: Params) -> Result; + fn send_transaction(&self, _: Params, _: Ready); /// Posts transaction asynchronously. /// Will return a transaction ID for later use with check_transaction. @@ -230,8 +230,8 @@ pub trait EthSigning: Sized + Send + Sync + 'static { /// Should be used to convert object to io delegate. fn to_delegate(self) -> IoDelegate { let mut delegate = IoDelegate::new(Arc::new(self)); - delegate.add_method("eth_sign", EthSigning::sign); - delegate.add_method("eth_sendTransaction", EthSigning::send_transaction); + delegate.add_async_method("eth_sign", EthSigning::sign); + delegate.add_async_method("eth_sendTransaction", EthSigning::send_transaction); delegate.add_method("eth_postSign", EthSigning::post_sign); delegate.add_method("eth_postTransaction", EthSigning::post_transaction); delegate.add_method("eth_checkRequest", EthSigning::check_request); diff --git a/rpc/src/v1/types/trace.rs b/rpc/src/v1/types/trace.rs index f4380b0a3..cee96e0c7 100644 --- a/rpc/src/v1/types/trace.rs +++ b/rpc/src/v1/types/trace.rs @@ -549,7 +549,7 @@ mod tests { block_hash: H256::from(14), }; let serialized = serde_json::to_string(&t).unwrap(); - assert_eq!(serialized, r#"{"action":{"call":{"from":"0x0000000000000000000000000000000000000004","to":"0x0000000000000000000000000000000000000005","value":"0x06","gas":"0x07","input":"0x1234","callType":{"call":[]}}},"result":{"call":{"gasUsed":"0x08","output":"0x5678"}},"traceAddress":["0x0a"],"subtraces":"0x01","transactionPosition":"0x0b","transactionHash":"0x000000000000000000000000000000000000000000000000000000000000000c","blockNumber":"0x0d","blockHash":"0x000000000000000000000000000000000000000000000000000000000000000e"}"#); + assert_eq!(serialized, r#"{"action":{"call":{"from":"0x0000000000000000000000000000000000000004","to":"0x0000000000000000000000000000000000000005","value":"0x06","gas":"0x07","input":"0x1234","callType":"call"}},"result":{"call":{"gasUsed":"0x08","output":"0x5678"}},"traceAddress":["0x0a"],"subtraces":"0x01","transactionPosition":"0x0b","transactionHash":"0x000000000000000000000000000000000000000000000000000000000000000c","blockNumber":"0x0d","blockHash":"0x000000000000000000000000000000000000000000000000000000000000000e"}"#); } #[test] @@ -614,7 +614,7 @@ mod tests { } ]); let serialized = serde_json::to_string(&t).unwrap(); - assert_eq!(serialized, r#"{"0x000000000000000000000000000000000000002a":{"balance":{"=":[]},"nonce":{"+":"0x01"},"code":{"=":[]},"storage":{"0x000000000000000000000000000000000000000000000000000000000000002a":{"=":[]}}},"0x0000000000000000000000000000000000000045":{"balance":{"=":[]},"nonce":{"*":{"from":"0x01","to":"0x00"}},"code":{"-":"0x60"},"storage":{}}}"#); + assert_eq!(serialized, r#"{"0x000000000000000000000000000000000000002a":{"balance":"=","nonce":{"+":"0x01"},"code":"=","storage":{"0x000000000000000000000000000000000000000000000000000000000000002a":"="}},"0x0000000000000000000000000000000000000045":{"balance":"=","nonce":{"*":{"from":"0x01","to":"0x00"}},"code":{"-":"0x60"},"storage":{}}}"#); } #[test] @@ -634,7 +634,7 @@ mod tests { })]; let serialized = serde_json::to_string(&actions).unwrap(); - assert_eq!(serialized, r#"[{"call":{"from":"0x0000000000000000000000000000000000000001","to":"0x0000000000000000000000000000000000000002","value":"0x03","gas":"0x04","input":"0x1234","callType":{"call":[]}}},{"create":{"from":"0x0000000000000000000000000000000000000005","value":"0x06","gas":"0x07","init":"0x5678"}}]"#); + assert_eq!(serialized, r#"[{"call":{"from":"0x0000000000000000000000000000000000000001","to":"0x0000000000000000000000000000000000000002","value":"0x03","gas":"0x04","input":"0x1234","callType":"call"}},{"create":{"from":"0x0000000000000000000000000000000000000005","value":"0x06","gas":"0x07","init":"0x5678"}}]"#); } #[test] @@ -654,6 +654,6 @@ mod tests { ]; let serialized = serde_json::to_string(&results).unwrap(); - assert_eq!(serialized, r#"[{"call":{"gasUsed":"0x01","output":"0x1234"}},{"create":{"gasUsed":"0x02","code":"0x4556","address":"0x0000000000000000000000000000000000000003"}},{"failedCall":[]},{"failedCreate":[]}]"#); + assert_eq!(serialized, r#"[{"call":{"gasUsed":"0x01","output":"0x1234"}},{"create":{"gasUsed":"0x02","code":"0x4556","address":"0x0000000000000000000000000000000000000003"}},"failedCall","failedCreate"]"#); } } diff --git a/signer/Cargo.toml b/signer/Cargo.toml index 5bb6325f1..a8ad0582c 100644 --- a/signer/Cargo.toml +++ b/signer/Cargo.toml @@ -12,7 +12,7 @@ rustc_version = "0.1" [dependencies] rand = "0.3.14" -jsonrpc-core = "2.1" +jsonrpc-core = "3.0" log = "0.3" env_logger = "0.3" ws = { git = "https://github.com/ethcore/ws-rs.git", branch = "mio-upstream-stable" } diff --git a/signer/src/ws_server/session.rs b/signer/src/ws_server/session.rs index e7abea833..d2d336d87 100644 --- a/signer/src/ws_server/session.rs +++ b/signer/src/ws_server/session.rs @@ -22,7 +22,7 @@ use std::path::{PathBuf, Path}; use std::sync::Arc; use std::str::FromStr; use jsonrpc_core::IoHandler; -use util::H256; +use util::{H256, Mutex}; #[cfg(feature = "ui")] mod signer { @@ -95,7 +95,7 @@ fn add_headers(mut response: ws::Response, mime: &str) -> ws::Response { } pub struct Session { - out: ws::Sender, + out: Arc>, skip_origin_validation: bool, self_origin: String, authcodes_path: PathBuf, @@ -145,12 +145,16 @@ impl ws::Handler for Session { fn on_message(&mut self, msg: ws::Message) -> ws::Result<()> { let req = try!(msg.as_text()); - match self.handler.handle_request(req) { - Some(res) => { - self.out.send(res) - }, - None => Ok(()), + if let Some(async) = self.handler.handle_request(req) { + let out = self.out.clone(); + async.on_result(move |result| { + let res = out.lock().send(result); + if let Err(e) = res { + warn!(target: "signer", "Error while sending response: {:?}", e); + } + }); } + Ok(()) } } @@ -177,7 +181,7 @@ impl ws::Factory for Factory { fn connection_made(&mut self, sender: ws::Sender) -> Self::Handler { Session { - out: sender, + out: Arc::new(Mutex::new(sender)), handler: self.handler.clone(), skip_origin_validation: self.skip_origin_validation, self_origin: self.self_origin.clone(), diff --git a/stratum/Cargo.toml b/stratum/Cargo.toml index 958e807be..d300106aa 100644 --- a/stratum/Cargo.toml +++ b/stratum/Cargo.toml @@ -12,7 +12,7 @@ ethcore-ipc-codegen = { path = "../ipc/codegen" } [dependencies] log = "0.3" json-tcp-server = { git = "https://github.com/ethcore/json-tcp-server" } -jsonrpc-core = "2.1" +jsonrpc-core = "3.0" mio = { git = "https://github.com/ethcore/mio", branch = "v0.5.x" } ethcore-util = { path = "../util" } ethcore-devtools = { path = "../devtools" } diff --git a/stratum/src/lib.rs b/stratum/src/lib.rs index c54eeea62..ecec535c2 100644 --- a/stratum/src/lib.rs +++ b/stratum/src/lib.rs @@ -108,15 +108,15 @@ impl Stratum { Ok(val) => val, Err(e) => { warn!(target: "stratum", "Invalid payload: '{}' ({:?})", &initial, e); - try!(to_value(&[0u8; 0])) + to_value(&[0u8; 0]) }, }, - None => try!(to_value(&[0u8; 0])), + None => to_value(&[0u8; 0]), }) } fn authorize(&self, params: Params) -> std::result::Result { - from_params::<(String, String)>(params).and_then(|(worker_id, secret)|{ + from_params::<(String, String)>(params).map(|(worker_id, secret)|{ if let Some(valid_secret) = self.secret { let hash = secret.sha3(); if hash != valid_secret { diff --git a/test.sh b/test.sh index 666f10d06..a873d870b 100755 --- a/test.sh +++ b/test.sh @@ -2,17 +2,22 @@ # Running Parity Full Test Sute FEATURES="json-tests ipc" +OPTIONS="--release" case $1 in --no-json) FEATURES="ipc" shift # past argument=value ;; + --no-release) + OPTIONS="" + shift + ;; *) # unknown option ;; esac . ./scripts/targets.sh -cargo test --release --features "$FEATURES" $TARGETS $1 \ +cargo test $OPTIONS --features "$FEATURES" $TARGETS $1 \