pub struct MockConsensusNode {
pub task_manager: TaskManager,
pub client: Arc<Client>,
pub backend: Arc<Backend>,
pub executor: RuntimeExecutor,
pub transaction_pool: Arc<FullPool<Client, Block, Header>>,
pub select_chain: FullSelectChain,
pub network_service: Arc<dyn NetworkService + Send + Sync>,
pub xdm_gossip_notification_service: Option<Box<dyn NotificationService>>,
pub sync_service: Arc<SyncingService<Block>>,
pub rpc_handlers: RpcHandlers,
pub network_starter: Option<NetworkStarter>,
pub key: Sr25519Keyring,
/* private fields */
}
Expand description
A mock Subspace consensus node instance used for testing.
Fields§
§task_manager: TaskManager
TaskManager
’s instance.
client: Arc<Client>
Client’s instance.
backend: Arc<Backend>
Backend.
executor: RuntimeExecutor
Code executor.
transaction_pool: Arc<FullPool<Client, Block, Header>>
Transaction pool.
select_chain: FullSelectChain
The SelectChain Strategy
network_service: Arc<dyn NetworkService + Send + Sync>
Network service.
xdm_gossip_notification_service: Option<Box<dyn NotificationService>>
Cross-domain gossip notification service.
sync_service: Arc<SyncingService<Block>>
Sync service.
rpc_handlers: RpcHandlers
RPC handlers.
network_starter: Option<NetworkStarter>
Network starter
key: Sr25519Keyring
Ferdie key
Implementations§
source§impl MockConsensusNode
impl MockConsensusNode
sourcepub fn run(
tokio_handle: Handle,
key: Sr25519Keyring,
base_path: BasePath,
) -> MockConsensusNode
pub fn run( tokio_handle: Handle, key: Sr25519Keyring, base_path: BasePath, ) -> MockConsensusNode
Run a mock consensus node
sourcepub fn run_with_finalization_depth(
tokio_handle: Handle,
key: Sr25519Keyring,
base_path: BasePath,
finalize_block_depth: Option<NumberFor<Block>>,
) -> MockConsensusNode
pub fn run_with_finalization_depth( tokio_handle: Handle, key: Sr25519Keyring, base_path: BasePath, finalize_block_depth: Option<NumberFor<Block>>, ) -> MockConsensusNode
Run a mock consensus node with finalization depth
sourcepub fn start_network(&mut self)
pub fn start_network(&mut self)
Start the mock consensus node network
sourcepub fn xdm_gossip_worker_builder(&mut self) -> &mut GossipWorkerBuilder
pub fn xdm_gossip_worker_builder(&mut self) -> &mut GossipWorkerBuilder
Get the cross domain gossip message worker builder
sourcepub fn start_cross_domain_gossip_message_worker(&mut self)
pub fn start_cross_domain_gossip_message_worker(&mut self)
Start the cross domain gossip message worker.
sourcepub fn set_next_slot(&mut self, next_slot: u64)
pub fn set_next_slot(&mut self, next_slot: u64)
Set the next slot number
sourcepub fn produce_slot(&mut self) -> (Slot, PotOutput)
pub fn produce_slot(&mut self) -> (Slot, PotOutput)
Produce a slot only, without waiting for the potential slot handlers.
sourcepub async fn notify_new_slot_and_wait_for_bundle(
&mut self,
new_slot: (Slot, PotOutput),
) -> Option<OpaqueBundle<NumberFor<Block>, Hash, DomainHeader, Balance>>
pub async fn notify_new_slot_and_wait_for_bundle( &mut self, new_slot: (Slot, PotOutput), ) -> Option<OpaqueBundle<NumberFor<Block>, Hash, DomainHeader, Balance>>
Notify the executor about the new slot and wait for the bundle produced at this slot.
sourcepub async fn produce_slot_and_wait_for_bundle_submission(
&mut self,
) -> ((Slot, PotOutput), OpaqueBundle<NumberFor<Block>, Hash, DomainHeader, Balance>)
pub async fn produce_slot_and_wait_for_bundle_submission( &mut self, ) -> ((Slot, PotOutput), OpaqueBundle<NumberFor<Block>, Hash, DomainHeader, Balance>)
Produce a new slot and wait for a bundle produced at this slot.
sourcepub fn new_slot_notification_stream(
&mut self,
) -> UnboundedReceiver<(Slot, PotOutput)>
pub fn new_slot_notification_stream( &mut self, ) -> UnboundedReceiver<(Slot, PotOutput)>
Subscribe the new slot notification
sourcepub fn new_acknowledgement_sender_stream(
&mut self,
) -> TracingUnboundedReceiver<Sender<()>>
pub fn new_acknowledgement_sender_stream( &mut self, ) -> TracingUnboundedReceiver<Sender<()>>
Subscribe the acknowledgement sender stream
sourcepub async fn confirm_acknowledgement(&mut self)
pub async fn confirm_acknowledgement(&mut self)
Wait for all the acknowledgements before return
It is used to wait for the acknowledgement of the domain worker to ensure it have finish all the previous tasks before return
sourcepub async fn confirm_block_import_processed(&mut self)
pub async fn confirm_block_import_processed(&mut self)
Wait for the operator finish processing the consensus block before return
sourcepub fn block_importing_notification_stream(
&mut self,
) -> TracingUnboundedReceiver<(NumberFor<Block>, Sender<()>)>
pub fn block_importing_notification_stream( &mut self, ) -> TracingUnboundedReceiver<(NumberFor<Block>, Sender<()>)>
Subscribe the block importing notification
sourcepub fn get_bundle_from_tx_pool(
&self,
new_slot: (Slot, PotOutput),
) -> Option<OpaqueBundle<NumberFor<Block>, Hash, DomainHeader, Balance>>
pub fn get_bundle_from_tx_pool( &self, new_slot: (Slot, PotOutput), ) -> Option<OpaqueBundle<NumberFor<Block>, Hash, DomainHeader, Balance>>
Get the bundle that created at slot
from the transaction pool
sourcepub async fn submit_transaction(
&self,
tx: OpaqueExtrinsic,
) -> Result<H256, PoolError>
pub async fn submit_transaction( &self, tx: OpaqueExtrinsic, ) -> Result<H256, PoolError>
Submit a tx to the tx pool
sourcepub async fn prune_tx_from_pool(
&self,
tx: &OpaqueExtrinsic,
) -> Result<(), Box<dyn Error>>
pub async fn prune_tx_from_pool( &self, tx: &OpaqueExtrinsic, ) -> Result<(), Box<dyn Error>>
Remove a ready transaction from transaction pool.
sourcepub fn does_receipt_exist(
&self,
er_hash: <DomainBlock as BlockT>::Hash,
) -> Result<bool, Box<dyn Error>>
pub fn does_receipt_exist( &self, er_hash: <DomainBlock as BlockT>::Hash, ) -> Result<bool, Box<dyn Error>>
Return if the given ER exist in the consensus state
sourcepub fn wait_for_fraud_proof<FP>(
&self,
fraud_proof_predict: FP,
) -> Pin<Box<dyn Future<Output = ()> + Send>>where
FP: Fn(&FraudProof<NumberFor<Block>, <Block as BlockT>::Hash, <DomainBlock as BlockT>::Header, H256>) -> bool + Send + 'static,
pub fn wait_for_fraud_proof<FP>(
&self,
fraud_proof_predict: FP,
) -> Pin<Box<dyn Future<Output = ()> + Send>>where
FP: Fn(&FraudProof<NumberFor<Block>, <Block as BlockT>::Hash, <DomainBlock as BlockT>::Header, H256>) -> bool + Send + 'static,
Return a future that only resolve if a fraud proof that the given fraud_proof_predict
return true is submitted to the consensus tx pool
sourcepub fn free_balance(&self, account_id: AccountId) -> Balance
pub fn free_balance(&self, account_id: AccountId) -> Balance
Get the free balance of the given account
source§impl MockConsensusNode
impl MockConsensusNode
sourcepub async fn produce_block_with_slot_at(
&mut self,
new_slot: (Slot, PotOutput),
parent_hash: <Block as BlockT>::Hash,
maybe_extrinsics: Option<Vec<<Block as BlockT>::Extrinsic>>,
) -> Result<<Block as BlockT>::Hash, Box<dyn Error>>
pub async fn produce_block_with_slot_at( &mut self, new_slot: (Slot, PotOutput), parent_hash: <Block as BlockT>::Hash, maybe_extrinsics: Option<Vec<<Block as BlockT>::Extrinsic>>, ) -> Result<<Block as BlockT>::Hash, Box<dyn Error>>
Produce a new block with the slot on top of parent_hash
, with optional
specified extrinsic list.
sourcepub async fn produce_block_with_slot(
&mut self,
slot: (Slot, PotOutput),
) -> Result<(), Box<dyn Error>>
pub async fn produce_block_with_slot( &mut self, slot: (Slot, PotOutput), ) -> Result<(), Box<dyn Error>>
Produce a new block on top of the current best block, with the extrinsics collected from the transaction pool.
sourcepub async fn produce_block_with_extrinsics(
&mut self,
extrinsics: Vec<<Block as BlockT>::Extrinsic>,
) -> Result<(), Box<dyn Error>>
pub async fn produce_block_with_extrinsics( &mut self, extrinsics: Vec<<Block as BlockT>::Extrinsic>, ) -> Result<(), Box<dyn Error>>
Produce a new block on top of the current best block, with the specificed extrinsics.
sourcepub async fn produce_blocks(&mut self, n: u64) -> Result<(), Box<dyn Error>>
pub async fn produce_blocks(&mut self, n: u64) -> Result<(), Box<dyn Error>>
Produce n
number of blocks.
sourcepub async fn produce_blocks_with_bundles(
&mut self,
n: u64,
) -> Result<(), Box<dyn Error>>
pub async fn produce_blocks_with_bundles( &mut self, n: u64, ) -> Result<(), Box<dyn Error>>
Produce n
number of blocks and wait for bundle submitted to the block.
sourcepub fn account_nonce(&self) -> u32
pub fn account_nonce(&self) -> u32
Get the nonce of the node account
sourcepub fn construct_extrinsic(
&mut self,
nonce: u32,
function: impl Into<<Runtime as Config>::RuntimeCall>,
) -> UncheckedExtrinsic
pub fn construct_extrinsic( &mut self, nonce: u32, function: impl Into<<Runtime as Config>::RuntimeCall>, ) -> UncheckedExtrinsic
Construct an extrinsic.
sourcepub async fn construct_and_send_extrinsic_with(
&mut self,
function: impl Into<<Runtime as Config>::RuntimeCall>,
) -> Result<RpcTransactionOutput, RpcTransactionError>
pub async fn construct_and_send_extrinsic_with( &mut self, function: impl Into<<Runtime as Config>::RuntimeCall>, ) -> Result<RpcTransactionOutput, RpcTransactionError>
Construct and send extrinsic through rpc
Auto Trait Implementations§
impl Freeze for MockConsensusNode
impl !RefUnwindSafe for MockConsensusNode
impl Send for MockConsensusNode
impl !Sync for MockConsensusNode
impl Unpin for MockConsensusNode
impl !UnwindSafe for MockConsensusNode
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
§fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> IsType<T> for T
impl<T> IsType<T> for T
§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read more§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.§impl<T> TryConv for T
impl<T> TryConv for T
§impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
type Error = <U as TryFromKey<T>>::Error
fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>
§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.