lighter.testing
Documentation for eth_defi.lighter.testing Python module.
Anvil-fork test helpers for the Lighter guard integration.
This module holds only the test-specific deployment helper; the library
deployment and whitelisting come from eth_defi.lighter.deployment so
production and tests share one code path.
See eth_defi/lighter/README-lighter-guard.md and
tests/guard/test_guard_lighter_lagoon.py.
Functions
|
Deploy |
|
Anvil override: forge an L1 Lighter account registration for |
- deploy_lighter_simple_vault(web3, deployer, asset_manager, owner, lighter_lib)
Deploy
SimpleVaultV0withLighterLiblinked (other libs zeroed).Mirrors the Hypercore test fixture: only the library under test gets a real address, the rest stay
ZERO_ADDRESSfromGUARD_LIBRARIES. The library itself is deployed viadeploy_lighter_lib().- Parameters
web3 (web3.main.Web3) – Web3 connection (Anvil fork).
deployer (Union[eth_typing.evm.HexAddress, str]) – Deployer address (becomes the initial owner before transfer).
asset_manager (Union[eth_typing.evm.HexAddress, str]) – Asset manager address (the allowed guard sender).
owner (Union[eth_typing.evm.HexAddress, str]) – Final guard owner (typically the Safe / governance).
lighter_lib (web3.contract.contract.Contract) – Deployed
LighterLibcontract to link.
- Returns
The deployed
SimpleVaultV0contract.- Return type
web3.contract.contract.Contract
- register_lighter_account_on_anvil(web3, owner, account_index, zk_lighter='0x3B4D794a66304F130a4Db8F2551B0070dfCf5ca7')
Anvil override: forge an L1 Lighter account registration for
owner.Calls bound to the caller’s registered account —
withdrawandchangePubKey— readmasterAccountIndex = validateAndGetAccountIndexFromAddress(msg.sender)and revertAccountIsNotRegisteredif the caller has no account. Registration normally happens off-chain (a Safe signature) plus an L2 state update, which cannot be reproduced on a fork. This writesZkLighter’saddressToAccountIndex[owner] = account_indexmapping slot directly withanvil_setStorageAtso those calls can be exercised end-to-end.- Parameters
web3 (web3.main.Web3) – Web3 connection (Anvil fork).
owner (Union[eth_typing.evm.HexAddress, str]) – Address to register (e.g. the vault’s Safe).
account_index (int) – Lighter account index to assign (must be non-zero and below
MAX_ACCOUNT_INDEX).zk_lighter (Union[eth_typing.evm.HexAddress, str]) – The
ZkLighterL1 contract address.
- Return type
None