Documentation
¶
Index ¶
- Constants
- Variables
- func All(t *testing.T, testFunc func(ctx context.Context, t *testing.T, db *gorm.DB))
- func AnvilFunderKey(t *testing.T) *ecdsa.PrivateKey
- func AnvilImpersonate(t *testing.T, rpcURL string, addr common.Address)
- func EscapePath(p string) string
- func FundEVMWallet(t *testing.T, rpcURL string, to common.Address, amount *big.Int) common.Hash
- func GenerateFixedBytes(length int) []byte
- func GenerateRandomBytes(n int) []byte
- func GenerateTestKey(t *testing.T) (*ecdsa.PrivateKey, common.Address)
- func GenerateUniqueName(prefix string) string
- func GetFileTimestamp(t *testing.T, path string) int64
- func One(t *testing.T, testFunc func(ctx context.Context, t *testing.T, db *gorm.DB))
- func OneWithoutReset(t *testing.T, testFunc func(ctx context.Context, t *testing.T, db *gorm.DB))
- func ReadContractOwner(t *testing.T, rpcURL string, contractAddr common.Address) common.Address
- func RegisterActorID(t *testing.T, rpcURL string, evmAddr common.Address, actorID uint64)
- func SendImpersonatedTx(t *testing.T, rpcURL string, from, to common.Address, data []byte) common.Hash
- func SetupFVMPrecompiles(t *testing.T, rpcURL string)
- func SkipIfNotExternalAPI(t *testing.T)
- func TransferERC20(t *testing.T, rpcURL string, tokenAddr, recipient common.Address, ...)
- type AnvilInstance
- type CloserFunc
Constants ¶
const ( CalibnetChainID = 314159 CalibnetDDOContract = "0x889fD50196BE300D06dc4b8F0F17fdB0af587095" CalibnetPaymentsContract = "0x09a0fDc2723fAd1A7b8e3e00eE5DF73841df55a0" CalibnetUSDFC = "0xb3042734b608a1B16e9e86B374A3f3e389B4cDf0" // CalibnetDDOProviderActorID is the FF calibnet miner t0178773. CalibnetDDOProviderActorID uint64 = 178773 )
const TestPrivateKeyHex = "" /* 160-byte string literal not displayed */
const TestWalletAddr = "f1fib3pv7jua2ockdugtz7viz3cyy6lkhh7rfx3sa"
Variables ¶
var ( FVMResolveAddress = common.HexToAddress("0xfe00000000000000000000000000000000000001") FVMCallActorByAddress = common.HexToAddress("0xfe00000000000000000000000000000000000003") FVMCallActorByID = common.HexToAddress("0xfe00000000000000000000000000000000000005") )
var CalibnetRPC = envOr("SINGULARITY_TEST_CALIBNET_RPC", "https://static.187.115.235.167.clients.your-server.de/calibnet/rpc/v1")
CalibnetRPC defaults to the self-hosted forest gateway; glif rate-limited CI.
OneEther is 1e18 wei, useful as a unit for test funding amounts.
var SupportedTestDialects = []string{"sqlite", "postgres"}
var TestLotusAPI = envOr("SINGULARITY_TEST_LOTUS_API", "https://static.187.115.235.167.clients.your-server.de/rpc/v1")
TestLotusAPI defaults to the self-hosted forest gateway; glif rate-limited CI.
var TestLotusToken = os.Getenv("FOREST_JWT")
TestLotusToken is the bearer token for the forest gateway; empty in local dev and on fork PRs (see SkipIfNotExternalAPI).
Functions ¶
func AnvilFunderKey ¶ added in v1.0.0
func AnvilFunderKey(t *testing.T) *ecdsa.PrivateKey
AnvilFunderKey returns the parsed private key for Anvil's first pre-funded account.
func AnvilImpersonate ¶ added in v1.0.0
AnvilImpersonate enables Anvil's impersonation for the given address, allowing transactions to be sent from it without a private key.
func EscapePath ¶ added in v0.4.0
func FundEVMWallet ¶ added in v1.0.0
FundEVMWallet sends ETH from Anvil's pre-funded account 0 to the given address. amount is in wei. Anvil automines the tx immediately.
func GenerateFixedBytes ¶ added in v0.4.0
func GenerateRandomBytes ¶
func GenerateTestKey ¶ added in v1.0.0
GenerateTestKey creates a fresh ECDSA key pair for testing and returns the private key and its corresponding EVM address.
func GenerateUniqueName ¶ added in v1.0.0
GenerateUniqueName creates a unique name for testing by combining a prefix with a UUID suffix
func OneWithoutReset ¶ added in v0.4.0
func ReadContractOwner ¶ added in v1.0.0
ReadContractOwner reads the Diamond contract owner by calling the owner() function.
func RegisterActorID ¶ added in v1.0.0
RegisterActorID adds an EVM address -> actor ID mapping to the mocked RESOLVE_ADDRESS precompile using the Filecoin delegated-address encoding.
func SendImpersonatedTx ¶ added in v1.0.0
func SendImpersonatedTx(t *testing.T, rpcURL string, from, to common.Address, data []byte) common.Hash
SendImpersonatedTx sends a transaction from an impersonated account via Anvil's eth_sendTransaction and waits for the receipt. The caller must have already called AnvilImpersonate for the from address.
func SetupFVMPrecompiles ¶ added in v1.0.0
SetupFVMPrecompiles deploys narrow Filecoin precompile mocks on an Anvil fork.
These mocks are useful for tests that would otherwise revert on empty Filecoin precompile addresses. They cover address resolution plus minimal actor-call happy paths, but they do not emulate DataCap / VerifReg flows end-to-end.
func SkipIfNotExternalAPI ¶ added in v1.0.0
SkipIfNotExternalAPI skips the test if external API access isn't configured. Two conditions must hold: SINGULARITY_TEST_EXTERNAL_API opts in, and either FOREST_JWT is set or one of the endpoint overrides (SINGULARITY_TEST_LOTUS_API / SINGULARITY_TEST_CALIBNET_RPC) points at something that doesn't need the gateway's bearer auth. Fork PRs and local devs without a token skip cleanly instead of hitting a 401.
func TransferERC20 ¶ added in v1.0.0
func TransferERC20(t *testing.T, rpcURL string, tokenAddr, recipient common.Address, amount *big.Int)
TransferERC20 sends ERC20 tokens from Anvil's pre-funded account 0 to a recipient. This works because account 0 already has a real private key (the well-known Anvil test key).
Types ¶
type AnvilInstance ¶ added in v1.0.0
type AnvilInstance struct {
RPCURL string
// contains filtered or unexported fields
}
func StartAnvil ¶ added in v1.0.0
func StartAnvil(t *testing.T, upstreamRPC string) *AnvilInstance
StartAnvil forks the given upstream RPC on a random free port. Returns when the fork is ready to accept connections.
func (*AnvilInstance) Close ¶ added in v1.0.0
func (a *AnvilInstance) Close()
func (*AnvilInstance) MineBlock ¶ added in v1.0.0
func (a *AnvilInstance) MineBlock(t *testing.T)
MineBlock forces anvil to produce a block. In automine mode (default), blocks are mined on tx submission, but consumers that only read (e.g. Shovel) need an explicit nudge to see chain progress.
type CloserFunc ¶ added in v0.4.0
type CloserFunc func() error
func (CloserFunc) Close ¶ added in v0.4.0
func (f CloserFunc) Close() error