client

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 License: MIT Imports: 30 Imported by: 0

README

Client

Contains code to interact with different blockchains, as well as chainlink nodes.

Documentation

Overview

Package client handles connections between chainlink nodes and different blockchain networks

Index

Constants

View Source
const (
	BlockchainTypeEVM          = "evm"
	BlockchainTypeEVMMultinode = "evm_multi"
	NetworkGethPerformance     = "ethereum_geth_performance"
)

Commonly used variables

View Source
const (
	// GWei one giga-wei used for gas calculations
	GWei = 1e9
	// ETH one eth in wei
	ETH = 1e18
)
View Source
const (
	QueryMemoryUsage          = `` /* 201-byte string literal not displayed */
	QueryAllCPUBusyPercentage = `100 - (avg by (instance) (irate(node_cpu_seconds_total{mode="idle"}[%s])) * 100)`
)

Query constants

Variables

View Source
var (
	// OneGWei represents 1 GWei
	OneGWei = big.NewInt(1e9)
	// OneEth represents 1 Ethereum
	OneEth = big.NewFloat(1e18)
)
View Source
var ErrNotFound = errors.New("unexpected response code, got 404")

ErrNotFound Error for not found

View Source
var ErrUnprocessableEntity = errors.New("unexpected response code, got 422")

ErrUnprocessableEntity Error for and unprocessable entity

View Source
var OneLINK = big.NewFloat(1e18)

OneLINK representation of a single LINK token

Functions

func ObservationSourceSpecBridge

func ObservationSourceSpecBridge(bta BridgeTypeAttributes) string

ObservationSourceSpecBridge creates a bridge task spec for json data

func ObservationSourceSpecHTTP

func ObservationSourceSpecHTTP(url string) string

ObservationSourceSpecHTTP creates a http GET task spec for json data

Types

type AdapterResponse added in v0.0.5

type AdapterResponse struct {
	Id    string        `json:"id"`
	Data  AdapterResult `json:"data"`
	Error interface{}   `json:"error"`
}

AdapterResponse represents a response from an adapter

type AdapterResult added in v0.0.5

type AdapterResult struct {
	Result int `json:"result"`
}

AdapterResult represents an int result for an adapter

type BasicHTTPClient

type BasicHTTPClient struct {
	BaseURL    string
	HttpClient *http.Client
	Cookies    []*http.Cookie
	Header     http.Header
}

BasicHTTPClient handles basic http sending logic and cookie handling

func NewBasicHTTPClient

func NewBasicHTTPClient(c *http.Client, baseURL string) *BasicHTTPClient

NewBasicHTTPClient returns new basic http client configured with an base URL

type BlockchainClient

type BlockchainClient interface {
	Get() interface{}
	GetID() int
	SetID(id int)
	SetDefaultClient(clientID int) error
	GetClients() []BlockchainClient
	SuggestGasPrice(ctx context.Context) (*big.Int, error)
	HeaderHashByNumber(ctx context.Context, bn *big.Int) (string, error)
	BlockNumber(ctx context.Context) (uint64, error)
	HeaderTimestampByNumber(ctx context.Context, bn *big.Int) (uint64, error)
	CalculateTxGas(gasUsedValue *big.Int) (*big.Float, error)
	Fund(fromWallet BlockchainWallet, toAddress string, nativeAmount, linkAmount *big.Float) error
	GasStats() *GasStats
	ParallelTransactions(enabled bool)
	Close() error

	AddHeaderEventSubscription(key string, subscriber HeaderEventSubscription)
	DeleteHeaderEventSubscription(key string)
	WaitForEvents() error
}

BlockchainClient is the interface that wraps a given client implementation for a blockchain, to allow for switching of network types within the test suite

func NewBlockchainClient

func NewBlockchainClient(network BlockchainNetwork) (BlockchainClient, error)

NewBlockchainClient returns an instantiated network client implementation based on the network configuration given

type BlockchainNetwork

type BlockchainNetwork interface {
	GasUsedEstimations
	ID() string
	URL() string
	URLs() []string
	Type() string
	SetURL(string)
	SetURLs(urls []string)
	ChainID() *big.Int
	Wallets() (BlockchainWallets, error)
	Config() *config.NetworkConfig
}

BlockchainNetwork is the interface that when implemented, defines a new blockchain network that can be tested against

func NewNetworkFromConfig

func NewNetworkFromConfig(conf *config.Config) (BlockchainNetwork, error)

NewNetworkFromConfig prepares settings for a connection to a hardhat blockchain

type BlockchainNetworkInit

type BlockchainNetworkInit func(conf *config.Config) (BlockchainNetwork, error)

BlockchainNetworkInit is a helper function to obtain different blockchain networks

func NewNetworkFromConfigWithDefault added in v0.0.5

func NewNetworkFromConfigWithDefault(networkID string) BlockchainNetworkInit

NewNetworkFromConfigWithDefault will return a new network with config but with a customisable default in-case a test needs a different default from the config file default. For example, performance tests usually need a "performance" network with higher gas limits than the vanilla Geth network.

type BlockchainWallet

type BlockchainWallet interface {
	PrivateKey() string
	Address() string
}

BlockchainWallet when implemented is the interface to allow multiple wallet implementations for each BlockchainNetwork that is supported

type BlockchainWallets

type BlockchainWallets interface {
	Default() BlockchainWallet
	All() []BlockchainWallet
	SetDefault(i int) error
	Wallet(i int) (BlockchainWallet, error)
}

