mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 11:41:02 +00:00
Switch parachain interface to new runtime_interface macro (#665)
* Make use of `runtime_interface` for parachain externalities This also changes the encoding of the `ValidationResult` return value to match the default encoding used in Substrate. * Fix compilation for web * Update `Cargo.lock` * Include feedback * Move proc macro * Update parachain/src/lib.rs Co-Authored-By: Robert Habermeier <rphmeier@gmail.com> Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
This commit is contained in:
@@ -18,8 +18,7 @@
|
||||
|
||||
use polkadot_parachain as parachain;
|
||||
|
||||
use crate::parachain::{IncomingMessage, ValidationParams};
|
||||
use crate::DummyExt;
|
||||
use crate::{DummyExt, parachain::{IncomingMessage, ValidationParams}};
|
||||
use codec::{Decode, Encode};
|
||||
|
||||
/// Head data for this parachain.
|
||||
@@ -78,7 +77,7 @@ pub fn execute_good_on_parent() {
|
||||
block_data: block_data.encode(),
|
||||
ingress: Vec::new(),
|
||||
},
|
||||
&mut DummyExt,
|
||||
DummyExt,
|
||||
parachain::wasm_executor::ExecutionMode::RemoteTest,
|
||||
).unwrap();
|
||||
|
||||
@@ -114,7 +113,7 @@ fn execute_good_chain_on_parent() {
|
||||
block_data: block_data.encode(),
|
||||
ingress: Vec::new(),
|
||||
},
|
||||
&mut DummyExt,
|
||||
DummyExt,
|
||||
parachain::wasm_executor::ExecutionMode::RemoteTest,
|
||||
).unwrap();
|
||||
|
||||
@@ -150,7 +149,7 @@ fn execute_bad_on_parent() {
|
||||
block_data: block_data.encode(),
|
||||
ingress: Vec::new(),
|
||||
},
|
||||
&mut DummyExt,
|
||||
DummyExt,
|
||||
parachain::wasm_executor::ExecutionMode::RemoteTest,
|
||||
).unwrap_err();
|
||||
}
|
||||
@@ -182,7 +181,7 @@ fn processes_messages() {
|
||||
IncomingMessage { source: 3.into(), data: (AddMessage { amount: 256 }).encode() },
|
||||
],
|
||||
},
|
||||
&mut DummyExt,
|
||||
DummyExt,
|
||||
parachain::wasm_executor::ExecutionMode::RemoteTest,
|
||||
).unwrap();
|
||||
|
||||
|
||||
@@ -19,16 +19,15 @@ mod wasm_executor;
|
||||
|
||||
use polkadot_parachain as parachain;
|
||||
use crate::parachain::{
|
||||
MessageRef, UpwardMessageRef,
|
||||
wasm_executor::{Externalities, ExternalitiesError, run_worker},
|
||||
TargetedMessage, UpwardMessage, wasm_executor::{Externalities, run_worker},
|
||||
};
|
||||
|
||||
struct DummyExt;
|
||||
impl Externalities for DummyExt {
|
||||
fn post_message(&mut self, _message: MessageRef) -> Result<(), ExternalitiesError> {
|
||||
fn post_message(&mut self, _: TargetedMessage) -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
fn post_upward_message(&mut self, _message: UpwardMessageRef) -> Result<(), ExternalitiesError> {
|
||||
fn post_upward_message(&mut self, _: UpwardMessage) -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ fn terminates_on_timeout() {
|
||||
block_data: Vec::new(),
|
||||
ingress: Vec::new(),
|
||||
},
|
||||
&mut DummyExt,
|
||||
DummyExt,
|
||||
parachain::wasm_executor::ExecutionMode::RemoteTest,
|
||||
);
|
||||
match result {
|
||||
@@ -55,7 +55,7 @@ fn parallel_execution() {
|
||||
block_data: Vec::new(),
|
||||
ingress: Vec::new(),
|
||||
},
|
||||
&mut DummyExt,
|
||||
DummyExt,
|
||||
parachain::wasm_executor::ExecutionMode::RemoteTest,
|
||||
).ok());
|
||||
let _ = parachain::wasm_executor::validate_candidate(
|
||||
@@ -65,7 +65,7 @@ fn parallel_execution() {
|
||||
block_data: Vec::new(),
|
||||
ingress: Vec::new(),
|
||||
},
|
||||
&mut DummyExt,
|
||||
DummyExt,
|
||||
parachain::wasm_executor::ExecutionMode::RemoteTest,
|
||||
);
|
||||
thread.join().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user