Struct concordium_std::test_infrastructure::TestContext
source · [−]pub struct TestContext<'a, C> { /* private fields */ }
Expand description
Context used for testing. The type parameter C is used to determine whether this will be an init or receive context.
Implementations
sourceimpl<'a, C> TestContext<'a, C>
impl<'a, C> TestContext<'a, C>
sourcepub fn push_policy(&mut self, value: OwnedPolicy) -> &mut Self
pub fn push_policy(&mut self, value: OwnedPolicy) -> &mut Self
Push a new sender policy to the context. When the first policy is pushed this will set the policy vector to ‘Some’, even if it was undefined previously.
sourcepub fn empty_policies(&mut self) -> &mut Self
pub fn empty_policies(&mut self) -> &mut Self
Set the policies to be defined, but an empty list. Such a situation can not realistically happen on the chain, but we provide functionality for it in case smart contract writers wish to program defensively.
pub fn set_parameter(&mut self, value: &'a [u8]) -> &mut Self
sourcepub fn metadata_mut(&mut self) -> &mut TestChainMeta
pub fn metadata_mut(&mut self) -> &mut TestChainMeta
Get a mutable reference to the chain meta data placeholder
sourcepub fn set_metadata_slot_time(&mut self, value: SlotTime) -> &mut Self
pub fn set_metadata_slot_time(&mut self, value: SlotTime) -> &mut Self
Set the metadata block slot time
sourceimpl<'a> TestContext<'a, TestInitOnlyData>
impl<'a> TestContext<'a, TestInitOnlyData>
sourcepub fn empty() -> Self
pub fn empty() -> Self
Create an TestInitContext
where every field is unset, and getting any
of the fields will result in fail!
.
sourcepub fn set_init_origin(&mut self, value: AccountAddress) -> &mut Self
pub fn set_init_origin(&mut self, value: AccountAddress) -> &mut Self
Set init_origin
in the TestInitContext
sourceimpl<'a> TestContext<'a, TestReceiveOnlyData>
impl<'a> TestContext<'a, TestReceiveOnlyData>
sourcepub fn empty() -> Self
pub fn empty() -> Self
Create a TestReceiveContext
where every field is unset, and getting
any of the fields will result in fail!
.
pub fn set_invoker(&mut self, value: AccountAddress) -> &mut Self
pub fn set_self_address(&mut self, value: ContractAddress) -> &mut Self
pub fn set_sender(&mut self, value: Address) -> &mut Self
pub fn set_owner(&mut self, value: AccountAddress) -> &mut Self
pub fn set_named_entrypoint(&mut self, value: OwnedEntrypointName) -> &mut Self
Trait Implementations
sourceimpl<'a, C: Clone> Clone for TestContext<'a, C>
impl<'a, C: Clone> Clone for TestContext<'a, C>
sourcefn clone(&self) -> TestContext<'a, C>
fn clone(&self) -> TestContext<'a, C>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<'a, C: Default> Default for TestContext<'a, C>
impl<'a, C: Default> Default for TestContext<'a, C>
sourcefn default() -> TestContext<'a, C>
fn default() -> TestContext<'a, C>
Returns the “default value” for a type. Read more
sourceimpl<'a, C> HasCommonData for TestContext<'a, C>
impl<'a, C> HasCommonData for TestContext<'a, C>
type MetadataType = TestChainMeta
type ParamType = TestParameterCursor<'a>
type PolicyIteratorType = IntoIter<TestPolicy, Global>
type PolicyType = TestPolicy
sourcefn parameter_cursor(&self) -> Self::ParamType
fn parameter_cursor(&self) -> Self::ParamType
Get the cursor to the parameter.
sourcefn metadata(&self) -> &Self::MetadataType
fn metadata(&self) -> &Self::MetadataType
Get the reference to chain metadata
sourcefn policies(&self) -> Self::PolicyIteratorType
fn policies(&self) -> Self::PolicyIteratorType
Policies of the sender of the message. For init methods this is the would-be creator of the contract, for the receive this is the policies of the immediate sender. Read more
Auto Trait Implementations
impl<'a, C> RefUnwindSafe for TestContext<'a, C> where
C: RefUnwindSafe,
impl<'a, C> !Send for TestContext<'a, C>
impl<'a, C> !Sync for TestContext<'a, C>
impl<'a, C> Unpin for TestContext<'a, C> where
C: Unpin,
impl<'a, C> UnwindSafe for TestContext<'a, C> where
C: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more