BlockchainWallets is an interface that when implemented is a representation of a slice of wallets for a specific network

type BridgeType

type BridgeType struct {
	Data BridgeTypeData `json:"data"`
}

BridgeType is the model that represents the bridge when read or created on a Chainlink node

type BridgeTypeAttributes

type BridgeTypeAttributes struct {
	Name        string `json:"name"`
	URL         string `json:"url"`
	RequestData string `json:"requestData,omitempty"`
}

BridgeTypeAttributes is the model that represents the bridge when read or created on a Chainlink node

type BridgeTypeData

type BridgeTypeData struct {
	Attributes BridgeTypeAttributes `json:"attributes"`
}

BridgeTypeData is the model that represents the bridge when read or created on a Chainlink node

type Chainlink interface {
	URL() string
	CreateJob(spec JobSpec) (*Job, error)
	CreateJobRaw(spec string) (*Job, error)
	ReadJobs() (*ResponseSlice, error)
	ReadJob(id string) (*Response, error)
	DeleteJob(id string) error

	CreateSpec(spec string) (*Spec, error)
	ReadSpec(id string) (*Response, error)
	DeleteSpec(id string) error

	CreateBridge(bta *BridgeTypeAttributes) error
	ReadBridge(name string) (*BridgeType, error)
	DeleteBridge(name string) error

	ReadRunsByJob(jobID string) (*JobRunsResponse, error)

	CreateOCRKey() (*OCRKey, error)
	ReadOCRKeys() (*OCRKeys, error)
	DeleteOCRKey(id string) error

	CreateP2PKey() (*P2PKey, error)
	ReadP2PKeys() (*P2PKeys, error)
	DeleteP2PKey(id int) error

	ReadETHKeys() (*ETHKeys, error)
	ReadVRFKeys() (*VRFKeys, error)
	PrimaryEthAddress() (string, error)

	CreateEI(eia *EIAttributes) (*EIKeyCreate, error)
	ReadEIs() (*EIKeys, error)
	DeleteEI(name string) error

	RemoteIP() string
	SetSessionCookie() error

	SetPageSize(size int)

	// SetClient is used for testing
	SetClient(client *http.Client)
}

Chainlink interface that enables interactions with a chainlink node

func NewChainlink(c *ChainlinkConfig, httpClient *http.Client) (Chainlink, error)

NewChainlink creates a new chainlink model using a provided config

type ChainlinkConfig

type ChainlinkConfig struct {
	URL      string
	Email    string
	Password string
	RemoteIP string
}

ChainlinkConfig represents the variables needed to connect to a Chainlink node

type ContractDeployer

type ContractDeployer func(auth *bind.TransactOpts, backend bind.ContractBackend) (
	common.Address,
	*types.Transaction,
	interface{},
	error,
)

ContractDeployer acts as a go-between function for general contract deployment

type ContractInfoJSON added in v0.0.5

type ContractInfoJSON struct {
	ContractAddress string `json:"contractAddress"`
	ContractVersion int    `json:"contractVersion"`
	Path            string `json:"path"`
	Status          string `json:"status"`
}

ContractInfoJSON represents an element of the contracts array used to deliver configs to otpe

type CronJobSpec

type CronJobSpec struct {
	Schedule          string `toml:"schedule"`          // CRON job style schedule string
	ObservationSource string `toml:"observationSource"` // List of commands for the chainlink node
}

CronJobSpec represents a cron job spec

func (*CronJobSpec) String

func (c *CronJobSpec) String() (string, error)

String representation of the job

func (*CronJobSpec) Type

func (c *CronJobSpec) Type() string

Type is cron

type DirectRequestJobSpec

type DirectRequestJobSpec struct {
	Name              string `toml:"name"`
	ContractAddress   string `toml:"contractAddress"`
	ExternalJobID     string `toml:"externalJobID"`
	ObservationSource string `toml:"observationSource"` // List of commands for the chainlink node
}

DirectRequestJobSpec represents a direct request spec

func (*DirectRequestJobSpec) String

func (d *DirectRequestJobSpec) String() (string, error)

String representation of the pipeline

func (*DirectRequestJobSpec) Type

func (d *DirectRequestJobSpec) Type() string

Type returns the type of the pipeline

type DirectRequestTxPipelineSpec

type DirectRequestTxPipelineSpec struct {
	BridgeTypeAttributes BridgeTypeAttributes
	DataPath             string
}

DirectRequestTxPipelineSpec oracle request with tx callback

func (*DirectRequestTxPipelineSpec) String

func (d *DirectRequestTxPipelineSpec) String() (string, error)

String representation of the pipeline

func (*DirectRequestTxPipelineSpec) Type

Type returns the type of the pipeline

type EIAttributes

type EIAttributes struct {
	Name              string `json:"name,omitempty"`
	URL               string `json:"url,omitempty"`
	IncomingAccessKey string `json:"incomingAccessKey,omitempty"`
	AccessKey         string `json:"accessKey,omitempty"`
	Secret            string `json:"incomingSecret,omitempty"`
	OutgoingToken     string `json:"outgoingToken,omitempty"`
	OutgoingSecret    string `json:"outgoingSecret,omitempty"`
}

EIAttributes is the model that represents the EI keys when created and read

type EIKey

type EIKey struct {
	Attributes EIAttributes `json:"attributes"`
}

EIKey is the model that represents the EI configs when read

type EIKeyCreate

