soroban_sdk/testutils/storage.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
use crate::{Env, IntoVal, Map, Val};
/// Test utilities for [`Persistent`][crate::storage::Persistent].
pub trait Persistent {
/// Returns all data stored in persistent storage for the contract.
fn all(&self) -> Map<Val, Val>;
/// Gets the TTL for the persistent storage entry corresponding to the provided key.
///
/// TTL is the number of ledgers left until the persistent entry is considered
/// expired, excluding the current ledger.
///
/// Panics if there is no entry corresponding to the key, or if the entry has expired.
fn get_ttl<K: IntoVal<Env, Val>>(&self, key: &K) -> u32;
}
/// Test utilities for [`Temporary`][crate::storage::Temporary].
pub trait Temporary {
/// Returns all data stored in temporary storage for the contract.
fn all(&self) -> Map<Val, Val>;
/// Gets the TTL for the temporary storage entry corresponding to the provided key.
///
/// TTL is the number of ledgers left until the temporary entry is considered
/// non-existent, excluding the current ledger.
///
/// Panics if there is no entry corresponding to the key.
fn get_ttl<K: IntoVal<Env, Val>>(&self, key: &K) -> u32;
}
/// Test utilities for [`Instance`][crate::storage::Instance].
pub trait Instance {
/// Returns all data stored in Instance storage for the contract.
fn all(&self) -> Map<Val, Val>;
/// Gets the TTL for the current contract's instance entry.
///
/// TTL is the number of ledgers left until the instance entry is considered
/// expired, excluding the current ledger.
fn get_ttl(&self) -> u32;
}