Skip to main content

BlokliTestState

Struct BlokliTestState 

Source
pub struct BlokliTestState {
Show 15 fields pub accounts: IndexMap<u32, Account>, pub native_balances: IndexMap<String, NativeBalance>, pub token_balances: IndexMap<String, HoprBalance>, pub safe_allowances: IndexMap<String, SafeHoprAllowance>, pub deployed_safes: IndexMap<String, Safe>, pub safe_redeem_stats: IndexMap<String, RedeemedStats>, pub tx_counts: IndexMap<String, u64>, pub channels: IndexMap<String, Channel>, pub services: IndexMap<String, ServiceEntry>, pub service_types: IndexMap<String, ServiceTypeInfo>, pub service_registry_config: ServiceRegistryConfig, pub chain_info: ChainInfo, pub version: String, pub health: String, pub active_txs: IndexMap<TxId, Transaction>,
}
Expand description

In-memory state served by BlokliTestClient.

Fields are public so tests can build fixtures directly. Maps are keyed by the same identifiers used by the public client responses, typically hex-encoded addresses or ids. BlokliTestState::default provides a small coherent baseline suitable for tests that only need to override a few fields.

Fields§

§accounts: IndexMap<u32, Account>

Contains KeyID -> Account

§native_balances: IndexMap<String, NativeBalance>

Contains native balances for addresses.

§token_balances: IndexMap<String, HoprBalance>

Contains token balances for addresses.

§safe_allowances: IndexMap<String, SafeHoprAllowance>

Contains safe allowances for addresses.

§deployed_safes: IndexMap<String, Safe>

Contains deployed Safes for addresses.

§safe_redeem_stats: IndexMap<String, RedeemedStats>

Ticket redemption statistics per Safe address

§tx_counts: IndexMap<String, u64>

Contains transaction counts for addresses.

§channels: IndexMap<String, Channel>

Contains ChannelId -> Channel.

§services: IndexMap<String, ServiceEntry>

Contains service registry entries, keyed by BlokliTestState::service_entry_key.

§service_types: IndexMap<String, ServiceTypeInfo>

Contains service type configuration, keyed by ServiceTypeInfo::service_type.

§service_registry_config: ServiceRegistryConfig

Contains the registry-wide type registration fee and node-safe registry pointer.

§chain_info: ChainInfo

Contains chain info.

§version: String

Version of the Blokli server.

§health: String

Health of the Blokli server.

§active_txs: IndexMap<TxId, Transaction>

Active transactions.

This field is transient and not serialized.

Implementations§

Source§

impl BlokliTestState

Source

pub fn service_entry_key(service_type: &str, node: &ChainAddress) -> String

Builds the services key for a service type and node address.

The key is "<service type>/<node address>", where the service type is written the way Blokli renders it - the ASCII name, or 0x-prefixed hex - and the node address is hex, with or without a 0x prefix.

Source

pub fn get_service_entry( &self, service_type: &ServiceTypeId, node: &ChainAddress, ) -> Option<&ServiceEntry>

Convenience method to return a reference to the ServiceEntry of a node for a service type.

Source

pub fn get_service_entry_mut( &mut self, service_type: &ServiceTypeId, node: &ChainAddress, ) -> Option<&mut ServiceEntry>

Convenience method to return a mutable reference to the ServiceEntry of a node for a service type.

Source

pub fn get_service_type( &self, service_type: &ServiceTypeId, ) -> Option<&ServiceTypeInfo>

Convenience method to return a reference to the ServiceTypeInfo of a service type.

Source

pub fn get_service_type_mut( &mut self, service_type: &ServiceTypeId, ) -> Option<&mut ServiceTypeInfo>

Convenience method to return a mutable reference to the ServiceTypeInfo of a service type.

Source

pub fn get_account(&self, chain_key: &ChainAddress) -> Option<&Account>

Convenience method to return a reference to an Account with a given ChainAddress.

Source

pub fn get_account_mut( &mut self, chain_key: &ChainAddress, ) -> Option<&mut Account>

Convenience method to return a mutable reference to an Account with a given ChainAddress.

Source

pub fn get_channel_by_id(&self, channel_id: &ChannelId) -> Option<&Channel>

Convenience method to return a reference to a Channel with a given ChannelId.

Source

pub fn get_channel_by_id_mut( &mut self, channel_id: &ChannelId, ) -> Option<&mut Channel>

Convenience method to return a mutable reference to a Channel with a given ChannelId.

Source

pub fn get_account_safe_token_balance( &self, chain_key: &ChainAddress, ) -> Option<&HoprBalance>

Convenience method to return a reference to Safe balance corresponding to the given ChainAddress of the Account.

Source

pub fn get_account_safe_token_balance_mut( &mut self, chain_key: &ChainAddress, ) -> Option<&mut HoprBalance>

Convenience method to return a mutable reference to Safe balance corresponding to the given ChainAddress of the Account.

Source

pub fn get_account_safe_native_balance( &self, chain_key: &ChainAddress, ) -> Option<&NativeBalance>

Convenience method to return a reference to the Safe’s native balance corresponding to the given ChainAddress of the Account.

Source

pub fn get_account_safe_native_balance_mut( &mut self, chain_key: &ChainAddress, ) -> Option<&mut NativeBalance>

Convenience method to return a mutable reference to the Safe’s native balance corresponding to the given ChainAddress of the Account.

Source

pub fn get_account_safe_allowance( &self, chain_key: &ChainAddress, ) -> Option<&SafeHoprAllowance>

Convenience method to return a reference to Safe allowance corresponding to the given ChainAddress of the Account.

Source

pub fn get_account_safe_allowance_mut( &mut self, chain_key: &ChainAddress, ) -> Option<&mut SafeHoprAllowance>

Convenience method to return a mutable reference to Safe allowance corresponding to the given ChainAddress of the Account.

Source

pub fn get_safe_redeem_stats( &self, chain_address: &ChainAddress, ) -> Option<&RedeemedStats>

Gets RedeemedStats for the given Safe address.

Source

pub fn get_safe_redeem_stats_mut( &mut self, chain_address: &ChainAddress, ) -> Option<&mut RedeemedStats>

Gets RedeemedStats for the given Safe address by mutable reference.

Source

pub fn get_safe_by_owner(&self, owner: &ChainAddress) -> Vec<&Safe>

Convenience method to return references to Safes with the given owner’s ChainAddress.

Source

pub fn get_safe_by_owner_mut(&mut self, owner: &ChainAddress) -> Vec<&mut Safe>

Convenience method to return mutable references to Safes with the given owner’s ChainAddress.

Trait Implementations§

Source§

impl AsRef<BlokliTestState> for BlokliTestStateSnapshot

Source§

fn as_ref(&self) -> &BlokliTestState

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for BlokliTestState

Source§

fn clone(&self) -> BlokliTestState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BlokliTestState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BlokliTestState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for BlokliTestState

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for BlokliTestState

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for BlokliTestState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IsFieldType<T> for T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more