type EIKeyCreate struct {
	Data EIKey `json:"data"`
}

EIKeyCreate is the model that represents the EI config when created

type EIKeys

type EIKeys struct {
	Data []EIKey `json:"data"`
}

EIKeys is the model that represents the EI configs when read

type ETHKey

type ETHKey struct {
	Data ETHKeyData `json:"data"`
}

ETHKey is the model that represents the created ETH keys when read

type ETHKeyAttributes

type ETHKeyAttributes struct {
	Address string `json:"address"`
}

ETHKeyAttributes is the model that represents the created ETH keys when read

type ETHKeyData

type ETHKeyData struct {
	Attributes ETHKeyAttributes `json:"attributes"`
}

ETHKeyData is the model that represents the created ETH keys when read

type ETHKeys

type ETHKeys struct {
	Data []ETHKeyData `json:"data"`
}

ETHKeys is the model that represents the created ETH keys when read

type EthereumClient

type EthereumClient struct {
	ID           int
	Client       *ethclient.Client
	Network      BlockchainNetwork
	BorrowNonces bool
	NonceMu      *sync.Mutex
	Nonces       map[string]uint64
	// contains filtered or unexported fields
}

EthereumClient wraps the client and the BlockChain network to interact with an EVM based Blockchain

func NewEthereumClient

func NewEthereumClient(network BlockchainNetwork) (*EthereumClient, error)

NewEthereumClient returns an instantiated instance of the Ethereum client that has connected to the server

func (*EthereumClient) AddHeaderEventSubscription

func (e *EthereumClient) AddHeaderEventSubscription(key string, subscriber HeaderEventSubscription)

AddHeaderEventSubscription adds a new header subscriber within the client to receive new headers

func (*EthereumClient) BlockNumber

func (e *EthereumClient) BlockNumber(ctx context.Context) (uint64, error)

BlockNumber gets latest block number

func (*EthereumClient) BorrowedNonces

func (e *EthereumClient) BorrowedNonces(n bool)

BorrowedNonces allows to handle nonces concurrently without requesting them every time

func (*EthereumClient) CalculateTxGas

func (e *EthereumClient) CalculateTxGas(gasUsed *big.Int) (*big.Float, error)

CalculateTxGas calculates tx gas cost accordingly gas used plus buffer, converts it to big.Float for funding

func (*EthereumClient) Close

func (e *EthereumClient) Close() error

Close tears down the current open Ethereum client

func (*EthereumClient) DeleteHeaderEventSubscription

func (e *EthereumClient) DeleteHeaderEventSubscription(key string)

DeleteHeaderEventSubscription removes a header subscriber from the map

func (*EthereumClient) DeployContract

func (e *EthereumClient) DeployContract(
	fromWallet BlockchainWallet,
	contractName string,
	deployer ContractDeployer,
) (*common.Address, *types.Transaction, interface{}, error)

DeployContract acts as a general contract deployment tool to an ethereum chain

func (*EthereumClient) Fund

func (e *EthereumClient) Fund(
	fromWallet BlockchainWallet,
	toAddress string,
	ethAmount, linkAmount *big.Float,
) error

Fund funds a specified address with LINK token and or ETH from the given wallet

func (*EthereumClient) GasStats added in v0.0.5

func (e *EthereumClient) GasStats() *GasStats

GasStats gets gas stats instance

func (*EthereumClient) Get

func (e *EthereumClient) Get() interface{}

Get returns the underlying client type to be used generically across the framework for switching network types

func (*EthereumClient) GetClients added in v0.0.5

func (e *EthereumClient) GetClients() []BlockchainClient

GetClients not used, only applicable to EthereumClients

func (*EthereumClient) GetHeaderSubscriptions

func (e *EthereumClient) GetHeaderSubscriptions() map[string]HeaderEventSubscription

GetHeaderSubscriptions returns a duplicate map of the queued transactions

func (*EthereumClient) GetID added in v0.0.5

func (e *EthereumClient) GetID() int

GetID gets client ID, node number it's connected to

func (*EthereumClient) GetNonce

func (e *EthereumClient) GetNonce(ctx context.Context, addr common.Address) (uint64, error)

GetNonce keep tracking of nonces per address, add last nonce for addr if the map is empty

func (*EthereumClient) HeaderHashByNumber added in v0.0.5

func (e *EthereumClient) HeaderHashByNumber(ctx context.Context, bn *big.Int) (string, error)

HeaderHashByNumber gets header hash by block number

func (*EthereumClient) HeaderTimestampByNumber

func (e *EthereumClient) HeaderTimestampByNumber(ctx context.Context, bn *big.Int) (uint64, error)

HeaderTimestampByNumber gets header timestamp by number

func (*EthereumClient) ParallelTransactions

func (e *EthereumClient) ParallelTransactions(enabled bool)

ParallelTransactions when enabled, sends the transaction without waiting for transaction confirmations. The hashes are then stored within the client and confirmations can be waited on by calling WaitForEvents. When disabled, the minimum confirmations are waited on when the transaction is sent, so parallelisation is disabled.

func (*EthereumClient) ProcessTransaction

func (e *EthereumClient) ProcessTransaction(txHash common.Hash) error

ProcessTransaction will queue or wait on a transaction depending on whether queue transactions is enabled

func (*EthereumClient) SendTransaction

func (e *EthereumClient) SendTransaction(
	from BlockchainWallet,
	to common.Address,
	value *big.Float,
	data []byte,
) (common.Hash, error)

