Documentation ¶
Index ¶
- Constants
- func CheckNonce(ctx context.Context, client *ethclient.Client, addr ethcommon.Address, ...) error
- func EnsureNoCctxMinedByInboundHash(ctx context.Context, inboundHash string, client crosschaintypes.QueryClient)
- func MustHaveCalledExampleContract(t require.TestingT, contract *testcontract.Example, amount *big.Int)
- func MustWaitForTxReceipt(ctx context.Context, client *ethclient.Client, tx *ethtypes.Transaction, ...) *ethtypes.Receipt
- 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 TraceTx(ctx context.Context, tx *ethtypes.Transaction, rpcURL string) (string, error)
- 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 WithTesting(ctx context.Context, t require.TestingT) context.Context
- 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 CheckNonce ¶
func EnsureNoCctxMinedByInboundHash ¶
func EnsureNoCctxMinedByInboundHash( ctx context.Context, inboundHash string, client crosschaintypes.QueryClient, )
EnsureNoCctxMinedByInboundHash ensures no cctx is mined by inbound hash
func MustHaveCalledExampleContract ¶
func MustHaveCalledExampleContract( t require.TestingT, contract *testcontract.Example, amount *big.Int, )
MustHaveCalledExampleContract checks if the contract has been called correctly
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 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 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)
Types ¶
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 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.