tester

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2020 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// InactiveFailureLookbackWindow is the size of each window to check
	// for missing ops. If a block with missing ops is not found in this
	// window, another window is created with the preceding
	// InactiveFailureLookbackWindow blocks (this process continues
	// until the client halts the search or the block is found).
	InactiveFailureLookbackWindow = 250

	// PeriodicLoggingFrequency is the frequency that stats are printed
	// to the terminal.
	PeriodicLoggingFrequency = periodicLoggingSeconds * time.Second

	// EndAtTipCheckInterval is the frequency that EndAtTip condition
	// is evaludated
	EndAtTipCheckInterval = 10 * time.Second
)
View Source
const (
	// MemoryLoggingFrequency is the frequency that memory
	// usage stats are logged to the terminal.
	MemoryLoggingFrequency = 10 * time.Second
)

Variables

This section is empty.

Functions

func BalanceTrackingTest added in v0.5.0

func BalanceTrackingTest(cfg *configuration.Configuration, err error, operationsSeen bool) *bool

BalanceTrackingTest returns a boolean indicating if any balances went negative while syncing.

func BlockSyncingTest added in v0.5.0

func BlockSyncingTest(err error, blocksSynced bool) *bool

BlockSyncingTest returns a boolean indicating if it was possible to sync blocks.

func ExitConstruction added in v0.5.0

func ExitConstruction(
	config *configuration.Configuration,
	counterStorage *storage.CounterStorage,
	jobStorage *storage.JobStorage,
	err error,
	status int,
)

ExitConstruction exits check:data, logs the test results to the console, and to a provided output path.

func ExitData added in v0.5.0

func ExitData(
	config *configuration.Configuration,
	counterStorage *storage.CounterStorage,
	balanceStorage *storage.BalanceStorage,
	err error,
	status int,
	endCondition configuration.CheckDataEndCondition,
	endConditionDetail string,
)

ExitData exits check:data, logs the test results to the console, and to a provided output path.

func LogMemoryLoop added in v0.5.5

func LogMemoryLoop(
	ctx context.Context,
) error

LogMemoryLoop runs a loop that logs memory usage.

func ReconciliationTest added in v0.5.0

func ReconciliationTest(
	cfg *configuration.Configuration,
	err error,
	reconciliationsPerformed bool,
) *bool

ReconciliationTest returns a boolean if no reconciliation errors were received.

func RequestResponseTest added in v0.5.0

func RequestResponseTest(err error) bool

RequestResponseTest returns a boolean indicating if all endpoints received a non-500 response.

func ResponseAssertionTest added in v0.5.0

func ResponseAssertionTest(err error) bool

ResponseAssertionTest returns a boolean indicating if all responses received from the server were correctly formatted.

Types

type CheckConstructionResults added in v0.5.0

type CheckConstructionResults struct {
	Error         string                  `json:"error"`
	EndConditions map[string]int          `json:"end_conditions"`
	Stats         *CheckConstructionStats `json:"stats"`
}

CheckConstructionResults contains any error that occurred on a check:construction run and a collection of interesting stats.

func ComputeCheckConstructionResults added in v0.5.0

func ComputeCheckConstructionResults(
	cfg *configuration.Configuration,
	err error,
	counterStorage *storage.CounterStorage,
	jobStorage *storage.JobStorage,
) *CheckConstructionResults

ComputeCheckConstructionResults returns a populated CheckConstructionResults.

func (*CheckConstructionResults) Output added in v0.5.0

func (c *CheckConstructionResults) Output(path string)

Output writes CheckConstructionResults to the provided path.

func (*CheckConstructionResults) Print added in v0.5.0

func (c *CheckConstructionResults) Print()

Print logs CheckConstructionResults to the console.

type CheckConstructionStats added in v0.5.0

type CheckConstructionStats struct {
	TransactionsConfirmed int64 `json:"transactions_confirmed"`
	TransactionsCreated   int64 `json:"transactions_created"`
	StaleBroadcasts       int64 `json:"stale_broadcasts"`
	FailedBroadcasts      int64 `json:"failed_broadcasts"`
	AddressesCreated      int64 `json:"addresses_created"`

	WorkflowsCompleted map[string]int64 `json:"workflows_completed"`
}

CheckConstructionStats contains interesting stats that are tracked while running check:construction.

func ComputeCheckConstructionStats added in v0.5.0

func ComputeCheckConstructionStats(
	ctx context.Context,
	config *configuration.Configuration,
	counters *storage.CounterStorage,
	jobs *storage.JobStorage,
) *CheckConstructionStats