SendTransaction sends a specified amount of WEI from a selected wallet to an address, and blocks until the transaction completes

func (*EthereumClient) SetDefaultClient added in v0.0.5

func (e *EthereumClient) SetDefaultClient(_ int) error

SetDefaultClient not used, only applicable to EthereumClients

func (*EthereumClient) SetID added in v0.0.5

func (e *EthereumClient) SetID(id int)

SetID sets client id, useful for multi-node networks

func (*EthereumClient) SuggestGasPrice added in v0.0.5

func (e *EthereumClient) SuggestGasPrice(ctx context.Context) (*big.Int, error)

SuggestGasPrice gets suggested gas price

func (*EthereumClient) TransactionCallMessage

func (e *EthereumClient) TransactionCallMessage(
	from BlockchainWallet,
	to common.Address,
	value *big.Int,
	data []byte,
) (*ethereum.CallMsg, error)

TransactionCallMessage returns a filled Ethereum CallMsg object with suggest gas price and limit

func (*EthereumClient) TransactionOpts

func (e *EthereumClient) TransactionOpts(
	from BlockchainWallet,
	to common.Address,
	value *big.Int,
	data []byte,
) (*bind.TransactOpts, error)

TransactionOpts return the base binding transaction options to create a new valid tx for contract deployment

func (*EthereumClient) WaitForEvents

func (e *EthereumClient) WaitForEvents() error

WaitForEvents is a blocking function that waits for all event subscriptions that have been queued within the client.

type EthereumClients added in v0.0.5

type EthereumClients struct {
	DefaultClient *EthereumClient
	Clients       []*EthereumClient
}

EthereumClients wraps the client and the BlockChain network to interact with an EVM based Blockchain with multiple nodes

func NewEthereumClients added in v0.0.5

func NewEthereumClients(network BlockchainNetwork) (*EthereumClients, error)

NewEthereumClients returns an instantiated instance of all Ethereum client connected to all nodes

func (*EthereumClients) AddHeaderEventSubscription added in v0.0.5

func (e *EthereumClients) AddHeaderEventSubscription(key string, subscriber HeaderEventSubscription)

AddHeaderEventSubscription adds a new header subscriber within the client to receive new headers

func (*EthereumClients) BlockNumber added in v0.0.5

func (e *EthereumClients) BlockNumber(ctx context.Context) (uint64, error)

BlockNumber gets block number

func (*EthereumClients) CalculateTxGas added in v0.0.5

func (e *EthereumClients) CalculateTxGas(gasUsedValue *big.Int) (*big.Float, error)

CalculateTxGas calculates tx gas cost accordingly gas used plus buffer, converts it to big.Float for funding

func (*EthereumClients) Close added in v0.0.5

func (e *EthereumClients) Close() error

Close tears down the all the clients

func (*EthereumClients) DeleteHeaderEventSubscription added in v0.0.5

func (e *EthereumClients) DeleteHeaderEventSubscription(key string)

DeleteHeaderEventSubscription removes a header subscriber from the map

func (*EthereumClients) Fund added in v0.0.5

func (e *EthereumClients) Fund(fromWallet BlockchainWallet, toAddress string, nativeAmount, linkAmount *big.Float) error

Fund funds a specified address with LINK token and or ETH from the given wallet

func (*EthereumClients) GasStats added in v0.0.5

func (e *EthereumClients) GasStats() *GasStats

GasStats gets gas stats instance

func (*EthereumClients) Get added in v0.0.5

func (e *EthereumClients) Get() interface{}

Get gets default client as an interface{}

func (*EthereumClients) GetClients added in v0.0.5

func (e *EthereumClients) GetClients() []BlockchainClient

GetClients gets clients for all nodes connected

func (*EthereumClients) GetID added in v0.0.5

func (e *EthereumClients) GetID() int

GetID gets client ID, node number it's connected to

func (*EthereumClients) HeaderHashByNumber added in v0.0.5

func (e *EthereumClients) HeaderHashByNumber(ctx context.Context, bn *big.Int) (string, error)

HeaderHashByNumber gets header hash by block number

func (*EthereumClients) HeaderTimestampByNumber added in v0.0.5

func (e *EthereumClients) HeaderTimestampByNumber(ctx context.Context, bn *big.Int) (uint64, error)

HeaderTimestampByNumber gets header timestamp by number

func (*EthereumClients) ParallelTransactions added in v0.0.5

func (e *EthereumClients) ParallelTransactions(enabled bool)

ParallelTransactions when enabled, sends the transaction without waiting for transaction confirmations. The hashes are then stored within the client and confirmations can be waited on by calling WaitForEvents. When disabled, the minimum confirmations are waited on when the transaction is sent, so parallelisation is disabled.

func (*EthereumClients) SetDefaultClient added in v0.0.5

func (e *EthereumClients) SetDefaultClient(clientID int) error

SetDefaultClient sets default client to perform calls to the network

func (*EthereumClients) SetID added in v0.0.5

func (e *EthereumClients) SetID(id int)

SetID sets client ID (node)

func (*EthereumClients) SuggestGasPrice added in v0.0.5

func (e *EthereumClients) SuggestGasPrice(ctx context.Context) (*big.Int, error)

SuggestGasPrice gets suggested gas price

func (*EthereumClients) WaitForEvents added in v0.0.5

func (e *EthereumClients) WaitForEvents() error

WaitForEvents is a blocking function that waits for all event subscriptions for all clients

type EthereumNetwork

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

