pub struct TestBuilder<B: StorageBuilder> {
pub initial_committee: Committee,
pub validator_storages: HashMap<ValidatorPublicKey, B::Storage>,
pub validator_key_pairs: HashMap<ValidatorPublicKey, ValidatorSecretKey>,
pub chain_owners: BTreeMap<ChainId, AccountOwner>,
pub signer: TestSigner,
/* private fields */
}Fields§
§initial_committee: Committee§validator_storages: HashMap<ValidatorPublicKey, B::Storage>§validator_key_pairs: HashMap<ValidatorPublicKey, ValidatorSecretKey>§chain_owners: BTreeMap<ChainId, AccountOwner>§signer: TestSignerImplementations§
Source§impl<B> TestBuilder<B>where
B: StorageBuilder,
impl<B> TestBuilder<B>where
B: StorageBuilder,
Sourcepub fn clock(&self) -> &TestClock
pub fn clock(&self) -> &TestClock
The simulated clock every storage here shares, so a test can drive the export queue’s tick in virtual time instead of sleeping through it.
Sourcepub async fn new(
storage_builder: B,
count: usize,
with_faulty_validators: usize,
signer: TestSigner,
) -> Result<Self, Error>
pub async fn new( storage_builder: B, count: usize, with_faulty_validators: usize, signer: TestSigner, ) -> Result<Self, Error>
Creates a test setup with count validators, with_faulty_validators of which are faulty.
Sourcepub async fn new_with_block_export(
storage_builder: B,
count: usize,
with_faulty_validators: usize,
signer: TestSigner,
) -> Result<Self, Error>
pub async fn new_with_block_export( storage_builder: B, count: usize, with_faulty_validators: usize, signer: TestSigner, ) -> Result<Self, Error>
Creates a test setup like TestBuilder::new, in which every validator also pushes the
blocks it executes to the rest of the committee.
Sourcepub async fn new_with_block_export_and_ttl(
storage_builder: B,
count: usize,
with_faulty_validators: usize,
signer: TestSigner,
chain_worker_ttl: Duration,
) -> Result<Self, Error>
pub async fn new_with_block_export_and_ttl( storage_builder: B, count: usize, with_faulty_validators: usize, signer: TestSigner, chain_worker_ttl: Duration, ) -> Result<Self, Error>
Creates a test setup like TestBuilder::new_with_block_export with an explicit chain
worker TTL, for asserting that workers expire even while export is enabled.
Sourcepub async fn new_with_block_export_config(
storage_builder: B,
count: usize,
with_faulty_validators: usize,
signer: TestSigner,
config: BlockExportConfig,
) -> Result<Self, Error>
pub async fn new_with_block_export_config( storage_builder: B, count: usize, with_faulty_validators: usize, signer: TestSigner, config: BlockExportConfig, ) -> Result<Self, Error>
Creates a test setup like TestBuilder::new_with_block_export, with the export tuned by
the caller. Used to shrink max_catch_up_blocks far below its default so that a backlog a
test can actually produce still takes several rounds to drain.
Sourcepub fn test_block_export_config() -> BlockExportConfig
pub fn test_block_export_config() -> BlockExportConfig
The export settings the block-export tests run with: production backoff is measured in seconds, which would make every test that exercises a failing destination wait it out.
Sourcepub fn with_policy(self, policy: ResourceControlPolicy) -> Self
pub fn with_policy(self, policy: ResourceControlPolicy) -> Self
Replaces the initial committee’s resource control policy.
Sourcepub fn with_cross_chain_message_chunk_limit(self, limit: usize) -> Self
pub fn with_cross_chain_message_chunk_limit(self, limit: usize) -> Self
Sets the cross-chain message chunk limit on every validator in the test setup.
Sourcepub fn fail_next_validator_set_builds(&self, count: usize)
pub fn fail_next_validator_set_builds(&self, count: usize)
Makes the next count attempts to build the validator set fail, so a test can
force update_notification_streams to return Err at a chosen moment.
Sourcepub fn validator_set_build_failures_left(&self) -> usize
pub fn validator_set_build_failures_left(&self) -> usize
How many of the injected validator-set-build failures are still pending, so a test can count how often a failing update was retried.
Sourcepub async fn stall_chain_info_queries(
&self,
index: usize,
) -> OwnedRwLockWriteGuard<()>
pub async fn stall_chain_info_queries( &self, index: usize, ) -> OwnedRwLockWriteGuard<()>
Stalls every chain-info query at the validator at index until the returned guard
is dropped, which stalls the initial sync a probe runs once subscribe succeeds.
Sourcepub fn slow_validator_set_builds(&self, by: TimeDelta)
pub fn slow_validator_set_builds(&self, by: TimeDelta)
Makes every validator-set build advance the clock, simulating a committee read slow enough that deadlines computed from a clock sampled BEFORE it are already elapsed.
Sourcepub fn validator_set_builds(&self) -> usize
pub fn validator_set_builds(&self) -> usize
Every attempt the chain clients have made to build the validator set.
Sourcepub async fn subscribe_calls(&self, index: usize) -> usize
pub async fn subscribe_calls(&self, index: usize) -> usize
How many times the validator at index has been asked to subscribe.
Sourcepub async fn disconnect_notification_subscribers(&self)
pub async fn disconnect_notification_subscribers(&self)
Severs every notification stream on every validator in the test setup, as a fleet-wide proxy restart does. Clients keep their (now dead) ends of the streams until they notice and re-subscribe.
Sourcepub fn fault_type(&self, public_key: &ValidatorPublicKey) -> Option<FaultType>
pub fn fault_type(&self, public_key: &ValidatorPublicKey) -> Option<FaultType>
Returns the FaultType currently configured for the given validator, or None
if no validator with that key is in the test setup.
Sourcepub fn set_fault_type(
&mut self,
indexes: impl AsRef<[usize]>,
fault_type: FaultType,
)
pub fn set_fault_type( &mut self, indexes: impl AsRef<[usize]>, fault_type: FaultType, )
Sets the FaultType for the validators at the given indexes.
Sourcepub async fn add_root_chain(
&mut self,
index: u32,
balance: Amount,
) -> Result<ChainClient<B::Storage>>
pub async fn add_root_chain( &mut self, index: u32, balance: Amount, ) -> Result<ChainClient<B::Storage>>
Creates the root chain with the given index, and returns a client for it.
Root chain 0 is the admin chain and needs to be initialized first, otherwise its balance is automatically set to zero.
Sourcepub async fn add_root_chain_with_ownership(
&mut self,
index: u32,
balance: Amount,
make_ownership: impl FnOnce(AccountOwner) -> ChainOwnership,
) -> Result<ChainClient<B::Storage>>
pub async fn add_root_chain_with_ownership( &mut self, index: u32, balance: Amount, make_ownership: impl FnOnce(AccountOwner) -> ChainOwnership, ) -> Result<ChainClient<B::Storage>>
Creates the root chain with the given index and a genesis ownership built from its
freshly generated owner key, and returns a client for it.
Root chain 0 is the admin chain and needs to be initialized first, otherwise its balance is automatically set to zero.
Sourcepub fn genesis_chains(&self) -> Vec<(AccountPublicKey, Amount)>
pub fn genesis_chains(&self) -> Vec<(AccountPublicKey, Amount)>
Returns the public key and balance of each genesis root chain.
Sourcepub fn admin_chain_id(&self) -> ChainId
pub fn admin_chain_id(&self) -> ChainId
Returns the admin chain’s ID, panicking if it has not been initialized.
Sourcepub fn admin_description(&self) -> Option<&ChainDescription>
pub fn admin_description(&self) -> Option<&ChainDescription>
Returns the admin chain description, if the admin chain has been initialized.
Sourcepub fn make_node_provider(&self) -> NodeProvider<B::Storage>
pub fn make_node_provider(&self) -> NodeProvider<B::Storage>
Returns a clone of the node provider backing this test setup.
Sourcepub fn validator_storage(&mut self, index: usize) -> B::Storage
pub fn validator_storage(&mut self, index: usize) -> B::Storage
Returns the storage of the validator at index, which holds every block that validator
has processed.
Sourcepub fn node(&mut self, index: usize) -> LocalValidatorClient<B::Storage>
pub fn node(&mut self, index: usize) -> LocalValidatorClient<B::Storage>
Returns a clone of the validator client at the given index.
Sourcepub async fn make_storage(&mut self) -> Result<B::Storage>
pub async fn make_storage(&mut self) -> Result<B::Storage>
Builds a fresh storage seeded with the network description and genesis chains.
Sourcepub async fn make_client_with_options(
&mut self,
chain_id: ChainId,
block_hash: Option<CryptoHash>,
block_height: BlockHeight,
options: Options,
follow_only: bool,
) -> Result<ChainClient<B::Storage>>
pub async fn make_client_with_options( &mut self, chain_id: ChainId, block_hash: Option<CryptoHash>, block_height: BlockHeight, options: Options, follow_only: bool, ) -> Result<ChainClient<B::Storage>>
Creates a chain client for the given chain with the given client options.
Sourcepub async fn make_client(
&mut self,
chain_id: ChainId,
block_hash: Option<CryptoHash>,
block_height: BlockHeight,
) -> Result<ChainClient<B::Storage>>
pub async fn make_client( &mut self, chain_id: ChainId, block_hash: Option<CryptoHash>, block_height: BlockHeight, ) -> Result<ChainClient<B::Storage>>
Creates a chain client for the given chain with default test options.
Sourcepub async fn check_that_validators_have_certificate(
&self,
chain_id: ChainId,
block_height: BlockHeight,
target_count: usize,
) -> Option<ConfirmedBlockCertificate>
pub async fn check_that_validators_have_certificate( &self, chain_id: ChainId, block_height: BlockHeight, target_count: usize, ) -> Option<ConfirmedBlockCertificate>
Tries to find a (confirmation) certificate for the given chain_id and block height.
Sourcepub async fn check_that_validators_are_in_round(
&self,
chain_id: ChainId,
block_height: BlockHeight,
round: Round,
target_count: usize,
)
pub async fn check_that_validators_are_in_round( &self, chain_id: ChainId, block_height: BlockHeight, round: Round, target_count: usize, )
Tries to find a (confirmation) certificate for the given chain_id and block height, and are in the expected round.
Sourcepub async fn exported_heights(
&self,
index: usize,
chain_id: ChainId,
) -> BTreeMap<ValidatorPublicKey, BlockHeight>
pub async fn exported_heights( &self, index: usize, chain_id: ChainId, ) -> BTreeMap<ValidatorPublicKey, BlockHeight>
Returns how far the validator at index believes it has exported the given chain to each
of the other validators.
Sourcepub async fn resident_chain_workers(&self, index: usize) -> usize
pub async fn resident_chain_workers(&self, index: usize) -> usize
Returns how many chain workers the validator at index currently has resident.
Sourcepub async fn next_block_height(
&self,
index: usize,
chain_id: ChainId,
) -> BlockHeight
pub async fn next_block_height( &self, index: usize, chain_id: ChainId, ) -> BlockHeight
Returns the next block height the validator at index has for the given chain.
Sourcepub async fn check_that_validators_have_empty_outboxes(&self, chain_id: ChainId)
pub async fn check_that_validators_have_empty_outboxes(&self, chain_id: ChainId)
Panics if any validator has a nonempty outbox for the given chain.
Auto Trait Implementations§
impl<B> Freeze for TestBuilder<B>where
B: Freeze,
impl<B> RefUnwindSafe for TestBuilder<B>
impl<B> Send for TestBuilder<B>where
B: Send,
impl<B> Sync for TestBuilder<B>where
B: Sync,
impl<B> Unpin for TestBuilder<B>
impl<B> UnsafeUnpin for TestBuilder<B>where
B: UnsafeUnpin,
impl<B> UnwindSafe for TestBuilder<B>
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T> MockResults for T
impl<T> MockResults for T
Source§type Results = T
type Results = T
MockInstance.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§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 moreSource§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 moreSource§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
Source§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
Source§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.Source§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.Source§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.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<M, I> RuntimeMemory<&mut I> for Mwhere
M: RuntimeMemory<I>,
impl<M, I> RuntimeMemory<&mut I> for Mwhere
M: RuntimeMemory<I>,
Source§fn read<'instance>(
&self,
instance: &'instance &mut I,
location: GuestPointer,
length: u32,
) -> Result<Cow<'instance, [u8]>, RuntimeError>
fn read<'instance>( &self, instance: &'instance &mut I, location: GuestPointer, length: u32, ) -> Result<Cow<'instance, [u8]>, RuntimeError>
Reads length bytes from memory from the provided location.
Source§fn write(
&mut self,
instance: &mut &mut I,
location: GuestPointer,
bytes: &[u8],
) -> Result<(), RuntimeError>
fn write( &mut self, instance: &mut &mut I, location: GuestPointer, bytes: &[u8], ) -> Result<(), RuntimeError>
Writes the bytes to memory at the provided location.
Source§impl<T> Tap for T
impl<T> Tap for T
Source§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.