Rearrange export structure to something a bit more convenient.

This commit is contained in:
Gav
2018-01-28 13:41:22 +01:00
parent 5b337e3a9c
commit daa77d09a6
42 changed files with 126 additions and 137 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ extern crate parity_wasm;
extern crate byteorder;
extern crate rustc_hex;
extern crate native_runtime;
extern crate runtime_support;
extern crate runtime_std;
extern crate memcmp;
#[macro_use]
+7 -8
View File
@@ -4,7 +4,7 @@ use state_machine::{Externalities, CodeExecutor};
use error::{Error, ErrorKind, Result};
use wasm_executor::WasmExecutor;
use native_runtime as runtime;
use runtime_support;
use runtime_std;
pub struct NativeExecutor;
@@ -22,7 +22,7 @@ impl CodeExecutor for NativeExecutor {
// get a proper build script, this must be strictly adhered to or things will go wrong.
let native_equivalent = include_bytes!("../../wasm-runtime/target/wasm32-unknown-unknown/release/runtime_polkadot.compact.wasm");
if code == &native_equivalent[..] {
runtime_support::with_externalities(ext, || match method {
runtime_std::with_externalities(ext, || match method {
"execute_block" => catch_unwind(|| runtime::execute_block(&data.0)).map_err(|_| ErrorKind::Runtime.into()),
"execute_transaction" => catch_unwind(|| runtime::execute_transaction(&data.0)).map_err(|_| ErrorKind::Runtime.into()),
_ => Err(ErrorKind::MethodNotFound(method.to_owned()).into()),
@@ -37,11 +37,10 @@ impl CodeExecutor for NativeExecutor {
#[cfg(test)]
mod tests {
use super::*;
use primitives::twox_128;
use native_runtime::testing::{TestExternalities, one, two};
use native_runtime::statichex::StaticHexInto;
use native_runtime::keyedvec::KeyedVec;
use native_runtime::codec::KeyedVec;
use native_runtime::support::{TestExternalities, one, two, StaticHexInto};
use native_runtime::runtime::staking::balance;
use primitives::twox_128;
fn tx() -> Vec<u8> { "679fcf0a846b4224c84ecad7d91a26241c46d00cb53d6480a363274e8965ee34b0b80b4b2e3836d3d8f8f12c0c1aef7350af587d9aee3883561d11726068ac0a2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee00000000000000000228000000d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a4500000000000000".convert() }
@@ -82,7 +81,7 @@ mod tests {
let r = NativeExecutor.call(&mut t, &native_equivalent_code[..], "execute_transaction", &CallData(tx()));
assert!(r.is_ok());
runtime_support::with_externalities(&mut t, || {
runtime_std::with_externalities(&mut t, || {
assert_eq!(balance(&one), 42);
assert_eq!(balance(&two), 69);
});
@@ -101,7 +100,7 @@ mod tests {
let r = NativeExecutor.call(&mut t, &foreign_code[..], "execute_transaction", &CallData(tx()));
assert!(r.is_ok());
runtime_support::with_externalities(&mut t, || {
runtime_std::with_externalities(&mut t, || {
assert_eq!(balance(&one), 42);
assert_eq!(balance(&two), 69);
});
+6 -10
View File
@@ -274,8 +274,11 @@ mod tests {
use super::*;
use rustc_hex::FromHex;
use native_runtime::testing::TestExternalities;
use primitives::hashing::blake2_256;
use primitives::{blake2_256, twox_128};
use runtime_std;
use native_runtime::support::{one, two, StaticHexInto, TestExternalities};
use native_runtime::codec::KeyedVec;
use native_runtime::runtime::staking::balance;
#[test]
fn returning_should_work() {
@@ -373,13 +376,6 @@ mod tests {
);
}
use primitives::twox_128;
use native_runtime::testing::{one, two};
use native_runtime::statichex::StaticHexInto;
use native_runtime::keyedvec::KeyedVec;
use native_runtime::runtime::staking::balance;
use runtime_support;
fn tx() -> Vec<u8> { "679fcf0a846b4224c84ecad7d91a26241c46d00cb53d6480a363274e8965ee34b0b80b4b2e3836d3d8f8f12c0c1aef7350af587d9aee3883561d11726068ac0a2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee00000000000000000228000000d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a4500000000000000".convert() }
#[test]
@@ -407,7 +403,7 @@ mod tests {
let r = WasmExecutor.call(&mut t, &foreign_code[..], "execute_transaction", &CallData(tx()));
assert!(r.is_ok());
runtime_support::with_externalities(&mut t, || {
runtime_std::with_externalities(&mut t, || {
assert_eq!(balance(&one), 42);
assert_eq!(balance(&two), 69);
});