EthereumNetwork is the implementation of BlockchainNetwork for the local ETH dev server

func (*EthereumNetwork) ChainID

func (e *EthereumNetwork) ChainID() *big.Int

ChainID returns the on-chain ID of the network being connected to

func (*EthereumNetwork) Config

func (e *EthereumNetwork) Config() *config.NetworkConfig

Config returns the blockchain network configuration

func (*EthereumNetwork) FluxMonitorSubmissionGasUsed

func (e *EthereumNetwork) FluxMonitorSubmissionGasUsed() (*big.Int, error)

FluxMonitorSubmissionGasUsed Flux Monitor one submission gasUsed value

func (*EthereumNetwork) ID

func (e *EthereumNetwork) ID() string

ID returns the readable name of the EVM network

func (*EthereumNetwork) SetURL

func (e *EthereumNetwork) SetURL(newURL string)

SetURL sets the RPC URL, useful for when blockchain URLs might be dynamic

func (*EthereumNetwork) SetURLs added in v0.0.5

func (e *EthereumNetwork) SetURLs(urls []string)

SetURLs sets all nodes URLs

func (*EthereumNetwork) Type

func (e *EthereumNetwork) Type() string

Type returns the readable type of the EVM network

func (*EthereumNetwork) URL

func (e *EthereumNetwork) URL() string

URL returns the RPC URL used for connecting to the network

func (*EthereumNetwork) URLs added in v0.0.5

func (e *EthereumNetwork) URLs() []string

URLs returns the RPC URLs used for connecting to the network nodes

func (*EthereumNetwork) Wallets

func (e *EthereumNetwork) Wallets() (BlockchainWallets, error)

Wallets returns all the viable wallets used for testing on chain

type EthereumWallet

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

EthereumWallet is the implementation to allow testing with ETH based wallets

func NewEthereumWallet

func NewEthereumWallet(pk string) (*EthereumWallet, error)

NewEthereumWallet returns the instantiated ETH wallet based on a given private key

func (*EthereumWallet) Address

func (e *EthereumWallet) Address() string

Address returns the ETH address for a given wallet

func (*EthereumWallet) PrivateKey

func (e *EthereumWallet) PrivateKey() string

PrivateKey returns the private key for a given Ethereum wallet

type ExplorerClient

type ExplorerClient struct {
	*BasicHTTPClient
	Config *ExplorerConfig
}

ExplorerClient is used to call Explorer API endpoints

func NewExplorerClient added in v0.0.3

func NewExplorerClient(cfg *ExplorerConfig) *ExplorerClient

NewExplorerClient creates a new explorer mock client

func (*ExplorerClient) PostAdminNodes added in v0.0.3

func (em *ExplorerClient) PostAdminNodes(nodeName string) (NodeAccessKeys, error)

PostAdminNodes is used to exercise the POST /api/v1/admin/nodes endpoint This endpoint is used to create access keys for nodes

type ExplorerConfig added in v0.0.5

type ExplorerConfig struct {
	URL           string
	AdminUsername string
	AdminPassword string
}

ExplorerConfig holds config information for ExplorerClient

type FluxMonitorJobSpec

type FluxMonitorJobSpec struct {
	Name              string        `toml:"name"`
	ContractAddress   string        `toml:"contractAddress"`   // Address of the Flux Monitor script
	Precision         int           `toml:"precision"`         // Optional
	Threshold         float32       `toml:"threshold"`         // Optional
	AbsoluteThreshold float32       `toml:"absoluteThreshold"` // Optional
	IdleTimerPeriod   time.Duration `toml:"idleTimerPeriod"`   // Optional
	IdleTimerDisabled bool          `toml:"idleTimerDisabled"` // Optional
	PollTimerPeriod   time.Duration `toml:"pollTimerPeriod"`   // Optional
	PollTimerDisabled bool          `toml:"pollTimerDisabled"` // Optional
	MaxTaskDuration   time.Duration `toml:"maxTaskDuration"`   // Optional
	ObservationSource string        `toml:"observationSource"` // List of commands for the chainlink node
}

FluxMonitorJobSpec represents a flux monitor spec

func (*FluxMonitorJobSpec) String

func (f *FluxMonitorJobSpec) String() (string, error)

String representation of the job

func (*FluxMonitorJobSpec) Type

func (f *FluxMonitorJobSpec) Type() string

Type returns the type of the job

type GasStats added in v0.0.5

type GasStats struct {
	NodeID       int
	TotalGasUsed int64
	SeenHashes   map[string]bool
	ClientTXs    []TXGasData
}

GasStats helper struct to determine gas metrics across all txs of a test

func NewGasStats added in v0.0.5

func NewGasStats(nodeID int) *GasStats

NewGasStats creates new gas stats collector

func (*GasStats) AddClientTXData added in v0.0.5

func (g *GasStats) AddClientTXData(data TXGasData)

AddClientTXData adds client TX data

func (*GasStats) PrintStats added in v0.0.5

func (g *GasStats) PrintStats()

PrintStats prints gas stats and total TXs cost

type GasUsedEstimations

type GasUsedEstimations interface {
	FluxMonitorSubmissionGasUsed() (*big.Int, error)
}

GasUsedEstimations contains some known gas values for contracts for every network

type HeaderEventSubscription

type HeaderEventSubscription interface {
	ReceiveBlock(header NodeBlock) error
	Wait() error
}

HeaderEventSubscription is an interface for allowing callbacks when the client receives a new header

