helpers

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const Anvil0SKHex = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"

Anvil0SKHex is Anvil account #0 secret (must match contracts/mcms/src/test.rs ANVIL_SK_0).

View Source
const DefaultMCMSTimelockMinDelaySec uint64 = 3
View Source
const STELLAR_LOCALNET_PASSPHRASE = "Standalone Network ; February 2017"

Sha256 hash of the network passphrase

Variables

This section is empty.

Functions

func ChainNetworkIDFromHex

func ChainNetworkIDFromHex(chainIDHex string) ([32]byte, error)

ChainNetworkIDFromHex parses a 32-byte Stellar chain network id from hex (e.g. chain-selectors ChainID).

func CleanupMCMSTestPool

func CleanupMCMSTestPool(
	t *testing.T,
	ctx context.Context,
	env *E2ETestEnv,
	gov *MCMSGovernanceStack,
	poolContractID string,
	poolRaw [32]byte,
	remoteSelector uint64,
	deployerAddr string,
	predecessor, saltTransfer [32]byte,
)

CleanupMCMSTestPool restores the shared devenv lock-release pool after MCMS e2e tests. Assumes the timelock owns the pool and outbound rate limits are enabled: transfers ownership back to the deployer via MCMS, deployer accept_ownership, then disables rate limits directly. Errors are logged but do not fail the test (runs from t.Cleanup).

func ContractIDToBytes32

func ContractIDToBytes32(contractID string) ([32]byte, error)

ContractIDToBytes32 decodes a Soroban contract strkey into a 32-byte contract id.

func CurseChain

func CurseChain(t *testing.T, env *cldfdeployment.Environment, chainSelector, subjectChainSelector uint64)

CurseChain curses a subject chain from the perspective of the given chain using fastcurse changeset. This replaces the deprecated Chain.Curse() method.

func EncodeTimelockInvokePayload

func EncodeTimelockInvokePayload(functionName string, argScVals []xdr.ScVal) ([]byte, error)

EncodeTimelockInvokePayload builds timelock Call.data for a Soroban contract function invocation.

func EthSignedMessageHash32

func EthSignedMessageHash32(digest [32]byte) [32]byte

EthSignedMessageHash32 returns keccak256(EIP-191 prefix || digest) for a 32-byte payload (contracts/mcms EIP-191 path).

func FindProjectRoot

func FindProjectRoot(t *testing.T) string

FindProjectRoot finds the root of the chainlink-stellar project.

func FindProjectRootErr

func FindProjectRootErr() (string, error)

FindProjectRootErr finds the root of the chainlink-stellar project, returning an error on failure.

func FundViaFriendbot

func FundViaFriendbot(friendbotURL, address string) error

func GenerateMockContractID

func GenerateMockContractID(t *testing.T, deployerAddress, contractName string) string

generateMockContractID generates a deterministic mock contract ID for testing.

func HashRootMetadata

func HashRootMetadata(m mcmsbindings.StellarRootMetadata) ([32]byte, error)

HashRootMetadata returns keccak256(abi.encode(D_META, StellarRootMetadata)) per contracts/mcms/src/abi_encoding.rs.

func HashSetRootInner

func HashSetRootInner(root [32]byte, validUntil uint32) [32]byte

HashSetRootInner returns keccak256(abi.encode(bytes32 root, uint32 validUntil)).

func HashStellarOp

func HashStellarOp(op mcmsbindings.StellarOp) ([32]byte, error)

HashStellarOp returns keccak256(abi.encode(D_OP, StellarOp)) per contracts/mcms/src/abi_encoding.rs.

func KeypairFromPrivateKeyHex

func KeypairFromPrivateKeyHex(t *testing.T, privateKeyHex string) *keypair.Full

func MCMSTimelockScheduleAndExecute

func MCMSTimelockScheduleAndExecute(
	t *testing.T,
	ctx context.Context,
	env *E2ETestEnv,
	gov *MCMSGovernanceStack,
	calls timelockbindings.Calls,
	predecessor, salt [32]byte,
)

MCMSTimelockScheduleAndExecute drives schedule_batch → wait → execute_batch through MCMS SetRoot + Execute (two-leaf Merkle tree, EIP-191 signing). Uses the current MCMS op count as the schedule nonce; execute uses nonce+1.

func MCMSTimelockScheduleAndExecuteErr

func MCMSTimelockScheduleAndExecuteErr(
	ctx context.Context,
	env *E2ETestEnv,
	gov *MCMSGovernanceStack,
	calls timelockbindings.Calls,
	predecessor, salt [32]byte,
) error

MCMSTimelockScheduleAndExecuteErr is the error-returning variant used by test cleanup hooks.

func MCMSValidUntilSeconds

func MCMSValidUntilSeconds(ctx context.Context, rpc *rpcclient.Client) (uint32, error)

MCMSValidUntilSeconds returns a deadline for MCMS set_root: must be >= host ledger timestamp and ≤ now + 90d (contracts/mcms MAX_ROOT_VALIDITY_SECS).

func MerkleProofTwoLeaves

func MerkleProofTwoLeaves(leaves [2][32]byte, leafIndex int) [][32]byte

MerkleProofTwoLeaves returns the sibling path for a two-leaf tree (compute_proof_for_leaf in mcms tests).

func MerkleRootTwoLeaves

func MerkleRootTwoLeaves(l0, l1 [32]byte) [32]byte

MerkleRootTwoLeaves builds the root from exactly two leaf digests (matches mcms merkle_root_native for n=2).

func PaddedEthAddress

