Constructs a simulator testbed instance with or without given scenario
Optional
scenario: TransactionObj[]The initial scenario to be used.
Private
nodeLeaky abstraction that provides access to the underlying blockchain object
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.
Optional
address: bigintThe contract address (default: the last deployed).
Retrieves all the transactions sent by the contract at a given height. Nice to get contract responses.
The blockheight of transactions to fetch.
Optional
address: bigintThe contract address (default: the last deployed).
An array of MemoryObj representing the contract memory.
Private
injectLoads a contract from the specified code path and eventually initializes the contract with the provided initializers
The path to the SmartC code file.
Optional
initializers: Record<string, string | number | bigint>The initializer object for the contract - Initialization is prepended.
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.
Optional
address: bigintThe target contract address (default: the last deployed).
An array of transactions, or empty array if no one was found.
Static
Private
to
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
initializer
parameter 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.