Unknit rpc from polkadot.

This commit is contained in:
Gav
2018-02-07 22:31:22 +01:00
parent 652b5705d6
commit b1537185fa
12 changed files with 110 additions and 32 deletions
+1 -2
View File
@@ -10,8 +10,7 @@ jsonrpc-macros = { git="https://github.com/paritytech/jsonrpc.git" }
substrate-client = { path = "../client" }
substrate-primitives = { path = "../primitives" }
substrate-state-machine = { path = "../state-machine" }
# TODO: Remove this and split out tests.
polkadot-executor = { path = "../polkadot-executor" }
substrate-executor = { path = "../executor" }
[dev-dependencies]
assert_matches = "1.1"
+10 -2
View File
@@ -14,13 +14,21 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
use polkadot_executor as executor;
use substrate_executor as executor;
use client;
use super::*;
#[test]
fn should_return_header() {
let client = client::new_in_mem(executor::executor()).unwrap();
let test_genesis_block = block::Header {
parent_hash: 0.into(),
number: 0,
state_root: 0.into(),
transaction_root: Default::default(),
digest: Default::default(),
};
let client = client::new_in_mem(executor::WasmExecutor, || (test_genesis_block.clone(), vec![])).unwrap();
assert_matches!(
ChainApi::header(&client, "af65e54217fb213853703d57b80fc5b2bb834bf923046294d7a49bff62f0a8b2".into()),
+1 -1
View File
@@ -29,7 +29,7 @@ extern crate error_chain;
extern crate jsonrpc_macros;
#[cfg(test)]
extern crate polkadot_executor;
extern crate substrate_executor;
#[cfg(test)]
#[macro_use]
extern crate assert_matches;
+19 -4
View File
@@ -14,15 +14,22 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
use substrate_executor as executor;
use super::*;
use polkadot_executor as executor;
use self::error::{Error, ErrorKind};
use client;
#[test]
fn should_return_storage() {
let client = client::new_in_mem(executor::executor()).unwrap();
let test_genesis_block = block::Header {
parent_hash: 0.into(),
number: 0,
state_root: 0.into(),
transaction_root: Default::default(),
digest: Default::default(),
};
let client = client::new_in_mem(executor::WasmExecutor, || (test_genesis_block.clone(), vec![])).unwrap();
let genesis_hash = "af65e54217fb213853703d57b80fc5b2bb834bf923046294d7a49bff62f0a8b2".into();
assert_matches!(
@@ -35,7 +42,15 @@ fn should_return_storage() {
#[ignore] // TODO: [ToDr] reenable once we can properly mock the wasm executor env
fn should_call_contract() {
// TODO [ToDr] Fix test after we are able to mock state.
let client = client::new_in_mem(executor::executor()).unwrap();
let test_genesis_block = block::Header {
parent_hash: 0.into(),
number: 0,
state_root: 0.into(),
transaction_root: Default::default(),
digest: Default::default(),
};
let client = client::new_in_mem(executor::WasmExecutor, || (test_genesis_block.clone(), vec![])).unwrap();
let genesis_hash = "af65e54217fb213853703d57b80fc5b2bb834bf923046294d7a49bff62f0a8b2".into();
assert_matches!(