type HttpInitializer added in v0.0.5

type HttpInitializer struct {
	Request  HttpRequest  `json:"httpRequest"`
	Response HttpResponse `json:"httpResponse"`
}

HttpInitializer represents an element of the initializer array used in the mockserver initializer

type HttpRequest added in v0.0.5

type HttpRequest struct {
	Path string `json:"path"`
}

HttpRequest represents the httpRequest json object used in the mockserver initializer

type HttpResponse added in v0.0.5

type HttpResponse struct {
	Body interface{} `json:"body"`
}

HttpResponse represents the httpResponse json object used in the mockserver initializer

type InstantConfirmations

type InstantConfirmations struct{}

InstantConfirmations is a no-op confirmer as all transactions are instantly mined so no confs are needed

func (*InstantConfirmations) ReceiveBlock

func (i *InstantConfirmations) ReceiveBlock(block NodeBlock) error

ReceiveBlock is a no-op

func (*InstantConfirmations) Wait

func (i *InstantConfirmations) Wait() error

Wait is a no-op

type Job

type Job struct {
	Data JobData `json:"data"`
}

Job contains the job data for a given job

type JobData

type JobData struct {
	ID string `json:"id"`
}

JobData contains the ID for a given job

type JobForm

type JobForm struct {
	TOML string `json:"toml"`
}

JobForm is the form used when creating a v2 job spec, containing the TOML of the v2 job

type JobRunsResponse

type JobRunsResponse struct {
	Data []RunsResponseData `json:"data"`
	Meta RunsMetaResponse   `json:"meta"`
}

JobRunsResponse job runs

type JobSpec

type JobSpec interface {
	Type() string
	// String Returns TOML representation of the job
	String() (string, error)
}

JobSpec represents the different possible job types that chainlink nodes can handle

type KeeperJobSpec

type KeeperJobSpec struct {
	Name            string `toml:"name"`
	ContractAddress string `toml:"contractAddress"`
	FromAddress     string `toml:"fromAddress"` // Hex representation of the from address
}

KeeperJobSpec represents a keeper spec

func (*KeeperJobSpec) String

func (k *KeeperJobSpec) String() (string, error)

String representation of the job

func (*KeeperJobSpec) Type

func (k *KeeperJobSpec) Type() string

Type returns the type of the job

type MockserverClient added in v0.0.5

type MockserverClient struct {
	*BasicHTTPClient
	Config *MockserverConfig
}

MockserverClient mockserver client

func NewMockserverClient added in v0.0.5

func NewMockserverClient(cfg *MockserverConfig) *MockserverClient

NewMockserverClient returns a mockserver client

func (*MockserverClient) ClearExpectation added in v0.0.5

func (em *MockserverClient) ClearExpectation(body interface{}) error

ClearExpectation clears expectations

func (*MockserverClient) PutExpectations added in v0.0.5

func (em *MockserverClient) PutExpectations(body interface{}) error

PutExpectations sets the expectations (i.e. mocked responses)

type MockserverConfig added in v0.0.5

type MockserverConfig struct {
	LocalURL   string
	ClusterURL string
}

MockserverConfig holds config information for MockserverClient

type Name added in v0.0.3

type Name struct {
	Name string `json:"name"`
}

Name is the body of the request

type NodeAccessKeys added in v0.0.3

type NodeAccessKeys struct {
	ID        string `mapstructure:"id" yaml:"id"`
	AccessKey string `mapstructure:"accesKey" yaml:"accessKey"`
	Secret    string `mapstructure:"secret" yaml:"secret"`
}

NodeAccessKeys is the body of the response

type NodeBlock added in v0.0.5

type NodeBlock struct {
	NodeID int
	*types.Block
}

NodeBlock block with a node ID which mined it

type NodeInfoJSON added in v0.0.5

type NodeInfoJSON struct {
	ID          string   `json:"id"`
	NodeAddress []string `json:"nodeAddress"`
}

NodeInfoJSON represents an element of the nodes array used to deliver configs to otpe

type OCRBootstrapJobSpec

type OCRBootstrapJobSpec struct {
	Name                     string        `toml:"name"`
	BlockChainTimeout        time.Duration `toml:"blockchainTimeout"`                      // Optional
	ContractConfirmations    int           `toml:"contractConfigConfirmations"`            // Optional
	TrackerPollInterval      time.Duration `toml:"contractConfigTrackerPollInterval"`      // Optional
	TrackerSubscribeInterval time.Duration `toml:"contractConfigTrackerSubscribeInterval"` // Optional
	ContractAddress          string        `toml:"contractAddress"`                        // Address of the OCR contract
	P2PBootstrapPeers        []string      `toml:"p2pBootstrapPeers"`                      // Typically empty for our suite
	IsBootstrapPeer          bool          `toml:"isBootstrapPeer"`                        // Typically true
	P2PPeerID                string        `toml:"p2pPeerID"`                              // This node's P2P ID
}

OCRBootstrapJobSpec represents the spec for bootstrapping an OCR job, given to one node that then must be linked back to by others by OCRTaskJobSpecs

func (*OCRBootstrapJobSpec) String

func (o *OCRBootstrapJobSpec) String() (string, error)

String representation of the job

func (*OCRBootstrapJobSpec) Type

func (o *OCRBootstrapJobSpec) Type() string

Type returns the type of the job

type OCRKey

type OCRKey struct {
	Data OCRKeyData `json:"data"`
}

OCRKey is the model that represents the created OCR keys when read

