Documentation
¶
Index ¶
- Constants
- func BTCAmountFromFloat64(t require.TestingT, amount float64) *big.Int
- func EnsureNoCctxMinedByInboundHash(ctx context.Context, inboundHash string, client crosschaintypes.QueryClient)
- func FetchHotkeyAddress(host string) (parsers.ObserverInfoReader, error)
- func FetchNodePubkey(host string) (string, error)
- func GetCCTXByInboundHash(ctx context.Context, client crosschaintypes.QueryClient, inboundHash string) []crosschaintypes.CrossChainTx
- func MinimumVersionCheck(testVersion, zetacoredVersion string) bool
- func MustHaveDroppedBitcoinTx(ctx context.Context, client *client.Client, txHash *chainhash.Hash)
- func MustHaveMinedBitcoinTx(ctx context.Context, client *client.Client, txHash *chainhash.Hash) *btcjson.TxRawResult
- func MustWaitForTxReceipt(ctx context.Context, client *ethclient.Client, tx *ethtypes.Transaction, ...) *ethtypes.Receipt
- func ParseBigInt(t require.TestingT, s string) *big.Int
- func ParseBitcoinWithdrawArgs(t require.TestingT, args []string, defaultReceiver string, ...) (btcutil.Address, *big.Int)
- func ParseFloat(t require.TestingT, s string) float64
- func ParseInt(t require.TestingT, s string) int
- func ParseUint(t require.TestingT, s string) math.Uint
- func ParseUint8Array(t require.TestingT, s string) []uint8
- func RequireCCTXErrorMessageAbort(t require.TestingT, cctx *crosschaintypes.CrossChainTx, ...)
- func RequireCCTXErrorMessageRevert(t require.TestingT, cctx *crosschaintypes.CrossChainTx, ...)
- func RequireCCTXErrorMessages(t require.TestingT, cctx *crosschaintypes.CrossChainTx, ...)
- func RequireCCTXStatus(t require.TestingT, cctx *crosschaintypes.CrossChainTx, ...)
- func RequireTxSuccessful(t require.TestingT, receipt *ethtypes.Receipt, msgAndArgs ...any)
- func RequiredTxFailed(t require.TestingT, receipt *ethtypes.Receipt, msgAndArgs ...any)
- func ScriptPKToAddress(scriptPKHex string, params *chaincfg.Params) string
- func TestingFromContext(ctx context.Context) require.TestingT
- func VerifyOutboundGasAccounting(t require.TestingT, cctx *crosschaintypes.CrossChainTx, ...)
- func WaitAndVerifyExampleContractCall(t require.TestingT, contract *testcontract.Example, amount *big.Int, ...)
- func WaitAndVerifyExampleContractCallWithMsg(t require.TestingT, contract *testcontract.Example, amount *big.Int, ...)
- func WaitAndVerifyZRC20BalanceChange(t require.TestingT, zrc20 *zrc20.ZRC20, address common.Address, ...)
- func WaitCCTXMinedByIndex(ctx context.Context, cctxIndex string, client crosschaintypes.QueryClient, ...) *crosschaintypes.CrossChainTx
- func WaitCctxAbortedByInboundHash(ctx context.Context, t require.TestingT, hash string, c CCTXClient) crosschaintypes.CrossChainTx
- func WaitCctxByInboundHash(ctx context.Context, t require.TestingT, hash string, c CCTXClient, ...) crosschaintypes.CrossChainTx
- func WaitCctxMinedByInboundHash(ctx context.Context, inboundHash string, client crosschaintypes.QueryClient, ...) *crosschaintypes.CrossChainTx
- func WaitCctxRevertedByInboundHash(ctx context.Context, t require.TestingT, hash string, c CCTXClient) crosschaintypes.CrossChainTx
- func WaitCctxsMinedByInboundHash(ctx context.Context, inboundHash string, client crosschaintypes.QueryClient, ...) []*crosschaintypes.CrossChainTx
- func WaitForBlockHeight(ctx context.Context, desiredHeight int64, rpcURL string, logger infoLogger) error
- func WaitForZetaBlocks(ctx context.Context, t require.TestingT, zevmClient *ethclient.Client, ...)
- func WaitOutboundTracker(ctx context.Context, client crosschaintypes.QueryClient, chainID int64, ...) []string
- func WithTesting(ctx context.Context, t require.TestingT) context.Context
- func WorkDir(t require.TestingT) string
- type BalanceChange
- type CCTXClient
- type NoopLogger
- type WaitOpts
Constants ¶
const ( EmergencyPolicyName = "emergency" AdminPolicyName = "admin" OperationalPolicyName = "operational" UserEmissionsWithdrawName = "emissions_withdraw" DefaultCctxTimeout = 8 * time.Minute )
const (
DefaultReceiptTimeout = 30 * time.Second
)
const (
// ErrHashRevertFoo is the keccak256 hash of custom error "Foo()" on reverter contract
ErrHashRevertFoo = "0xbfb4ebcf"
)
Variables ¶
This section is empty.
Functions ¶
func BTCAmountFromFloat64 ¶
BTCAmountFromFloat64 takes float64 (e.g. 0.001) that represents btc amount and converts it to big.Int for downstream usage.
func EnsureNoCctxMinedByInboundHash ¶
func EnsureNoCctxMinedByInboundHash( ctx context.Context, inboundHash string, client crosschaintypes.QueryClient, )
EnsureNoCctxMinedByInboundHash ensures no cctx is mined by inbound hash
func FetchHotkeyAddress ¶
func FetchHotkeyAddress(host string) (parsers.ObserverInfoReader, error)
FetchHotkeyAddress retrieves the hotkey address of a new validator.
func FetchNodePubkey ¶
FetchNodePubkey retrieves the public key of the new validator node.
func GetCCTXByInboundHash ¶
func GetCCTXByInboundHash( ctx context.Context, client crosschaintypes.QueryClient, inboundHash string, ) []crosschaintypes.CrossChainTx
GetCCTXByInboundHash gets cctx by inbound hash
func MinimumVersionCheck ¶
func MustHaveDroppedBitcoinTx ¶
MustHaveDroppedBitcoinTx ensures the given Bitcoin tx has been dropped
func MustHaveMinedBitcoinTx ¶
func MustHaveMinedBitcoinTx(ctx context.Context, client *client.Client, txHash *chainhash.Hash) *btcjson.TxRawResult
MustHaveMinedBitcoinTx ensures the given Bitcoin tx has been mined
func MustWaitForTxReceipt ¶
func MustWaitForTxReceipt( ctx context.Context, client *ethclient.Client, tx *ethtypes.Transaction, logger infoLogger, timeout time.Duration, ) *ethtypes.Receipt
MustWaitForTxReceipt waits until a broadcasted tx to be mined and return its receipt
func ParseBigInt ¶
ParseBigInt parses *big.Int from provided string, used in e2e tests
func ParseBitcoinWithdrawArgs ¶
func ParseBitcoinWithdrawArgs( t require.TestingT, args []string, defaultReceiver string, bitcoinChainID int64, ) (btcutil.Address, *big.Int)
ParseBitcoinWithdrawArgs parses receiver and withdrawal amount, used in e2e tests
func ParseFloat ¶
ParseFloat parses float64 from provided string, used in e2e tests
func ParseUint8Array ¶
ParseUint8Array parses []uint8 from provided string, used in e2e tests
func RequireCCTXErrorMessageAbort ¶
func RequireCCTXErrorMessageAbort(t require.TestingT, cctx *crosschaintypes.CrossChainTx, wantErrMessages ...string)
RequireCCTXErrorMessageAbort checks if the CCTX's ErrorMessageAbort contains all the expected error messages
func RequireCCTXErrorMessageRevert ¶
func RequireCCTXErrorMessageRevert(t require.TestingT, cctx *crosschaintypes.CrossChainTx, wantErrMessages ...string)
RequireCCTXErrorMessageRevert checks if the CCTX's ErrorMessageRevert contains all the expected error messages
func RequireCCTXErrorMessages ¶
func RequireCCTXErrorMessages(t require.TestingT, cctx *crosschaintypes.CrossChainTx, wantErrMessages ...string)
RequireCCTXErrorMessages checks if the CCTX's ErrorMessage contains all the expected error messages
func RequireCCTXStatus ¶
func RequireCCTXStatus( t require.TestingT, cctx *crosschaintypes.CrossChainTx, expected crosschaintypes.CctxStatus, msgAndArgs ...any, )
RequireCCTXStatus checks if the cctx status is equal to the expected status
func RequireTxSuccessful ¶
RequireTxSuccessful checks if the receipt status is successful. Currently, it accepts eth receipt, but we can make this more generic by using type assertion.
func RequiredTxFailed ¶
RequiredTxFailed checks if the receipt status is failed. Currently, it accepts eth receipt, but we can make this more generic by using type assertion.
func ScriptPKToAddress ¶
ScriptPKToAddress is a hex string for P2WPKH script
func TestingFromContext ¶
TestingFromContext extracts require.TestingT from the context or panics.
func VerifyOutboundGasAccounting ¶
func VerifyOutboundGasAccounting( t require.TestingT, cctx *crosschaintypes.CrossChainTx, stabilityPoolPercentage uint64, logger infoLogger, )
VerifyOutboundGasAccounting verifies the gas accounting for an outbound CCTX. It asserts that UserGasFeePaid equals GasLimit * GasPrice (gas token denomination), and logs the calculated refund amounts (stability pool and user refund). stabilityPoolPercentage should be obtained from chain params (e.g., chainParams.ChainParams.StabilityPoolPercentage)
func WaitAndVerifyExampleContractCall ¶
func WaitAndVerifyExampleContractCall( t require.TestingT, contract *testcontract.Example, amount *big.Int, sender []byte, )
WaitAndVerifyExampleContractCall waits for the example contract to be called with the expected amount and sender This function is to tolerate the fact that the contract state may not be synced across all nodes behind a RPC.
func WaitAndVerifyExampleContractCallWithMsg ¶
func WaitAndVerifyExampleContractCallWithMsg( t require.TestingT, contract *testcontract.Example, amount *big.Int, msg []byte, sender []byte, )
WaitAndVerifyExampleContractCallWithMsg waits for the example contract to be called with the expected amount, msg and sender This function is to tolerate the fact that the contract state may not be synced across all nodes behind a RPC.
func WaitAndVerifyZRC20BalanceChange ¶
func WaitAndVerifyZRC20BalanceChange( t require.TestingT, zrc20 *zrc20.ZRC20, address common.Address, oldBalance *big.Int, change BalanceChange, logger infoLogger, )
WaitAndVerifyZRC20BalanceChange waits for the zrc20 balance of the given address to change by the given delta amount This function is to tolerate the fact that the balance update may not be synced across all nodes behind a RPC.
func WaitCCTXMinedByIndex ¶
func WaitCCTXMinedByIndex( ctx context.Context, cctxIndex string, client crosschaintypes.QueryClient, logger infoLogger, timeout time.Duration, ) *crosschaintypes.CrossChainTx
WaitCCTXMinedByIndex waits until cctx is mined; returns the cctxIndex
func WaitCctxAbortedByInboundHash ¶
func WaitCctxAbortedByInboundHash( ctx context.Context, t require.TestingT, hash string, c CCTXClient, ) crosschaintypes.CrossChainTx
WaitCctxAbortedByInboundHash waits until cctx is aborted by inbound hash.
func WaitCctxByInboundHash ¶
func WaitCctxByInboundHash( ctx context.Context, t require.TestingT, hash string, c CCTXClient, opts ...WaitOpts, ) crosschaintypes.CrossChainTx
WaitCctxByInboundHash waits until cctx appears by inbound hash.
func WaitCctxMinedByInboundHash ¶
func WaitCctxMinedByInboundHash( ctx context.Context, inboundHash string, client crosschaintypes.QueryClient, logger infoLogger, timeout time.Duration, ) *crosschaintypes.CrossChainTx
WaitCctxMinedByInboundHash waits until cctx is mined; returns the cctxIndex (the last one)
func WaitCctxRevertedByInboundHash ¶
func WaitCctxRevertedByInboundHash( ctx context.Context, t require.TestingT, hash string, c CCTXClient, ) crosschaintypes.CrossChainTx
WaitCctxRevertedByInboundHash waits until cctx is reverted by inbound hash.
func WaitCctxsMinedByInboundHash ¶
func WaitCctxsMinedByInboundHash( ctx context.Context, inboundHash string, client crosschaintypes.QueryClient, cctxsCount int, logger infoLogger, timeout time.Duration, ) []*crosschaintypes.CrossChainTx
WaitCctxsMinedByInboundHash waits until cctx is mined; returns the cctxIndex (the last one)
func WaitForBlockHeight ¶
func WaitForBlockHeight( ctx context.Context, desiredHeight int64, rpcURL string, logger infoLogger, ) error
WaitForBlockHeight waits until the block height reaches the given height
func WaitForZetaBlocks ¶
func WaitForZetaBlocks( ctx context.Context, t require.TestingT, zevmClient *ethclient.Client, waitBlocks uint64, timeout time.Duration, )
WaitForZetaBlocks waits for the given number of Zeta blocks
func WaitOutboundTracker ¶
func WaitOutboundTracker( ctx context.Context, client crosschaintypes.QueryClient, chainID int64, nonce uint64, hashCount int, logger infoLogger, timeout time.Duration, ) []string
WaitOutboundTracker wait for outbound tracker to be filled with 'hashCount' hashes
func WithTesting ¶
WithTesting allows to store a testing.T instance in the context
Types ¶
type BalanceChange ¶
type BalanceChange struct {
// contains filtered or unexported fields
}
BalanceChange contains details about the balance change
func NewBalanceChange ¶
func NewBalanceChange(positive bool) BalanceChange
NewBalanceChange returns a new BalanceChange with given positive flag
func NewExactChange ¶
func NewExactChange(delta *big.Int) BalanceChange
NewExactChange returns a new BalanceChange with the Delta field set to the exact value
type CCTXClient ¶
type CCTXClient = crosschaintypes.QueryClient
type NoopLogger ¶
type NoopLogger struct{}
func (NoopLogger) Info ¶
func (nl NoopLogger) Info(_ string, _ ...interface{})
type WaitOpts ¶
type WaitOpts func(c *waitConfig)
func HasOutboundTxHash ¶
func HasOutboundTxHash() WaitOpts
HasOutboundTxHash returns true when the CCTX has been assigned an outbound hash. This now happens when the first tracker is written.
func MatchReverted ¶
func MatchReverted() WaitOpts
MatchReverted is the WaitOpts that matches reverted CCTX.
func MatchStatus ¶
func MatchStatus(s crosschaintypes.CctxStatus) WaitOpts
MatchStatus is the WaitOpts that matches CCTX with the given status.
func Matches ¶
func Matches(fn func(tx crosschaintypes.CrossChainTx) bool) WaitOpts
Matches adds a filter to WaitCctxByInboundHash that checks cctxs match provided callback. ALL cctxs should match this filter.