pub struct TestEnvironment { /* private fields */ }Expand description
Test environment for Neo N3 contract testing
Implementations§
Source§impl TestEnvironment
impl TestEnvironment
pub fn new() -> Self
pub fn with_runtime(self, runtime: MockRuntime) -> Self
pub fn runtime(&self) -> &MockRuntime
pub fn runtime_mut(&mut self) -> &mut MockRuntime
pub fn set_storage(&mut self, key: &[u8], value: &[u8])
pub fn get_storage_context(&mut self) -> MockStorageContext
pub fn get_read_only_storage_context(&mut self) -> MockStorageContext
pub fn put_storage_with_context( &mut self, context: &MockStorageContext, key: &[u8], value: &[u8], ) -> Result<(), NeoError>
pub fn delete_storage_with_context( &mut self, context: &MockStorageContext, key: &[u8], ) -> Result<(), NeoError>
pub fn get_storage(&self, key: &[u8]) -> Option<Vec<u8>>
pub fn delete_storage(&mut self, key: &[u8])
pub fn set_trigger(&mut self, trigger: i32)
pub fn set_time(&mut self, time: i64)
pub fn set_network(&mut self, network: i64)
pub fn add_witness(&mut self, address: &[u8])
pub fn check_witness(&self, address: &[u8]) -> bool
pub fn add_log(&mut self, message: &str)
pub fn logs(&self) -> &[String]
pub fn clear_logs(&mut self)
pub fn assert_runtime(&self) -> RuntimeAssertions<'_>
pub fn assert_storage(&self) -> StorageAssertions<'_>
Sourcepub fn call_method<F, R>(&self, name: &str, args: &[NeoValue], f: F) -> Rwhere
F: FnOnce() -> R,
pub fn call_method<F, R>(&self, name: &str, args: &[NeoValue], f: F) -> Rwhere
F: FnOnce() -> R,
Run a contract method against this mock environment under a readable label, returning its result.
This is the unit / logic testing layer: f invokes your contract
method natively (host execution) so it reads/writes this environment’s
mock storage and runtime. name/args document the call and appear in
failure diagnostics; they do not dispatch (native Rust calls are
type-checked directly).
To execute the translated NeoVM bytecode on a real VM instead — the
equivalent of Solana’s solana-program-test — use the neo-vm-test
crate’s Contract::compile(..).invoke(..).
pub fn deploy(&mut self, script: &[u8], manifest: &[u8]) -> TestResult
pub fn update(&mut self, script: &[u8]) -> TestResult
pub fn update_with_manifest( &mut self, script: &[u8], manifest: &[u8], ) -> TestResult
pub fn destroy(&mut self) -> TestResult
pub fn is_deployed(&self) -> bool
pub fn deployed_script(&self) -> Option<&[u8]>
pub fn deployed_manifest(&self) -> Option<&[u8]>
pub fn reset(&mut self)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TestEnvironment
impl RefUnwindSafe for TestEnvironment
impl Send for TestEnvironment
impl Sync for TestEnvironment
impl Unpin for TestEnvironment
impl UnsafeUnpin for TestEnvironment
impl UnwindSafe for TestEnvironment
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
Mutably borrows from an owned value. Read more