type OCRKeyAttributes

type OCRKeyAttributes struct {
	ConfigPublicKey       string `json:"configPublicKey"`
	OffChainPublicKey     string `json:"offChainPublicKey"`
	OnChainSigningAddress string `json:"onChainSigningAddress"`
}

OCRKeyAttributes is the model that represents the created OCR keys when read

type OCRKeyData

type OCRKeyData struct {
	Attributes OCRKeyAttributes `json:"attributes"`
	ID         string           `json:"id"`
}

OCRKeyData is the model that represents the created OCR keys when read

type OCRKeys

type OCRKeys struct {
	Data []OCRKeyData `json:"data"`
}

OCRKeys is the model that represents the created OCR keys when read

type OCRTaskJobSpec

type OCRTaskJobSpec struct {
	Name                     string        `toml:"name"`
	BlockChainTimeout        time.Duration `toml:"blockchainTimeout"`                      // Optional
	ContractConfirmations    int           `toml:"contractConfigConfirmations"`            // Optional
	TrackerPollInterval      time.Duration `toml:"contractConfigTrackerPollInterval"`      // Optional
	TrackerSubscribeInterval time.Duration `toml:"contractConfigTrackerSubscribeInterval"` // Optional
	ContractAddress          string        `toml:"contractAddress"`                        // Address of the OCR contract
	P2PBootstrapPeers        []Chainlink   `toml:"p2pBootstrapPeers"`                      // P2P ID of the bootstrap node
	IsBootstrapPeer          bool          `toml:"isBootstrapPeer"`                        // Typically false
	P2PPeerID                string        `toml:"p2pPeerID"`                              // This node's P2P ID
	KeyBundleID              string        `toml:"keyBundleID"`                            // ID of this node's OCR key bundle
	MonitoringEndpoint       string        `toml:"monitoringEndpoint"`                     // Typically "chain.link:4321"
	TransmitterAddress       string        `toml:"transmitterAddress"`                     // ETH address this node will use to transmit its answer
	ObservationSource        string        `toml:"observationSource"`                      // List of commands for the chainlink node
}

OCRTaskJobSpec represents an OCR job that is given to other nodes, meant to communicate with the bootstrap node, and provide their answers

func (*OCRTaskJobSpec) String

func (o *OCRTaskJobSpec) String() (string, error)

String representation of the job

func (*OCRTaskJobSpec) Type

func (o *OCRTaskJobSpec) Type() string

Type returns the type of the job

type P2PData

type P2PData struct {
	RemoteIP string
	PeerID   string
}

P2PData holds the remote ip and the peer id

type P2PKey

type P2PKey struct {
	Data P2PKeyData `json:"data"`
}

P2PKey is the model that represents the created P2P keys when read

type P2PKeyAttributes

type P2PKeyAttributes struct {
	ID        int    `json:"id"`
	PeerID    string `json:"peerId"`
	PublicKey string `json:"publicKey"`
}

P2PKeyAttributes is the model that represents the created P2P keys when read

type P2PKeyData

type P2PKeyData struct {
	Attributes P2PKeyAttributes `json:"attributes"`
}

P2PKeyData is the model that represents the created P2P keys when read

type P2PKeys

type P2PKeys struct {
	Data []P2PKeyData `json:"data"`
}

P2PKeys is the model that represents the created P2P keys when read

type PathSelector added in v0.0.5

type PathSelector struct {
	Path string `json:"path"`
}

PathSelector represents the json object used to find expectations by path

type PipelineSpec

type PipelineSpec struct {
	BridgeTypeAttributes BridgeTypeAttributes
	DataPath             string
}

PipelineSpec common API call pipeline

func (*PipelineSpec) String

func (d *PipelineSpec) String() (string, error)

String representation of the pipeline

func (*PipelineSpec) Type

func (d *PipelineSpec) Type() string

Type is common_pipeline

type Prometheus

type Prometheus struct {
	v1.API
}

Prometheus ease of use for v1.API

func NewPrometheusClient

func NewPrometheusClient(url string) (*Prometheus, error)

NewPrometheusClient returns a prometheus client

func (*Prometheus) CPUBusyPercentage

func (p *Prometheus) CPUBusyPercentage() (float64, error)

CPUBusyPercentage host CPU busy percentage

func (*Prometheus) GetAlerts added in v0.0.5

func (p *Prometheus) GetAlerts() (v1.AlertsResult, error)

GetAlerts returns all firing alerts

func (*Prometheus) GetQuery added in v0.0.5

func (p *Prometheus) GetQuery(query string) (model.Value, error)

GetQuery returns the result of applying a PromQL query

func (*Prometheus) MemoryUsage

func (p *Prometheus) MemoryUsage() (float64, error)

MemoryUsage total memory used by interval

func (*Prometheus) ResourcesSummary

func (p *Prometheus) ResourcesSummary() (float64, float64, error)

ResourcesSummary returns a summary of memory and cpu used

type ResourcesSummary

type ResourcesSummary struct {
	MemoryUsage   float64
	CPUPercentage float64
}

ResourcesSummary Data for memory and cpu usage

type Response

type Response struct {
	Data map[string]interface{}
}

Response is the generic model that can be used for all Chainlink API responses

type ResponseSlice

type ResponseSlice struct {
	Data []map[string]interface{}
}

ResponseSlice is the generic model that can be used for all Chainlink API responses that are an slice

type RunInputs

