pub struct TestNode<C> { /* private fields */ }
Expand description
A test node.
A TestNode<C>
represents a validator node containing an instance of the state transition
machine and its accompanying consensus engine.
§Initialization
Construct a new test node by calling TestNode::builder()
. The builder::Builder
returned by that method can be used to set the initial application state, and configure
validators’ consensus keys that should be present at genesis. Use
builder::Builder::init_chain()
to consume the builder and initialize the application.
§Consensus Service
A test node is generic in terms of a consensus service C
. This service should implement
[tower::Service
], accepting ConsensusRequest
s, and returning
ConsensusResponse
s.
For tower-abci
users, this should correspond with the C
parameter of the
Server
type.
§Blocks
Blocks can be executed by using TestNode::block()
. This can be used to add transactions,
signatures, and evidence to a Block
, before invoking
block::Builder::execute()
to execute the next block.
Implementations§
Source§impl<C> TestNode<C>
ABCI-related interfaces.
impl<C> TestNode<C>
ABCI-related interfaces.
Sourcepub async fn begin_block(
&mut self,
header: Header,
last_commit_info: CommitInfo,
) -> Result<BeginBlock, Error>
pub async fn begin_block( &mut self, header: Header, last_commit_info: CommitInfo, ) -> Result<BeginBlock, Error>
Sends a [ConsensusRequest::BeginBlock
] request to the ABCI application.
Sourcepub async fn deliver_tx(&mut self, tx: Bytes) -> Result<DeliverTx, Error>
pub async fn deliver_tx(&mut self, tx: Bytes) -> Result<DeliverTx, Error>
Sends a [ConsensusRequest::DeliverTx
] request to the ABCI application.
Source§impl<C> TestNode<C>
Accessors.
impl<C> TestNode<C>
Accessors.
Sourcepub fn last_app_hash(&self) -> &[u8] ⓘ
pub fn last_app_hash(&self) -> &[u8] ⓘ
Returns the last app_hash
value, represented as a slice of bytes.
Sourcepub fn last_commit(&self) -> Option<&Commit>
pub fn last_commit(&self) -> Option<&Commit>
Returns the last commit
value.
Sourcepub fn last_validator_set_hash(&self) -> Option<&Hash>
pub fn last_validator_set_hash(&self) -> Option<&Hash>
Returns the last validator_set_hash
value.
Sourcepub fn last_app_hash_hex(&self) -> String
pub fn last_app_hash_hex(&self) -> String
Returns the last app_hash
value, represented as a hexadecimal string.
Sourcepub fn keyring(&self) -> &BTreeMap<VerificationKey, SigningKey>
pub fn keyring(&self) -> &BTreeMap<VerificationKey, SigningKey>
Returns a reference to the test node’s set of consensus keys.
Sourcepub fn keyring_mut(&mut self) -> &mut BTreeMap<VerificationKey, SigningKey>
pub fn keyring_mut(&mut self) -> &mut BTreeMap<VerificationKey, SigningKey>
Returns a mutable reference to the test node’s set of consensus keys.
pub fn height(&self) -> &Height
Auto Trait Implementations§
impl<C> Freeze for TestNode<C>where
C: Freeze,
impl<C> !RefUnwindSafe for TestNode<C>
impl<C> Send for TestNode<C>where
C: Send,
impl<C> Sync for TestNode<C>where
C: Sync,
impl<C> Unpin for TestNode<C>where
C: Unpin,
impl<C> !UnwindSafe for TestNode<C>
Blanket Implementations§
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> Conv for T
impl<T> Conv for T
§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>
§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> 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.