Companion for #3007 (Track teleported assets) (#436)

* Companion for #3007: Track teleported assets

* Bump

* Try fix the breakage

Co-authored-by: Sergei Shulepov <sergei@parity.io>
This commit is contained in:
Gavin Wood
2021-05-12 22:51:28 +02:00
committed by GitHub
parent eb23023c45
commit 84bd37817a
5 changed files with 282 additions and 239 deletions
Generated
+264 -224
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -47,6 +47,7 @@ sc-client-api = { git = "https://github.com/paritytech/substrate", default-featu
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-executor-common = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
cumulus-test-client = { path = "../../test/client" }
env_logger = "0.7.1"
+6 -9
View File
@@ -184,17 +184,13 @@ fn new_test_ext() -> sp_io::TestExternalities {
.into()
}
struct CallInWasm(Vec<u8>);
struct ReadRuntimeVersion(Vec<u8>);
impl sp_core::traits::CallInWasm for CallInWasm {
fn call_in_wasm(
impl sp_core::traits::ReadRuntimeVersion for ReadRuntimeVersion {
fn read_runtime_version(
&self,
_wasm_code: &[u8],
_code_hash: Option<Vec<u8>>,
_method: &str,
_call_data: &[u8],
_ext: &mut dyn sp_externalities::Externalities,
_missing_host_functions: sp_core::traits::MissingHostFunctions,
) -> Result<Vec<u8>, String> {
Ok(self.0.clone())
}
@@ -207,10 +203,11 @@ fn wasm_ext() -> sp_io::TestExternalities {
impl_version: 1,
..Default::default()
};
let call_in_wasm = CallInWasm(version.encode());
let mut ext = new_test_ext();
ext.register_extension(sp_core::traits::CallInWasmExt::new(call_in_wasm));
ext.register_extension(sp_core::traits::ReadRuntimeVersionExt::new(
ReadRuntimeVersion(version.encode()),
));
ext
}
@@ -27,7 +27,6 @@ use sc_executor::{
};
use sp_blockchain::HeaderBackend;
use sp_consensus::SelectChain;
use sp_core::traits::CallInWasm;
use sp_io::TestExternalities;
use sp_keyring::AccountKeyring::*;
use sp_runtime::{
@@ -42,6 +41,8 @@ fn call_validate_block(
block_data: ParachainBlockData<Block>,
relay_parent_storage_root: Hash,
) -> Result<Header> {
use sc_executor_common::runtime_blob::RuntimeBlob;
let mut ext = TestExternalities::default();
let mut ext_ext = ext.ext();
let params = ValidationParams {
@@ -61,13 +62,15 @@ fn call_validate_block(
);
executor
.call_in_wasm(
&WASM_BINARY.expect("You need to build the WASM binaries to run the tests!"),
None,
.uncached_call(
RuntimeBlob::uncompress_if_needed(
&WASM_BINARY.expect("You need to build the WASM binaries to run the tests!"),
)
.expect("RuntimeBlob uncompress & parse"),
&mut ext_ext,
false,
"validate_block",
&params,
&mut ext_ext,
sp_core::traits::MissingHostFunctions::Disallow,
)
.map(|v| ValidationResult::decode(&mut &v[..]).expect("Decode `ValidationResult`."))
.map(|v| Header::decode(&mut &v.head_data.0[..]).expect("Decode `Header`."))
@@ -280,6 +280,8 @@ pub type LocalAssetTransactor = CurrencyAdapter<
LocationToAccountId,
// Our chain's account ID type (we can't get away without mentioning it explicitly):
AccountId,
// We don't track any teleports.
(),
>;
/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,