testutils

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 38 Imported by: 0

Documentation

Overview

Package testutils implements test utils for many different packages.

Index

Constants

View Source
const (
	LocalTestDBDSNPrefix = "postgres://postgres:xmtp@localhost:8765"
	LocalTestDBDSNSuffix = "?sslmode=disable"
)
View Source
const (
	TestPrivateKey = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
)

This is the private key that anvil has funded by default This is safe to commit

Variables

This section is empty.

Functions

func BuildIdentityUpdateEvent

func BuildIdentityUpdateEvent(update []byte) ([]byte, error)

func BuildIdentityUpdateLog

func BuildIdentityUpdateLog(
	t *testing.T,
	inboxID [32]byte,
	clientEnvelope *envelopesProto.ClientEnvelope,
	sequenceID uint64,
) types.Log

BuildIdentityUpdateLog builds a log message for an IdentityUpdateCreated event.

func BuildMessageSentEvent

func BuildMessageSentEvent(
	message []byte,
) ([]byte, error)

BuildMessageSentEvent builds an abi encoded MessageSent event struct.

func BuildMessageSentLog

func BuildMessageSentLog(
	t *testing.T,
	groupID [16]byte,
	clientEnvelope *envelopesProto.ClientEnvelope,
	sequenceID uint64,
) types.Log

BuildMessageSentLog builds a log message for a MessageSent event.

func BuildPayerRegistryDepositLog added in v0.5.1

func BuildPayerRegistryDepositLog(
	t *testing.T,
	payer common.Address,
	amount *big.Int,
) types.Log

func BuildPayerRegistryUsageSettledLog added in v0.5.1

func BuildPayerRegistryUsageSettledLog(
	t *testing.T,
	payer common.Address,
	amount *big.Int,
	payerReportId common.Hash,
) types.Log

func BuildPayerRegistryWithdrawalCancelledLog added in v0.5.1

func BuildPayerRegistryWithdrawalCancelledLog(
	t *testing.T,
	payer common.Address,
) types.Log

func BuildPayerRegistryWithdrawalRequestedLog added in v0.5.1

func BuildPayerRegistryWithdrawalRequestedLog(
	t *testing.T,
	payer common.Address,
	amount *big.Int,
	withdrawableTimestamp uint32,
	nonce uint32,
) types.Log

func BuildPayerReportSubmittedEvent added in v0.5.1

func BuildPayerReportSubmittedEvent(
	t *testing.T,
	originatorNodeID uint32,
	payerReportIndex uint64,
	startSequenceID uint64,
	endSequenceID uint64,
	endMinuteSinceEpoch uint64,
	payersMerkleRoot [32]byte,
	activeNodeIDs []uint32,
) types.Log

func BuildPayerReportSubsetSettledLog added in v0.5.1

func BuildPayerReportSubsetSettledLog(
	t *testing.T,
	originatorNodeID uint32,
	payerReportIndex uint64,
	count uint32,
	remaining uint32,
	feesSettled *big.Int,
) types.Log

func CancelledContext added in v0.1.1

func CancelledContext() context.Context

func CreatePayer added in v0.3.0

func CreatePayer(t *testing.T, db *sql.DB, address ...string) int32

func GetCallerName added in v0.2.0

func GetCallerName(depth int) string

func GetLatestTag added in v0.2.1

func GetLatestTag(t *testing.T) string

func GetLatestVersion added in v0.2.1

func GetLatestVersion(t *testing.T) *semver.Version

func GetPayerOptions

func GetPayerOptions(t *testing.T) config.PayerOptions

func GetScriptPath added in v0.4.0

func GetScriptPath(paths ...string) string

func InsertGatewayEnvelopes

func InsertGatewayEnvelopes(
	t *testing.T,
	dbInstance *sql.DB,
	rows []queries.InsertGatewayEnvelopeParams,
	notifyChan ...chan bool,
)

func Int64ToHash added in v0.2.0

func Int64ToHash(x int64) common.Hash

func Marshal

func Marshal(t *testing.T, msg proto.Message) []byte

func NewContractsOptions added in v0.3.0

func NewContractsOptions(t *testing.T, rpcURL, wsURL string) *config.ContractsOptions

func NewDB

func NewDB(t *testing.T, ctx context.Context) (*db.Handler, string)

func NewDBs

func NewDBs(t *testing.T, ctx context.Context, count int) []*sql.DB

func NewJSONLog added in v1.1.0

func NewJSONLog(t testing.TB) *zap.Logger

func NewLog

func NewLog(t testing.TB) *zap.Logger

func NewRawDB added in v1.1.0

func NewRawDB(t *testing.T, ctx context.Context) (*sql.DB, string)

func RandomAddress

func RandomAddress() common.Address

func RandomBlockHash added in v0.2.0

func RandomBlockHash() common.Hash

func RandomBytes

func RandomBytes(n int) []byte

func RandomDomainSeparator added in v0.5.0

func RandomDomainSeparator() common.Hash

func RandomGroupID

func RandomGroupID() [16]byte

func RandomInboxIDBytes added in v0.5.0

func RandomInboxIDBytes() [32]byte

func RandomInboxIDString added in v0.5.0

func RandomInboxIDString() string

func RandomInt32 added in v0.3.0

func RandomInt32() int32

func RandomInt64 added in v0.5.0

func RandomInt64() int64

func RandomLogTopic

func RandomLogTopic() common.Hash

func RandomPrivateKey

func RandomPrivateKey(t *testing.T) *ecdsa.PrivateKey

func RandomReportID added in v1.0.0

func RandomReportID() []byte

func RandomString

func RandomString(n int) string

func RandomStringLower

func RandomStringLower(n int) string

Types

type CapturingLogger added in v0.5.1

type CapturingLogger struct {
	*zap.Logger
	// contains filtered or unexported fields
}

CapturingLogger wraps a zap.Logger and stores emitted logs.

func NewCapturingLogger added in v0.5.1

func NewCapturingLogger(level zapcore.Level) *CapturingLogger

NewCapturingLogger creates a zap.Logger that records all logs in memory.

func (*CapturingLogger) Contains added in v0.5.1

func (cl *CapturingLogger) Contains(substr string) bool

Contains checks if any captured log contains the given substring.

func (*CapturingLogger) Logs added in v0.5.1

func (cl *CapturingLogger) Logs() string

Logs returns all captured logs as a single string.

type CapturingWriteSyncer added in v0.5.1

type CapturingWriteSyncer struct {
	// contains filtered or unexported fields
}

CapturingWriteSyncer is a WriteSyncer that stores logs in memory.

func (*CapturingWriteSyncer) Sync added in v0.5.1

func (c *CapturingWriteSyncer) Sync() error

func (*CapturingWriteSyncer) Write added in v0.5.1

func (c *CapturingWriteSyncer) Write(p []byte) (n int, err error)

Directories

Path Synopsis
Package anvil implements the anvil test utils.
Package anvil implements the anvil test utils.
Package apiutils implements the api test utils.
Package apiutils implements the api test utils.
Package envelopes implements the envelopes test utils.
Package envelopes implements the envelopes test utils.
Package fees implements the fees test utils.
Package fees implements the fees test utils.
Package flags provides control over flags that are set at build time.
Package flags provides control over flags that are set at build time.
Package network implements the network test utils.
Package network implements the network test utils.
Package redis implements the redis test utils.
Package redis implements the redis test utils.
Package registry implements the node registry test utils.
Package registry implements the node registry test utils.
Package server implements the replication server test utils.
Package server implements the replication server test utils.

Jump to

Keyboard shortcuts

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