ComputeCheckConstructionStats returns a populated CheckConstructionStats.

func (*CheckConstructionStats) Print added in v0.5.0

func (c *CheckConstructionStats) Print()

Print calls PrintCounts and PrintWorkflows.

func (*CheckConstructionStats) PrintCounts added in v0.5.0

func (c *CheckConstructionStats) PrintCounts()

PrintCounts logs counter-related stats to the console.

func (*CheckConstructionStats) PrintWorkflows added in v0.5.0

func (c *CheckConstructionStats) PrintWorkflows()

PrintWorkflows logs workflow counts to the console.

type CheckDataResults added in v0.5.0

type CheckDataResults struct {
	Error        string          `json:"error"`
	EndCondition *EndCondition   `json:"end_condition"`
	Tests        *CheckDataTests `json:"tests"`
	Stats        *CheckDataStats `json:"stats"`
}

CheckDataResults contains any error that occurred on a check:data run, the outcome of certain tests, and a collection of interesting stats.

func ComputeCheckDataResults added in v0.5.0

func ComputeCheckDataResults(
	cfg *configuration.Configuration,
	err error,
	counterStorage *storage.CounterStorage,
	balanceStorage *storage.BalanceStorage,
	endCondition configuration.CheckDataEndCondition,
	endConditionDetail string,
) *CheckDataResults

ComputeCheckDataResults returns a populated CheckDataResults.

func (*CheckDataResults) Output added in v0.5.0

func (c *CheckDataResults) Output(path string)

Output writes *CheckDataResults to the provided path.

func (*CheckDataResults) Print added in v0.5.0

func (c *CheckDataResults) Print()

Print logs CheckDataResults to the console.

type CheckDataStats added in v0.5.0

type CheckDataStats struct {
	Blocks                  int64   `json:"blocks"`
	Orphans                 int64   `json:"orphans"`
	Transactions            int64   `json:"transactions"`
	Operations              int64   `json:"operations"`
	ActiveReconciliations   int64   `json:"active_reconciliations"`
	InactiveReconciliations int64   `json:"inactive_reconciliations"`
	ReconciliationCoverage  float64 `json:"reconciliation_coverage"`
}

CheckDataStats contains interesting stats that are counted while running the check:data.

func ComputeCheckDataStats added in v0.5.0

func ComputeCheckDataStats(
	ctx context.Context,
	counters *storage.CounterStorage,
	balances *storage.BalanceStorage,
) *CheckDataStats

ComputeCheckDataStats returns a populated CheckDataStats.

func (*CheckDataStats) Print added in v0.5.0

func (c *CheckDataStats) Print()

Print logs CheckDataStats to the console.

type CheckDataTests added in v0.5.0

type CheckDataTests struct {
	RequestResponse   bool  `json:"request_response"`
	ResponseAssertion bool  `json:"response_assertion"`
	BlockSyncing      *bool `json:"block_syncing"`
	BalanceTracking   *bool `json:"balance_tracking"`
	Reconciliation    *bool `json:"reconciliation"`
}

CheckDataTests indicates which tests passed. If a test is nil, it did not apply to the run.

TODO: add CoinTracking

func ComputeCheckDataTests added in v0.5.0

func ComputeCheckDataTests(
	ctx context.Context,
	cfg *configuration.Configuration,
	err error,
	counterStorage *storage.CounterStorage,
) *CheckDataTests

ComputeCheckDataTests returns a populated CheckDataTests.

func (*CheckDataTests) Print added in v0.5.0

func (c *CheckDataTests) Print()

Print logs CheckDataTests to the console.

type ConstructionTester

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

ConstructionTester coordinates the `check:construction` test.

func InitializeConstruction

func InitializeConstruction(
	ctx context.Context,
	config *configuration.Configuration,
	network *types.NetworkIdentifier,
	onlineFetcher *fetcher.Fetcher,
	cancel context.CancelFunc,
	signalReceived *bool,
) (*ConstructionTester, error)

InitializeConstruction initiates the construction API tester.

func (*ConstructionTester) CloseDatabase

func (t *ConstructionTester) CloseDatabase(ctx context.Context)

CloseDatabase closes the database used by ConstructionTester.

func (*ConstructionTester) HandleErr added in v0.5.0

func (t *ConstructionTester) HandleErr(
	err error,
	sigListeners *[]context.CancelFunc,
)

HandleErr is called when `check:construction` returns an error.

