pub struct Builder {
pub app_state: Option<Bytes>,
pub keyring: BTreeMap<VerificationKey, SigningKey>,
pub on_block: Option<OnBlockFn>,
pub ts_callback: Option<TsCallbackFn>,
pub initial_timestamp: Option<Time>,
pub chain_id: Option<String>,
pub hardcoded_genesis: Option<Genesis>,
pub keys: Vec<(SigningKey, VerificationKey)>,
}
Expand description
A builder, used to prepare and instantiate a new TestNode
.
Fields§
§app_state: Option<Bytes>
§keyring: BTreeMap<VerificationKey, SigningKey>
§on_block: Option<OnBlockFn>
§ts_callback: Option<TsCallbackFn>
§initial_timestamp: Option<Time>
§chain_id: Option<String>
§hardcoded_genesis: Option<Genesis>
Hardcodes a genesis to be used for the chain. Useful if you’re trying to test cometbft compatibility but should not be used typically.
keys: Vec<(SigningKey, VerificationKey)>
Specifies hardcoded keys to be assigned to validators. Lowest indices are assigned first. If not enough are provided, random keys will be generated for the remaining validators. The default behavior is to generate random keys if none are supplied.
Implementations§
Source§impl Builder
impl Builder
Sourcepub async fn init_chain<C>(self, consensus: C) -> Result<TestNode<C>, Error>
pub async fn init_chain<C>(self, consensus: C) -> Result<TestNode<C>, Error>
Consumes this builder, using the provided consensus service.
This function returns an error if the builder was not fully initialized, or if the application could not successfully perform the chain initialization.
See TestNode
for more information on the consensus service.
Source§impl Builder
impl Builder
Sourcepub fn app_state(self, app_state: impl Into<Bytes>) -> Self
pub fn app_state(self, app_state: impl Into<Bytes>) -> Self
Sets the app_state_bytes
to send the ABCI application upon chain initialization.
Sourcepub fn single_validator(self) -> Self
pub fn single_validator(self) -> Self
Generates a single set of validator keys.
Sourcepub fn two_validators(self) -> Self
pub fn two_validators(self) -> Self
Generates a pair of validator keys.
Sourcepub fn on_block<F>(self, f: F) -> Self
pub fn on_block<F>(self, f: F) -> Self
Sets a callback that will be invoked when a new block is constructed.
Sourcepub fn ts_callback<F>(self, f: F) -> Self
pub fn ts_callback<F>(self, f: F) -> Self
Sets a callback that will be invoked when a block is committed, to increment the timestamp.
Sourcepub fn with_initial_timestamp(self, initial_time: Time) -> Self
pub fn with_initial_timestamp(self, initial_time: Time) -> Self
Sets the starting time for the test node. If not called, the current timestamp will be used.
Sourcepub fn with_keys(self, keys: Vec<(SigningKey, VerificationKey)>) -> Self
pub fn with_keys(self, keys: Vec<(SigningKey, VerificationKey)>) -> Self
Sets the keys used by validators.
Sourcepub fn with_tendermint_genesis(self, genesis: Genesis) -> Self
pub fn with_tendermint_genesis(self, genesis: Genesis) -> Self
Add the provided Tendermint [Genesis
] to the builder.
This will override other configurations and hardcode the genesis data.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Builder
impl !RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl !UnwindSafe for Builder
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.