pub struct TestEnvironmentBuilder { /* private fields */ }Expand description
Builder for a TestEnvironment that needs something other than the
stock chain settings.
The plain constructors (TestEnvironment::new,
no_cost, and the rest) cover the ordinary
case and are unaffected by this type. Reach for the builder when a test
wants to drive contract behavior that a network config parameter
governs – what a contract does as it approaches a cap the chain sets,
which is otherwise only observable on a chain configured that way:
use thruput_native_exec::test_environment::TestEnvironment;
let env = TestEnvironment::builder()
.no_cost()
.with_max_sha256_buffers(2)
.build();Every setter is optional and independent; an unset one keeps what
TestEnvironment::new would have used, and unstated config
parameters keep their stock values (see
stock_network_config).
A builder with no configuration overrides at all creates its database
exactly as the plain constructors do. A parameter setter needs a hogd
build that knows the parameter; see NetworkConfigBuilder.
Implementations§
Source§impl TestEnvironmentBuilder
impl TestEnvironmentBuilder
Sourcepub fn with_cost_model(self, cost_model: StorageCostModel) -> Self
pub fn with_cost_model(self, cost_model: StorageCostModel) -> Self
Charge storage against cost_model instead of the chain default.
Sourcepub fn no_cost(self) -> Self
pub fn no_cost(self) -> Self
Make every storage operation free, as
TestEnvironment::no_cost does.
Sourcepub fn with_network_hash(self, network_hash: NetworkHash) -> Self
pub fn with_network_hash(self, network_hash: NetworkHash) -> Self
Run on network_hash instead of test_network_hash.
The network hash is part of every transaction signature preimage, so pin it when a test’s signatures were produced for a specific network.
Sourcepub fn with_genesis_root_contract(self, contract: Contract) -> Self
pub fn with_genesis_root_contract(self, contract: Contract) -> Self
Install contract as the genesis root deployment instead of
mock_genesis_root_contract.
Sourcepub fn with_network_config(self, config: NetworkConfig) -> Self
pub fn with_network_config(self, config: NetworkConfig) -> Self
Apply the parameter setters below to config rather than to the
stock configuration.
This is the whole-configuration escape hatch: pass one read back off another environment, or one built by hand. Anything the setters do not restate is taken from it verbatim.
Sourcepub fn with_config_param(self, param: ConfigParam) -> Self
pub fn with_config_param(self, param: ConfigParam) -> Self
State one config parameter the typed setters below do not cover.
Sourcepub fn with_max_sha256_buffers(self, max_sha256_buffers: u32) -> Self
pub fn with_max_sha256_buffers(self, max_sha256_buffers: u32) -> Self
Concurrently open incremental SHA-256 buffers permitted per invocation
frame (the cap thruput_sdk::Hasher allocates against).
Sourcepub fn with_max_cross_invoke_depth(self, max_cross_invoke_depth: u32) -> Self
pub fn with_max_cross_invoke_depth(self, max_cross_invoke_depth: u32) -> Self
Invocation frames one transaction may have open at once.
The harness opens its frames directly, so one the executor refuses is
an unrecoverable panic rather than the error a contract would observe.
To assert on the cap, have the frame call through the Invoke syscall
(thruput_sdk::call::try_call_raw_with), which reports it as
RawCallError::DepthExceeded.
Sourcepub fn with_max_new_contracts_per_tx(
self,
max_new_contracts_per_tx: u32,
) -> Self
pub fn with_max_new_contracts_per_tx( self, max_new_contracts_per_tx: u32, ) -> Self
Contracts one transaction may attach in contracts_to_deploy.
Sourcepub fn with_max_bytestring_len(self, max_bytestring_len: u32) -> Self
pub fn with_max_bytestring_len(self, max_bytestring_len: u32) -> Self
Bytes one bytestring storage item may hold.
Sourcepub fn with_max_contract_size_bytes(self, max_contract_size_bytes: u32) -> Self
pub fn with_max_contract_size_bytes(self, max_contract_size_bytes: u32) -> Self
Bytes one attached contract’s code blob (ContractBlob.data) may
hold, checked before any attached contract is verified or executed.
Sourcepub fn with_max_savepoint_depth(self, max_savepoint_depth: u32) -> Self
pub fn with_max_savepoint_depth(self, max_savepoint_depth: u32) -> Self
Storage savepoints one transaction may have open at once: one per
TryInvoke frame still executing, plus the one the root commit
takes.
Sourcepub fn with_max_sha256_buffer_bytes(self, max_sha256_buffer_bytes: u32) -> Self
pub fn with_max_sha256_buffer_bytes(self, max_sha256_buffer_bytes: u32) -> Self
Bytes one incremental SHA-256 buffer may absorb between resets, the
per-buffer companion of
with_max_sha256_buffers.
Sourcepub fn with_max_auth_token_depth(self, max_auth_token_depth: u32) -> Self
pub fn with_max_auth_token_depth(self, max_auth_token_depth: u32) -> Self
Levels of AuthTokenNode nesting an auth token may carry, counted
from its root.
Sourcepub fn with_max_rv32_code_bytes(self, max_rv32_code_bytes: u32) -> Self
pub fn with_max_rv32_code_bytes(self, max_rv32_code_bytes: u32) -> Self
Bytes of code (code_size in the artifact header) an RV32 artifact
may carry to be attached as a contract.
Sourcepub fn with_max_rv32_memory_bytes(self, max_rv32_memory_bytes: u32) -> Self
pub fn with_max_rv32_memory_bytes(self, max_rv32_memory_bytes: u32) -> Self
Bytes of guest data memory (memory_bytes in the artifact header)
an RV32 artifact may declare to be attached as a contract.
Sourcepub fn build(self) -> TestEnvironmentHandle
pub fn build(self) -> TestEnvironmentHandle
Create the configured environment.