Documentation
¶
Overview ¶
Package client provides traffic generation for E2E tests.
Clients are created via the environment and bound to a specific node:
env.NewClient(100) // create client for node 100 env.Client(100).PublishEnvelopes(ctx, 10) // publish 10 envelopes env.Client(100).GenerateTraffic(ctx, opts) // background traffic env.Client(100).Stop() // stop traffic + cleanup
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
// PublishEnvelopes publishes the specified number of group message envelopes
// to the target node via gRPC. Blocks until all envelopes are published.
PublishEnvelopes(ctx context.Context, count uint) error
// GenerateTraffic starts background traffic generation that continuously
// publishes envelopes in batches until Stop is called or the duration elapses.
// Returns a TrafficGenerator to monitor and stop the generation.
GenerateTraffic(ctx context.Context, opts TrafficOptions) *TrafficGenerator
// Stop stops any active background traffic generation and releases resources.
Stop()
// NodeID returns the on-chain nodeID of the node this client publishes to.
NodeID() uint32
// PayerKey returns the private key hex string used for signing payer envelopes.
PayerKey() string
// Name returns the unique identifier for this client within the environment.
Name() string
// Address returns the Ethereum address derived from this client's payer key.
// This address appears in the payers table and can be used to verify per-payer
// attribution via GetUnsettledUsage.
Address() common.Address
}
Client is the interface for E2E traffic generation. Implementations are bound to a specific node and can publish envelopes synchronously or generate background traffic.
type Options ¶
type Options struct {
// NodeAddr is the host-accessible address of a node (e.g. http://localhost:XXXXX).
NodeAddr string
// PayerKey is the private key used to sign payer envelopes.
PayerKey string
// OriginatorID is the on-chain nodeID of the target node.
OriginatorID uint32
// Name is the unique identifier for this client within the environment.
Name string
}
Options configures a new client instance.
type TrafficGenerator ¶
type TrafficGenerator struct {
// contains filtered or unexported fields
}
TrafficGenerator manages a background traffic generation goroutine. Call Stop to cancel the generation and wait for it to finish. Check Err after Stop to see if the generation encountered an error.
func (*TrafficGenerator) Err ¶
func (g *TrafficGenerator) Err() error
Err returns the first error from the background generation, if any. Safe to call after Stop returns.
func (*TrafficGenerator) Stop ¶
func (g *TrafficGenerator) Stop()
Stop cancels the background generation and waits for it to finish.
type TrafficOptions ¶
type TrafficOptions struct {
// BatchSize is the number of envelopes to publish per batch.
BatchSize uint
// Duration is how long to generate traffic before stopping automatically.
Duration time.Duration
}
TrafficOptions configures background traffic generation.