type RunInputs struct {
	Parse int `json:"parse"`
}

RunInputs run inputs (value)

type RunsAttributesResponse

type RunsAttributesResponse struct {
	Meta       interface{}   `json:"meta"`
	Errors     []interface{} `json:"errors"`
	Inputs     RunInputs     `json:"inputs"`
	CreatedAt  time.Time     `json:"createdAt"`
	FinishedAt time.Time     `json:"finishedAt"`
}

RunsAttributesResponse runs attributes

type RunsMetaResponse

type RunsMetaResponse struct {
	Count int `json:"count"`
}

RunsMetaResponse runs meta

type RunsResponseData

type RunsResponseData struct {
	Type       string                 `json:"type"`
	ID         string                 `json:"id"`
	Attributes RunsAttributesResponse `json:"attributes"`
}

RunsResponseData runs response data

type Session

type Session struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

Session is the form structure used for authenticating

type Spec

type Spec struct {
	Data SpecData `json:"data"`
}

Spec represents a job specification that contains information about the job spec

type SpecData

type SpecData struct {
	ID string `json:"id"`
}

SpecData contains the ID of the job spec

type SpecForm

type SpecForm struct {
	TOML string `json:"toml"`
}

SpecForm is the form used when creating a v2 job spec, containing the TOML of the v2 job

type TXGasData added in v0.0.5

type TXGasData struct {
	TXHash            string
	Value             uint64
	GasLimit          uint64
	GasUsed           uint64
	GasPrice          uint64
	CumulativeGasUsed uint64
}

TXGasData transaction gas data

type TransactionConfirmer

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

TransactionConfirmer is an implementation of HeaderEventSubscription that checks whether tx are confirmed

func NewTransactionConfirmer

func NewTransactionConfirmer(eth *EthereumClient, txHash common.Hash, minConfirmations int) *TransactionConfirmer

NewTransactionConfirmer returns a new instance of the transaction confirmer that waits for on-chain minimum confirmations

func (*TransactionConfirmer) ReceiveBlock

func (t *TransactionConfirmer) ReceiveBlock(block NodeBlock) error

ReceiveBlock the implementation of the HeaderEventSubscription that receives each block and checks tx confirmation

func (*TransactionConfirmer) Wait

func (t *TransactionConfirmer) Wait() error

Wait is a blocking function that waits until the transaction is complete

type VRFJobSpec

type VRFJobSpec struct {
	Name               string `toml:"name"`
	CoordinatorAddress string `toml:"coordinatorAddress"` // Address of the VRF Coordinator contract
	PublicKey          string `toml:"publicKey"`          // Public key of the proving key
	Confirmations      int    `toml:"confirmations"`      // Number of block confirmations to wait for
	ExternalJobID      string `toml:"externalJobID"`
	ObservationSource  string `toml:"observationSource"` // List of commands for the chainlink node
}

VRFJobSpec represents a VRF job

func (*VRFJobSpec) String

func (v *VRFJobSpec) String() (string, error)

String representation of the job

func (*VRFJobSpec) Type

func (v *VRFJobSpec) Type() string

Type returns the type of the job

type VRFKey

type VRFKey struct {
	Type       string           `json:"type"`
	ID         string           `json:"id"`
	Attributes VRFKeyAttributes `json:"attributes"`
}

VRFKey is the model that represents the created VRF key when read

type VRFKeyAttributes

type VRFKeyAttributes struct {
	Compressed   string      `json:"compressed"`
	Uncompressed string      `json:"uncompressed"`
	Hash         string      `json:"hash"`
	CreatedAt    time.Time   `json:"createdAt"`
	UpdatedAt    time.Time   `json:"updatedAt"`
	DeletedAt    interface{} `json:"deletedAt"`
}

VRFKeyAttributes is the model that represents the created VRF key attributes when read

type VRFKeys

type VRFKeys struct {
	Data []VRFKey `json:"data"`
}

VRFKeys is the model that represents the created VRF keys when read

type VRFTxPipelineSpec

type VRFTxPipelineSpec struct {
	Address string
}

VRFTxPipelineSpec VRF request with tx callback

func (*VRFTxPipelineSpec) String

func (d *VRFTxPipelineSpec) String() (string, error)

String representation of the pipeline

func (*VRFTxPipelineSpec) Type

func (d *VRFTxPipelineSpec) Type() string

Type returns the type of the pipeline

type Wallets

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

Wallets is the default implementation of BlockchainWallets that holds a slice of wallets with the default

func (*Wallets) All

func (w *Wallets) All() []BlockchainWallet

All returns the raw representation of Wallets

func (*Wallets) Default

func (w *Wallets) Default() BlockchainWallet

Default returns the default wallet to be used for a transaction on-chain

func (*Wallets) SetDefault

func (w *Wallets) SetDefault(i int) error

SetDefault changes the default wallet to be used for on-chain transactions

func (*Wallets) Wallet

func (w *Wallets) Wallet(i int) (BlockchainWallet, error)

Wallet returns a wallet based on a given index in the slice

type WebhookJobSpec

type WebhookJobSpec struct {
	ObservationSource string `toml:"observationSource"` // List of commands for the chainlink node
}

WebhookJobSpec reprsents a webhook job

func (*WebhookJobSpec) String

func (w *WebhookJobSpec) String() (string, error)

String representation of the job

func (*WebhookJobSpec) Type

func (w *WebhookJobSpec) Type() string

Type returns the type of the job

Jump to

Keyboard shortcuts

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