Constructs a simulator testbed instance with or without given scenario
Optionalscenario: TransactionObj[]The initial scenario to be used.
Leaky abstraction that provides access to the underlying blockchain object
Retrieves the account with the specified account ID.
The ID of the account to retrieve.
The account with the specified ID, or undefined if no account is found.
Returns all contracts deployed on the simulated blockchain.
All deployed contracts.
Retrieves the maps per contract.
Optionaladdress: bigintThe contract address (default: the last deployed).
The maps per contract.
Retrieves a value from a map per slot.
1st Key
2nd Key
Optionaladdress: bigintThe contract address (default: the last deployed).
The value or 0 if not exists.
Retrieves a list of (key-value)-tuples from a map per slot.
1st Key
Optionaladdress: bigintThe contract address (default: the last deployed).
The value or 0 if not exists.
Retrieves the contract memory for a given slot.
Optionaladdress: bigintThe contract address (default: the last deployed).
An array of MemoryObj representing the contract memory.
Retrieves the value of a contract memory variable by name, e.g. myvalue or inside a function func_myvalue
The name of the variable to retrieve.
Optionaladdress: bigintThe contract address (default: the last deployed).
Returns a single transaction by Index
Index of transaction (not Id!), must not be negative nor greater than the transaction list
Returns a single transaction by Id
Transaction Id
Return an array of BlockchainTransactionObj representing the transactions in the blockchain.
Retrieves all the transactions sent by the contract at a given height. Nice to get contract responses.
The blockheight of transactions to fetch.
Optionaladdress: bigintThe contract address (default: the last deployed).
An array of MemoryObj representing the contract memory.
Loads a contract from the specified code path with optional creator, contractId, and initializers.
The last loaded contract becomes the active contract, which is the default target for getContract, getContractMap, and sendTransactionAndGetResponse when called without an explicit address. In multi-contract setups, load helper/dependency contracts first and the contract under test last so it is active by default.
The path to the SmartC code file.
Optionaloptions: LoadContractOptionsOptional creator (default: 555n), contractId (default: auto-incremented), and initializers.
The simulator testbed with the loaded contract.
Runs a scenario by simulating a series of user transactions.
The array of user transactions representing the scenario.
Updates the current contract to the contract at the specified address.
The contract address to select. Throws error if contract is not found.
Sends the argument transactions at the next blockheight and returns all transactions from the selected contract in the subsequent height. Input transactions are modified to match blockheight and contract address. This method forges two blocks in order to get the response.
Transactions to send.
Optionaladdress: bigintThe target contract address (default: the last deployed).
An array of transactions, or empty array if no one was found.
Simulator Testbed Class
Use this class to run scenarios against the simulator.
Example
INITIALIZE CONTRACT
To initialize variables in the contract you can use the
initializerparameter when loading the contract.To apply initialization a code injection is needed and requires the developer to use defines pre-pended with TESTBED_ source code, i.e.
You may load the contract into the testbed as follows:
This testbed loads a SmartC Contract and a scenario (set of transactions) and forges all necessary blocks. It's possible to inspect all the results, i.e. transactions, kkv-maps, accounts, in-memory variables, and test them against expected result sets. This class is meant to be used with Test Runners like Vitest or Jest.