func (*ConstructionTester) PerformBroadcasts

func (t *ConstructionTester) PerformBroadcasts(ctx context.Context) error

PerformBroadcasts attempts to rebroadcast all pending transactions if the RebroadcastAll configuration is set to true.

func (*ConstructionTester) StartConstructor

func (t *ConstructionTester) StartConstructor(
	ctx context.Context,
) error

StartConstructor uses the tester's constructor to begin generating addresses and constructing transactions.

func (*ConstructionTester) StartPeriodicLogger

func (t *ConstructionTester) StartPeriodicLogger(
	ctx context.Context,
) error

StartPeriodicLogger prints out periodic stats about a run of `check:construction`.

func (*ConstructionTester) StartSyncer

func (t *ConstructionTester) StartSyncer(
	ctx context.Context,
	cancel context.CancelFunc,
) error

StartSyncer uses the tester's stateful syncer to compute balance changes and track transactions for confirmation on-chain.

func (*ConstructionTester) WatchEndConditions added in v0.5.0

func (t *ConstructionTester) WatchEndConditions(
	ctx context.Context,
) error

WatchEndConditions cancels check:construction once all end conditions are met (provided workflows are executed at least minOccurences).

type DataTester

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

DataTester coordinates the `check:data` test.

func InitializeData

func InitializeData(
	ctx context.Context,
	config *configuration.Configuration,
	network *types.NetworkIdentifier,
	fetcher *fetcher.Fetcher,
	cancel context.CancelFunc,
	genesisBlock *types.BlockIdentifier,
	interestingAccount *reconciler.AccountCurrency,
	signalReceived *bool,
) *DataTester

InitializeData returns a new *DataTester.

func (*DataTester) CloseDatabase

func (t *DataTester) CloseDatabase(ctx context.Context)

CloseDatabase closes the database used by DataTester.

func (*DataTester) EndAtTipLoop added in v0.5.0

func (t *DataTester) EndAtTipLoop(
	ctx context.Context,
	minReconciliationCoverage float64,
)

EndAtTipLoop runs a loop that evaluates end condition EndAtTip

func (*DataTester) EndDurationLoop added in v0.5.0

func (t *DataTester) EndDurationLoop(
	ctx context.Context,
	duration time.Duration,
)

EndDurationLoop runs a loop that evaluates end condition EndDuration.

func (*DataTester) FindMissingOps

func (t *DataTester) FindMissingOps(
	ctx context.Context,
	originalErr error,
	sigListeners *[]context.CancelFunc,
)

FindMissingOps logs the types.BlockIdentifier of a block that is missing balance-changing operations for a *reconciler.AccountCurrency.

func (*DataTester) HandleErr

func (t *DataTester) HandleErr(ctx context.Context, err error, sigListeners *[]context.CancelFunc)

HandleErr is called when `check:data` returns an error. If historical balance lookups are enabled, HandleErr will attempt to automatically find any missing balance-changing operations.

func (*DataTester) StartPeriodicLogger

func (t *DataTester) StartPeriodicLogger(
	ctx context.Context,
) error

StartPeriodicLogger prints out periodic stats about a run of `check:data`.

func (*DataTester) StartProgressLogger added in v0.5.5

func (t *DataTester) StartProgressLogger(
	ctx context.Context,
) error

StartProgressLogger priunts out periodic estimates of sync duration if we are behind tip.

func (*DataTester) StartPruning added in v0.5.3

func (t *DataTester) StartPruning(
	ctx context.Context,
) error

StartPruning attempts to prune block storage every 10 seconds.

func (*DataTester) StartReconciler

func (t *DataTester) StartReconciler(
	ctx context.Context,
) error

StartReconciler starts the reconciler if reconciliation is enabled.

func (*DataTester) StartSyncing

func (t *DataTester) StartSyncing(
	ctx context.Context,
) error

StartSyncing syncs from startIndex to endIndex. If startIndex is -1, it will start from the last saved block. If endIndex is -1, it will sync continuously (or until an error).

func (*DataTester) WatchEndConditions

func (t *DataTester) WatchEndConditions(
	ctx context.Context,
) error

WatchEndConditions starts go routines to watch the end conditions

type EndCondition added in v0.5.0

type EndCondition struct {
	Type   configuration.CheckDataEndCondition `json:"type"`
	Detail string                              `json:"detail"`
}

EndCondition contains the type of end condition and any detail associated with the stop.

Jump to

Keyboard shortcuts

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