func PaddedEthAddress(pub *ecdsa.PublicKey) [32]byte

PaddedEthAddress returns the 32-byte left-padded address form used in MCMS signer config (match Rust padded_eth_address).

func ResolveEVMTestToken

func ResolveEVMTestToken(ds datastore.DataStore, evmChainSelector uint64) (protocol.UnknownAddress, error)

ResolveEVMTestToken finds the BurnMint test token configured for EVM-to-Stellar transfers on the given EVM chain. It returns the raw token address as a protocol.UnknownAddress suitable for SendMessage.TokenAmount.TokenAddress and GetTokenBalance.

func SignaturesForSetRoot

func SignaturesForSetRoot(pk *ecdsa.PrivateKey, root [32]byte, validUntil uint32) (mcmsbindings.SignatureVec, error)

SignaturesForSetRoot signs the EIP-191 digest over hash_set_root_inner with the Anvil #0 test key (1-of-1).

func SorobanExecuteBatch

func SorobanExecuteBatch(
	caller string,
	calls timelockbindings.Calls,
	predecessor, salt [32]byte,
) ([]byte, error)

SorobanExecuteBatch encodes timelock execute_batch Call.data for MCMS StellarOp payloads.

func SorobanScheduleBatch

func SorobanScheduleBatch(
	caller string,
	calls timelockbindings.Calls,
	predecessor, salt [32]byte,
	delay uint64,
) ([]byte, error)

SorobanScheduleBatch encodes timelock schedule_batch Call.data for MCMS StellarOp payloads.

func UncurseChain

func UncurseChain(t *testing.T, env *cldfdeployment.Environment, chainSelector, subjectChainSelector uint64)

UncurseChain uncurses a subject chain from the perspective of the given chain using fastcurse changeset. This replaces the deprecated Chain.Uncurse() method.

func WaitForFriendbot

func WaitForFriendbot(ctx context.Context, friendbotBaseURL string, timeout time.Duration) error

waitForFriendbot waits for the friendbot service to be ready. The Stellar quickstart container starts multiple services and friendbot initializes after the main RPC endpoint is ready.

func WaitTimelockOperationReady

func WaitTimelockOperationReady(
	ctx context.Context,
	t *testing.T,
	tlClient *timelockbindings.TimelockClient,
	calls timelockbindings.Calls,
	predecessor, salt [32]byte,
)

WaitTimelockOperationReady polls until the scheduled timelock batch is executable.

Types

type E2ETestEnv

type E2ETestEnv struct {
	DeployerKP         *keypair.Full
	Deployer           *stellardeployment.Deployer
	RPCClient          *rpcclient.Client
	NetworkPassphrase  string
	StellarRoot        string
	DataStore          datastore.DataStore
	SourceChain        cciptestinterfaces.CCIP17
	DestChain          cciptestinterfaces.CCIP17
	SourceChainDetails *chain_selectors.ChainDetails
	DestChainDetails   *chain_selectors.ChainDetails
	Chains             map[uint64]cciptestinterfaces.CCIP17
	AggregatorClients  map[string]*ccv.AggregatorClient
	IndexerMonitor     *ccv.IndexerMonitor
	FriendbotURL       string
	CLDFEnv            *cldfdeployment.Environment
}

func NewE2ETestEnv

func NewE2ETestEnv(t *testing.T, ctx context.Context, l *zerolog.Logger, configOutputPath string, stellarChainID string, stellarSelector uint64) *E2ETestEnv

type MCMSGovernanceStack

type MCMSGovernanceStack struct {
	MCMSID         string
	TimelockID     string
	MCMSClient     *mcmsbindings.McmsClient
	TimelockClient *timelockbindings.TimelockClient
	MCMSRaw        [32]byte
	TimelockRaw    [32]byte
	ChainNetID     [32]byte
	SignerPK       *ecdsa.PrivateKey
	MinDelaySec    uint64
}

MCMSGovernanceStack holds deployed MCMS + timelock contracts wired for MCMS-mediated governance.

func DeployMCMSAndTimelock

func DeployMCMSAndTimelock(
	t *testing.T,
	ctx context.Context,
	env *E2ETestEnv,
	chainSelector uint64,
	qualifier string,
) *MCMSGovernanceStack

DeployMCMSAndTimelock deploys and initializes MCMS + RBAC timelock via CLDF operations (mcmsops/timelockops Deploy, Initialize, SetConfig), using mcmsutil WASM paths and deploy salts.

MCMS is configured as both proposer and executor on the timelock so MCMS.execute can drive schedule_batch and execute_batch (same wiring as integration TestMcmsMerkleTimelockScheduleAndExecute).

type SharedTestEnv

type SharedTestEnv struct {
	ProjectRoot       string
	DeployerKP        *keypair.Full
	Deployer          *stellardeployment.Deployer
	RPCClient         *rpcclient.Client
	NetworkPassphrase string
	FriendbotURL      string             // faucet base URL (no ?addr=), for funding issuers / SAC setup
	Output            *blockchain.Output // for teardown
}

SharedTestEnv holds the result of SetupTestEnvShared for use across multiple integration tests.

func SetupTestEnvShared

func SetupTestEnvShared(ctx context.Context, containerName string) (*SharedTestEnv, error)

SetupTestEnvShared performs the same setup as SetupTestEnv but without *testing.T. It returns the blockchain Output for teardown. Use containerName for a stable container name when sharing across tests (e.g. "blockchain-stellar-integration-shared").

Directories

Path Synopsis
cmd
devenv command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL