Trait era_test_node::namespaces::EvmNamespaceT
source · pub trait EvmNamespaceT: Sized + Send + Sync + 'static {
// Required methods
fn increase_time(&self, time_delta_seconds: u64) -> RpcResult<u64>;
fn evm_mine(&self) -> RpcResult<String>;
fn set_next_block_timestamp(&self, timestamp: u64) -> RpcResult<u64>;
fn set_time(&self, time: u64) -> RpcResult<i128>;
fn snapshot(&self) -> RpcResult<U64>;
fn revert_snapshot(&self, snapshot_id: U64) -> RpcResult<bool>;
// Provided method
fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M> { ... }
}
Required Methods§
sourcefn increase_time(&self, time_delta_seconds: u64) -> RpcResult<u64>
fn increase_time(&self, time_delta_seconds: u64) -> RpcResult<u64>
Increase the current timestamp for the node
Parameters
time_delta
: The number of seconds to increase time by
Returns
The applied time delta to current_timestamp
value for the InMemoryNodeInner.
sourcefn evm_mine(&self) -> RpcResult<String>
fn evm_mine(&self) -> RpcResult<String>
Force a single block to be mined.
Will mine an empty block (containing zero transactions)
Returns
The string “0x0”.
sourcefn set_next_block_timestamp(&self, timestamp: u64) -> RpcResult<u64>
fn set_next_block_timestamp(&self, timestamp: u64) -> RpcResult<u64>
Set the current timestamp for the node. The timestamp must be in future.
Parameters
timestamp
: The timestamp to set the time to
Returns
The new timestamp value for the InMemoryNodeInner.
sourcefn set_time(&self, time: u64) -> RpcResult<i128>
fn set_time(&self, time: u64) -> RpcResult<i128>
Set the current timestamp for the node. Warning: This will allow you to move backwards in time, which may cause new blocks to appear to be mined before old blocks. This will result in an invalid state.
Parameters
time
: The timestamp to set the time to
Returns
The difference between the current_timestamp
and the new timestamp for the InMemoryNodeInner.
sourcefn snapshot(&self) -> RpcResult<U64>
fn snapshot(&self) -> RpcResult<U64>
Snapshot the state of the blockchain at the current block. Takes no parameters. Returns the id of the snapshot that was created. A snapshot can only be reverted once. After a successful evm_revert, the same snapshot id cannot be used again. Consider creating a new snapshot after each evm_revert if you need to revert to the same point multiple times.
Returns
The U64
identifier for this snapshot.
sourcefn revert_snapshot(&self, snapshot_id: U64) -> RpcResult<bool>
fn revert_snapshot(&self, snapshot_id: U64) -> RpcResult<bool>
Revert the state of the blockchain to a previous snapshot. Takes a single parameter, which is the snapshot id to revert to. This deletes the given snapshot, as well as any snapshots taken after (e.g.: reverting to id 0x1 will delete snapshots with ids 0x1, 0x2, etc.)
Parameters
snapshot_id
: The snapshot id to revert.
Returns
true
if a snapshot was reverted, otherwise false
.
Provided Methods§
sourcefn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
Create an IoDelegate
, wiring rpc calls to the trait methods.