description |
---|
GUI provides methods related to chain interactions |
Spawns a forked network using Foundry's Anvil using a specific chain ID and (optionally) a block number. If you do not specify a block number, the test will run at the current block.
chainId
- The network chain ID to forkforkBlockNumber
- The block number to fork from (optional)
// Creates a fork of Ethereum mainnet at block 17110784
await gui.initializeChain(1, 17110784)
Sets the allowance of an address to spend the test wallet's ERC20 tokens to a specific amount.
token
- The designated token address for balance allocation (e.g. USDC on Ethereum is 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48)spenderAddress
- The address to authorize for spending the tokens in the test wallet.amount
- The amount to be approved to be spent by the spender. This needs to have the appropriate number of decimals (i.e. 1 ETH is "1000000000000000000")
// Gives the Olympus staking contract approval to spend 1 OHM
await gui.setAllowance("0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5", "0xb63cac384247597756545b500253ff8e607a8020", "1000000000");
Sets an ERC20 token's balance for the test wallet.
token
- The designated token address for balance allocation.amount
- The amount of tokens to give the test wallet. This needs to have the appropriate number of decimals (i.e. 1 ETH is "1000000000000000000")
// Gives the test wallet 1 OHM
await gui.setBalance("0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5", "1000000000");
Sets the test wallet's ETH balance to a specific amount.
amount
- The amount of ETH to give to the test wallet. This needs to have the appropriate number of decimals (i.e. 1 ETH is "1000000000000000000")
// Gives the test wallet 1 ETH
await gui.setEthBalance("1000000000000000000");
Arbitrarily sets a storage slot on a contract to a specific value.
contract
- The contract address to set the storage slot onslot
- The keccak256'd storage slot to setvalue
- The assigned value for the storage slot
// Sets the first storage slot on the WETH contract to 1
const storageSlot = ethers.utils.solidityKeccak256(["uint256"], 1);
const value = ethers.utils.hexlify(1);
await gui.setContractStorageSlot("0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", storageSlot, value);
Checks that the eth_sendTransaction
or eth_sendRawTransaction
request following a button click is interacting with the correct contract or providing approval to the correct contract.
locator
- The Playwright locator string of the button to clicktargetContract
- The contract address the button should trigger an interaction with
// Validates that the Olympus "stake" button triggers an interaction with the staking contract
await gui.validateContractInteraction("[data-testid='submit-modal-button']", "0xb63cac384247597756545b500253ff8e607a8020");