chainlink: github.com/smartcontractkit/chainlink/core/internal/cltest Index | Files

package cltest

import "github.com/smartcontractkit/chainlink/core/internal/cltest"

Index

Package Files

client.go cltest.go event_websocket_server.go factories.go fixtures.go memory_sink.go mocks.go postgres.go transactor.go vrf.go

Constants

const (
    // RootDir the root directory for cltest
    RootDir = "/tmp/chainlink_test"
    // APIKey of the fixture API user
    APIKey = "2d25e62eaf9143e993acaf48691564b2"
    // APISecret of the fixture API user.
    APISecret = "1eCP/w0llVkchejFaoBpfIGaLRxZK54lTXBCT22YLW+pdzE4Fafy/XO5LoJ2uwHi"
    // Email of the fixture API user
    APIEmail = "apiuser@chainlink.test"
    // Password just a password we use everywhere for testing
    Password = "password"
    // SessionSecret is the hardcoded secret solely used for test
    SessionSecret = "clsession_test_secret"
)
const (
    DBWaitTimeout = 3 * time.Second
    // DBPollingInterval can't be too short to avoid DOSing the test database
    DBPollingInterval = 100 * time.Millisecond
)
const EthMockRegisterChainID = "eth_mock_register_chain_id"

EthMockRegisterChainID registers the common case of calling eth_chainId and returns the store.config.ChainID

const (
    Key3cb8e3fd9d27e39a5e9e6852b0e96160061fd4ea = "" /* 493 byte string literal not displayed */
)
const LenientEthMock = "lenient"

LenientEthMock flag prevents the mock eth client from panicking if an unexpected call is made

Variables

var OracleTransactor *bind.TransactOpts

OracleTransactor representsthe identity of the oracle address used in cltest

func AddTxAttempt Uses

func AddTxAttempt(
    t testing.TB,
    store *strpkg.Store,
    tx *models.Tx,
    etx *types.Transaction,
    blkNum uint64,
) *models.TxAttempt

func AllExternalInitiators Uses

func AllExternalInitiators(t testing.TB, store *strpkg.Store) []models.ExternalInitiator

func AllJobs Uses

func AllJobs(t testing.TB, store *strpkg.Store) []models.JobSpec

func AssertError Uses

func AssertError(t testing.TB, want bool, err error)

func AssertServerResponse Uses

func AssertServerResponse(t testing.TB, resp *http.Response, expectedStatusCode int)

AssertServerResponse is used to match against a client response, will print any errors returned if the request fails.

func AssertSyncEventCountStays Uses

func AssertSyncEventCountStays(
    t testing.TB,
    orm *orm.ORM,
    want int,
)

AssertSyncEventCountStays ensures that the event sync count stays consistent for a period of time

func BigHexInt Uses

func BigHexInt(val interface{}) hexutil.Big

BigHexInt create hexutil.Big value from given value

func BlockWithTransactions Uses

func BlockWithTransactions(gasPrices ...uint64) eth.Block

BlockWithTransactions returns a new ethereum block with transactions matching the given gas prices

func BuildInitiatorRequests Uses

func BuildInitiatorRequests(t *testing.T, initrs []models.Initiator) []models.InitiatorRequest

func BuildTaskRequests Uses

func BuildTaskRequests(t *testing.T, initrs []models.TaskSpec) []models.TaskSpecRequest

func CallbackOrTimeout Uses

func CallbackOrTimeout(t testing.TB, msg string, callback func(), durationParams ...time.Duration)

func ChainlinkEthLogFromGethLog Uses

func ChainlinkEthLogFromGethLog(l types.Log) eth.Log

ChainlinkEthLogFromGethLog returns a copy of l as an eth.Log. (They have identical fields, but the field tags differ, and the types differ slightly.)

func CreateBridgeTypeViaWeb Uses

func CreateBridgeTypeViaWeb(
    t testing.TB,
    app *TestApplication,
    payload string,
) *models.BridgeTypeAuthentication

CreateBridgeTypeViaWeb creates a bridgetype via web using /v2/bridge_types

func CreateExternalInitiatorViaWeb Uses

func CreateExternalInitiatorViaWeb(
    t testing.TB,
    app *TestApplication,
    payload string,
) *presenters.ExternalInitiatorAuthentication

CreateExternalInitiatorViaWeb creates a bridgetype via web using /v2/bridge_types

func CreateHelloWorldJobViaWeb Uses

func CreateHelloWorldJobViaWeb(t testing.TB, app *TestApplication, url string) models.JobSpec

CreateHelloWorldJobViaWeb creates a HelloWorld JobSpec with the given MockServer Url

func CreateJobRunViaExternalInitiator Uses

func CreateJobRunViaExternalInitiator(
    t testing.TB,
    app *TestApplication,
    j models.JobSpec,
    eia auth.Token,
    body string,
) models.JobRun

func CreateJobRunViaWeb Uses

func CreateJobRunViaWeb(t testing.TB, app *TestApplication, j models.JobSpec, body ...string) models.JobRun

CreateJobRunViaWeb creates JobRun via web using /v2/specs/ID/runs

func CreateJobRunWithStatus Uses

func CreateJobRunWithStatus(t testing.TB, store *strpkg.Store, job models.JobSpec, status models.RunStatus) models.JobRun

CreateJobRunWithStatus returns a new job run with the specified status that has been persisted

func CreateJobSpecViaWeb Uses

func CreateJobSpecViaWeb(t testing.TB, app *TestApplication, job models.JobSpec) models.JobSpec

CreateJobSpecViaWeb creates a jobspec via web using /v2/specs

func CreateMemoryTestLogger Uses

func CreateMemoryTestLogger(lvl zapcore.Level) *zap.Logger

CreateMemoryTestLogger creates a logger that only directs output to the buffer testMemoryLog.

func CreateServiceAgreementViaWeb Uses

func CreateServiceAgreementViaWeb(
    t *testing.T,
    app *TestApplication,
    path string,
    endAt time.Time,
) models.ServiceAgreement

CreateServiceAgreementViaWeb creates a service agreement from a fixture using /v2/service_agreements

func CreateSpecViaWeb Uses

func CreateSpecViaWeb(t testing.TB, app *TestApplication, spec string) models.JobSpec

CreateJobSpecViaWeb creates a jobspec via web using /v2/specs

func CreateTestLogger Uses

func CreateTestLogger(lvl zapcore.Level) *zap.Logger

CreateTestLogger creates a logger that directs output to PrettyConsole configured for test output, and to the buffer testMemoryLog.

func CreateTx Uses

func CreateTx(
    t testing.TB,
    store *strpkg.Store,
    from common.Address,
    sentAt uint64,
) *models.Tx

CreateTx creates a Tx from a specified address, and sentAt

func CreateTxWithNonceAndGasPrice Uses

func CreateTxWithNonceAndGasPrice(
    t testing.TB,
    store *strpkg.Store,
    from common.Address,
    sentAt uint64,
    nonce uint64,
    gasPrice int64,
) *models.Tx

CreateTxWithNonceAndGasPrice creates a Tx from a specified address, sentAt, nonce and gas price

func CreateTxWithNonceGasPriceAndRecipient Uses

func CreateTxWithNonceGasPriceAndRecipient(
    t testing.TB,
    store *strpkg.Store,
    from common.Address,
    to common.Address,
    sentAt uint64,
    nonce uint64,
    gasPrice int64,
) *models.Tx

CreateTxWithNonceGasPriceAndRecipient creates a Tx from a specified sender, recipient, sentAt, nonce and gas price

func DecodeSessionCookie Uses

func DecodeSessionCookie(value string) (string, error)

func EmptyBlock Uses

func EmptyBlock() eth.Block

EmptyBlock returns a new empty ethereum block

func EmptyCLIContext Uses

func EmptyCLIContext() *cli.Context

func ExtractTargetAddressFromERC20EthEthCallMock Uses

func ExtractTargetAddressFromERC20EthEthCallMock(
    t *testing.T, arg ...interface{}) common.Address

ExtractTargetAddressFromERC20EthEthCallMock extracts the contract address and the method data, for checking in a test.

func FindJob Uses

func FindJob(t testing.TB, s *strpkg.Store, id *models.ID) models.JobSpec

FindJob returns JobSpec for given JobID

func FindJobRun Uses

func FindJobRun(t *testing.T, store *strpkg.Store, id *models.ID) models.JobRun

func FindServiceAgreement Uses

func FindServiceAgreement(t testing.TB, s *strpkg.Store, id string) models.ServiceAgreement

func FixtureCreateJobViaWeb Uses

func FixtureCreateJobViaWeb(t *testing.T, app *TestApplication, path string) models.JobSpec

FixtureCreateJobViaWeb creates a job from a fixture using /v2/specs

func GetAccountAddress Uses

func GetAccountAddress(t testing.TB, store *strpkg.Store) common.Address

GetAccountAddress returns Address of the account in the keystore of the passed in store

func GetAccountAddresses Uses

func GetAccountAddresses(store *strpkg.Store) []common.Address

GetAccountAddresses returns the Address of all registered accounts

func GetLastTx Uses

func GetLastTx(t testing.TB, store *strpkg.Store) models.Tx

func GetLastTxAttempt Uses

func GetLastTxAttempt(t testing.TB, store *strpkg.Store) models.TxAttempt

func GetLogs Uses

func GetLogs(t *testing.T, rv interface{}, logs EthereumLogIterator) []interface{}

GetLogs drains logs of EVM log representations. Since those log representations don't fit into a type hierarchy, this API is a bit awkward. It returns the logs as a slice of blank interface{}s, and if rv is non-nil, it must be a pointer to a slice for elements of the same type as the logs, in which case GetLogs will append the logs to it.

func Head(val interface{}) *models.Head

Head given the value convert it into an Head

func Int Uses

func Int(val interface{}) *utils.Big

func JSONFromBytes Uses

func JSONFromBytes(t testing.TB, body []byte) models.JSON

JSONFromBytes creates JSON from a given byte array

func JSONFromFixture Uses

func JSONFromFixture(t *testing.T, path string) models.JSON

JSONFromFixture create models.JSON from file path

func JSONFromString Uses

func JSONFromString(t testing.TB, body string, args ...interface{}) models.JSON

JSONFromString create JSON from given body and arguments

func JSONResultFromFixture Uses

func JSONResultFromFixture(t *testing.T, path string) models.JSON

JSONResultFromFixture create model.JSON with params.result found in the given file path

func JobRunStays Uses

func JobRunStays(
    t testing.TB,
    store *strpkg.Store,
    jr models.JobRun,
    status models.RunStatus,
    optionalDuration ...time.Duration,
) models.JobRun

JobRunStays tests if a JobRun will consistently stay at the specified status

func JobRunStaysPendingIncomingConfirmations Uses

func JobRunStaysPendingIncomingConfirmations(
    t testing.TB,
    store *strpkg.Store,
    jr models.JobRun,
) models.JobRun

JobRunStaysPendingIncomingConfirmations tests if a JobRun will stay at the PendingIncomingConfirmations Status

func LogFromFixture Uses

func LogFromFixture(t *testing.T, path string) eth.Log

LogFromFixture create ethtypes.log from file path

func MakeRoundStateReturnData Uses

func MakeRoundStateReturnData(
    roundID uint64,
    eligible bool,
    answer, startAt, timeout, availableFunds, paymentAmount, oracleCount uint64,
) string

func MustAllJobsWithStatus Uses

func MustAllJobsWithStatus(t testing.TB, store *strpkg.Store, statuses ...models.RunStatus) []*models.JobRun

func MustEVMUintHexFromBase10String Uses

func MustEVMUintHexFromBase10String(t *testing.T, strings ...string) string

func MustGenerateSessionCookie Uses

func MustGenerateSessionCookie(value string) *http.Cookie

func MustHelloWorldAgreement Uses

func MustHelloWorldAgreement(t *testing.T) string

MustHelloWorldAgreement returns the fixture hello world agreement

func MustJSONDel Uses

func MustJSONDel(t *testing.T, json, path string) string

MustJSONDel uses sjson.Delete to remove a path from a JSON string and returns the string

func MustJSONSet Uses

func MustJSONSet(t *testing.T, json, path string, value interface{}) string

MustJSONSet uses sjson.Set to set a path in a JSON string and returns the string See https://github.com/tidwall/sjson

func MustNewUser Uses

func MustNewUser(t *testing.T, email, password string) models.User

func MustParseDuration Uses

func MustParseDuration(t testing.TB, durationStr string) time.Duration

func MustParseURL Uses

func MustParseURL(input string) *url.URL

func MustRandomUser Uses

func MustRandomUser() models.User

func MustReadFile Uses

func MustReadFile(t testing.TB, file string) []byte

MustReadFile loads a file but should never fail

func MustResultString Uses

func MustResultString(t *testing.T, input models.RunResult) string

func NewAddress Uses

func NewAddress() common.Address

NewAddress return a random new address

func NewBridgeType Uses

func NewBridgeType(t testing.TB, info ...string) (*models.BridgeTypeAuthentication, *models.BridgeType)

NewBridgeType create new bridge type given info slice

func NewEth Uses

func NewEth(t *testing.T, amount string) *assets.Eth

func NewEthBlockHeader Uses

func NewEthBlockHeader(height interface{}) eth.BlockHeader

func NewHTTPMockServer Uses

func NewHTTPMockServer(
    t *testing.T,
    status int,
    wantMethod string,
    response string,
    callback ...func(http.Header, string),
) (*httptest.Server, func())

NewHTTPMockServer create http test server with passed in parameters

func NewHTTPMockServerWithAlterableResponse Uses

func NewHTTPMockServerWithAlterableResponse(
    t *testing.T, response func() string) (server *httptest.Server)

func NewHash Uses

func NewHash() common.Hash

NewHash return random Keccak256

func NewJob Uses

func NewJob() models.JobSpec

NewJob return new NoOp JobSpec

func NewJobRun Uses

func NewJobRun(job models.JobSpec) models.JobRun

NewJobRun returns a newly initialized job run for test purposes only

func NewJobRunPendingBridge Uses

func NewJobRunPendingBridge(job models.JobSpec) models.JobRun

NewJobRunPendingBridge returns a new job run in the pending bridge state

func NewJobWithExternalInitiator Uses

func NewJobWithExternalInitiator(ei *models.ExternalInitiator) models.JobSpec

NewJobWithExternalInitiator creates new Job with external initiator

func NewJobWithFluxMonitorInitiator Uses

func NewJobWithFluxMonitorInitiator() models.JobSpec

NewJobWithFluxMonitorInitiator create new Job with FluxMonitor initiator

func NewJobWithFluxMonitorInitiatorWithBridge Uses

func NewJobWithFluxMonitorInitiatorWithBridge() models.JobSpec

NewJobWithFluxMonitorInitiator create new Job with FluxMonitor initiator

func NewJobWithLogInitiator Uses

func NewJobWithLogInitiator() models.JobSpec

NewJobWithLogInitiator create new Job with ethlog initiator

func NewJobWithRunAtInitiator Uses

func NewJobWithRunAtInitiator(t time.Time) models.JobSpec

NewJobWithRunAtInitiator create new Job with RunAt initiator

func NewJobWithRunLogInitiator Uses

func NewJobWithRunLogInitiator() models.JobSpec

NewJobWithRunLogInitiator creates a new JobSpec with the RunLog initiator

func NewJobWithSALogInitiator Uses

func NewJobWithSALogInitiator() models.JobSpec

NewJobWithSALogInitiator creates new JobSpec with the ServiceAgreement initiator

func NewJobWithSchedule Uses

func NewJobWithSchedule(sched string) models.JobSpec

NewJobWithSchedule create new job with the given schedule

func NewJobWithWebInitiator Uses

func NewJobWithWebInitiator() models.JobSpec

NewJobWithWebInitiator create new Job with web initiator

func NewLink(t *testing.T, amount string) *assets.Link

func NewMockAuthenticatedHTTPClient Uses

func NewMockAuthenticatedHTTPClient(cfg orm.ConfigReader, sessionID string) cmd.HTTPClient

func NewPollingDeviationChecker Uses

func NewPollingDeviationChecker(t *testing.T, s *strpkg.Store) *fluxmonitor.PollingDeviationChecker

func NewRandomInt64 Uses

func NewRandomInt64() int64

func NewRandomnessRequestLog Uses

func NewRandomnessRequestLog(t *testing.T, r vrf.RandomnessRequestLog,
    emitter common.Address, blk int) eth.Log

NewRandomnessRequestLog(t, r, emitter, blk) is a RandomnessRequest log for the randomness request log represented by r.

func NewRunInput Uses

func NewRunInput(value models.JSON) models.RunInput

func NewRunInputWithResult Uses

func NewRunInputWithResult(value interface{}) models.RunInput

func NewRunInputWithResultAndJobRunID Uses

func NewRunInputWithResultAndJobRunID(value interface{}, jobRunID *models.ID) models.RunInput

func NewRunInputWithString Uses

func NewRunInputWithString(t testing.TB, value string) models.RunInput

func NewRunLog Uses

func NewRunLog(
    t *testing.T,
    jobID *models.ID,
    emitter common.Address,
    requester common.Address,
    blk int,
    json string,
) eth.Log

NewRunLog create eth.Log for given jobid, address, block, and json

func NewServiceAgreementExecutionLog Uses

func NewServiceAgreementExecutionLog(
    t *testing.T,
    jobID *models.ID,
    logEmitter common.Address,
    executionRequester common.Address,
    blockHeight int,
    serviceAgreementJSON string,
) eth.Log

NewServiceAgreementExecutionLog creates a log event for the given jobid, address, block, and json, to simulate a request for execution on a service agreement.

func NewSession Uses

func NewSession(optionalSessionID ...string) models.Session

func NewStore Uses

func NewStore(t testing.TB) (*strpkg.Store, func())

NewStore creates a new store

func NewStoreWithConfig Uses

func NewStoreWithConfig(config *TestConfig) (*strpkg.Store, func())

NewStoreWithConfig creates a new store with given config

func NewTask Uses

func NewTask(t *testing.T, taskType string, json ...string) models.TaskSpec

NewTask given the tasktype and json params return a TaskSpec

func NewTransaction Uses

func NewTransaction(nonce uint64, sentAtV ...uint64) *models.Tx

func NewTx Uses

func NewTx(from common.Address, sentAt uint64) *models.Tx

NewTx returns a Tx using a specified from address and sentAt

func NewWSServer Uses

func NewWSServer(msg string) (*httptest.Server, func())

NewWSServer returns a new wsserver

func NormalizedJSON Uses

func NormalizedJSON(t testing.TB, input []byte) string

func NullableTime Uses

func NullableTime(t time.Time) null.Time

NullableTime will return a valid nullable time given time.Time

func ParseISO8601 Uses

func ParseISO8601(t testing.TB, s string) time.Time

ParseISO8601 given the time string it Must parse the time and return it

func ParseJSON Uses

func ParseJSON(t testing.TB, body io.Reader) models.JSON

func ParseJSONAPIErrors Uses

func ParseJSONAPIErrors(t testing.TB, body io.Reader) *models.JSONAPIErrors

func ParseJSONAPIResponse Uses

func ParseJSONAPIResponse(t testing.TB, resp *http.Response, resource interface{}) error

ParseJSONAPIResponse parses the response and returns the JSONAPI resource.

func ParseJSONAPIResponseMeta Uses

func ParseJSONAPIResponseMeta(input []byte) (map[string]*json.RawMessage, error)

ParseJSONAPIResponseMeta parses the bytes of the root document and returns a map of *json.RawMessage's within the 'meta' key.

func ParseJSONAPIResponseMetaCount Uses

func ParseJSONAPIResponseMetaCount(input []byte) (int, error)

ParseJSONAPIResponseMetaCount parses the bytes of the root document and returns the value of the 'count' key from the 'meta' section.

func ParseNullableTime Uses

func ParseNullableTime(t testing.TB, s string) null.Time

ParseNullableTime given a time string parse it into a null.Time

func ParseResponseBody Uses

func ParseResponseBody(t testing.TB, resp *http.Response) []byte

ParseResponseBody will parse the given response into a byte slice

func ReadLogs Uses

func ReadLogs(config orm.ConfigReader) (string, error)

ReadLogs returns the contents of the applications log file as a string

func ServiceAgreementFromString Uses

func ServiceAgreementFromString(str string) (models.ServiceAgreement, error)

func StoredVRFKey Uses

func StoredVRFKey(t *testing.T, store *strpkg.Store) *vrfkey.PublicKey

StoredVRFKey creates a VRFKeyStore on store, imports a known VRF key into it, and returns the corresponding public key.

func StringToHash Uses

func StringToHash(s string) common.Hash

func StringToVersionedLogData0 Uses

func StringToVersionedLogData0(t *testing.T, internalID, str string) []byte

func StringToVersionedLogData20190123withFulfillmentParams Uses

func StringToVersionedLogData20190123withFulfillmentParams(t *testing.T, internalID, str string) []byte

func StringToVersionedLogData20190207withoutIndexes Uses

func StringToVersionedLogData20190207withoutIndexes(
    t *testing.T,
    internalID string,
    requester common.Address,
    str string,
) []byte

func TxReceiptFromFixture Uses

func TxReceiptFromFixture(t *testing.T, path string) eth.TxReceipt

TxReceiptFromFixture create ethtypes.log from file path

func UnauthenticatedPatch Uses

func UnauthenticatedPatch(t testing.TB, url string, body io.Reader, headers map[string]string) (*http.Response, func())

func UnauthenticatedPost Uses

func UnauthenticatedPost(t testing.TB, url string, body io.Reader, headers map[string]string) (*http.Response, func())

func UpdateJobRunViaWeb Uses

func UpdateJobRunViaWeb(
    t testing.TB,
    app *TestApplication,
    jr models.JobRun,
    bta *models.BridgeTypeAuthentication,
    body string,
) models.JobRun

UpdateJobRunViaWeb updates jobrun via web using /v2/runs/ID

func WaitForJobRunStatus Uses

func WaitForJobRunStatus(
    t testing.TB,
    store *strpkg.Store,
    jr models.JobRun,
    status models.RunStatus,
) models.JobRun

WaitForJobRunStatus waits for a JobRun to reach given status

func WaitForJobRunToComplete Uses

func WaitForJobRunToComplete(
    t testing.TB,
    store *strpkg.Store,
    jr models.JobRun,
) models.JobRun

WaitForJobRunToComplete waits for a JobRun to reach Completed Status

func WaitForJobRunToPendBridge Uses

func WaitForJobRunToPendBridge(
    t testing.TB,
    store *strpkg.Store,
    jr models.JobRun,
) models.JobRun

WaitForJobRunToPendBridge waits for a JobRun to reach PendingBridge Status

func WaitForJobRunToPendIncomingConfirmations Uses

func WaitForJobRunToPendIncomingConfirmations(
    t testing.TB,
    store *strpkg.Store,
    jr models.JobRun,
) models.JobRun

WaitForJobRunToPendIncomingConfirmations waits for a JobRun to reach PendingIncomingConfirmations Status

func WaitForJobRunToPendOutgoingConfirmations Uses

func WaitForJobRunToPendOutgoingConfirmations(
    t testing.TB,
    store *strpkg.Store,
    jr models.JobRun,
) models.JobRun

WaitForJobRunToPendOutgoingConfirmations waits for a JobRun to reach PendingOutgoingConfirmations Status

func WaitForRuns Uses

func WaitForRuns(t testing.TB, j models.JobSpec, store *strpkg.Store, want int) []models.JobRun

WaitForRuns waits for the wanted number of runs then returns a slice of the JobRuns

func WaitForRunsAtLeast Uses

func WaitForRunsAtLeast(t testing.TB, j models.JobSpec, store *strpkg.Store, want int)

WaitForRunsAtLeast waits for at least the passed number of runs to start.

func WaitForSyncEventCount Uses

func WaitForSyncEventCount(
    t testing.TB,
    orm *orm.ORM,
    want int,
)

WaitForSyncEventCount checks if the sync event count eventually reaches the amound specified in parameter want.

func WaitForTxAttemptCount Uses

func WaitForTxAttemptCount(t testing.TB, store *strpkg.Store, want int) []models.TxAttempt

func WebURL Uses

func WebURL(t testing.TB, unparsed string) models.WebURL

WebURL parses a url into a models.WebURL

type BlockedRunner Uses

type BlockedRunner struct {
    Done chan struct{}
}

BlockedRunner is a Runner that blocks until its channel is posted to

func (BlockedRunner) Run Uses

func (r BlockedRunner) Run(app chainlink.Application) error

Run runs the blocked runner, doesn't return until the channel is signalled

type CallbackAuthenticator Uses

type CallbackAuthenticator struct {
    Callback func(*store.Store, string) (string, error)
}

CallbackAuthenticator contains a call back authenticator method

func (CallbackAuthenticator) Authenticate Uses

func (a CallbackAuthenticator) Authenticate(store *store.Store, pwd string) (string, error)

Authenticate authenticates store and pwd with the callback authenticator

func (CallbackAuthenticator) AuthenticateVRFKey Uses

func (a CallbackAuthenticator) AuthenticateVRFKey(*store.Store, string) error

type EmptyRunner Uses

type EmptyRunner struct{}

EmptyRunner is an EmptyRunner

func (EmptyRunner) Run Uses

func (r EmptyRunner) Run(app chainlink.Application) error

Run runs the empty runner

type EthMock Uses

type EthMock struct {
    Responses     []MockResponse
    Subscriptions []*MockSubscription
    // contains filtered or unexported fields
}

EthMock is a mock ethereum client

func MockEthOnStore Uses

func MockEthOnStore(t testing.TB, s *store.Store, flags ...string) *EthMock

MockEthOnStore given store return new EthMock Client

func (*EthMock) AllCalled Uses

func (mock *EthMock) AllCalled() bool

AllCalled return true if all mocks have been mocked

func (*EthMock) AssertAllCalled Uses

func (mock *EthMock) AssertAllCalled()

AssertAllCalled immediately checks that all calls have been made

func (*EthMock) Call Uses

func (mock *EthMock) Call(result interface{}, method string, args ...interface{}) error

Call will call given method and set the result

func (*EthMock) Context Uses

func (mock *EthMock) Context(context string, callback func(*EthMock))

Context adds helpful context to EthMock values set in the callback function.

func (*EthMock) Dial Uses

func (mock *EthMock) Dial(url string) (eth.CallerSubscriber, error)

Dial mock dial

func (*EthMock) EventuallyAllCalled Uses

func (mock *EthMock) EventuallyAllCalled(t *testing.T)

EventuallyAllCalled eventually will return after all the mock subscriptions and responses are called

func (*EthMock) Register Uses

func (mock *EthMock) Register(
    method string,
    response interface{},
    callback ...func(interface{}, ...interface{}) error,
)

Register register mock responses and append to Ethmock

func (*EthMock) RegisterError Uses

func (mock *EthMock) RegisterError(method, errMsg string)

RegisterError register mock errors to EthMock

func (*EthMock) RegisterNewHead Uses

func (mock *EthMock) RegisterNewHead(blockNumber int64) chan eth.BlockHeader

RegisterNewHead register new head at given blocknumber

func (*EthMock) RegisterNewHeads Uses

func (mock *EthMock) RegisterNewHeads() chan eth.BlockHeader

RegisterNewHeads registers a newheads subscription

func (*EthMock) RegisterSubscription Uses

func (mock *EthMock) RegisterSubscription(name string, channels ...interface{}) *MockSubscription

RegisterSubscription register a mock subscription to the given name and channels

func (*EthMock) Remaining Uses

func (mock *EthMock) Remaining() string

func (*EthMock) ShouldCall Uses

func (mock *EthMock) ShouldCall(setup func(mock *EthMock)) ethMockDuring

func (*EthMock) Subscribe Uses

func (mock *EthMock) Subscribe(
    ctx context.Context,
    channel interface{},
    args ...interface{},
) (eth.Subscription, error)

Subscribe registers a subscription to the channel

type EthereumLogIterator Uses

type EthereumLogIterator interface{ Next() bool }

EthereumLogIterator is the interface provided by gethwrapper representations of EVM logs.

type EventWebSocketServer Uses

type EventWebSocketServer struct {
    *httptest.Server

    Connected chan struct{}
    Received  chan string
    URL       *url.URL
    // contains filtered or unexported fields
}

EventWebSocketServer is a web socket server designed specifically for testing

func NewEventWebSocketServer Uses

func NewEventWebSocketServer(t *testing.T) (*EventWebSocketServer, func())

NewEventWebSocketServer returns a new EventWebSocketServer

func (*EventWebSocketServer) Broadcast Uses

func (wss *EventWebSocketServer) Broadcast(message string) error

Broadcast sends a message to every web socket client connected to the EventWebSocketServer

func (*EventWebSocketServer) WriteCloseMessage Uses

func (wss *EventWebSocketServer) WriteCloseMessage()

WriteCloseMessage tells connected clients to disconnect. Useful to emulate that the websocket server is shutting down without actually shutting down. This overcomes httptest.Server's inability to restart on the same URL:port.

type HTTPClientCleaner Uses

type HTTPClientCleaner struct {
    HTTPClient cmd.HTTPClient
    // contains filtered or unexported fields
}

func (*HTTPClientCleaner) Delete Uses

func (r *HTTPClientCleaner) Delete(path string) (*http.Response, func())

func (*HTTPClientCleaner) Get Uses

func (r *HTTPClientCleaner) Get(path string, headers ...map[string]string) (*http.Response, func())

func (*HTTPClientCleaner) Patch Uses

func (r *HTTPClientCleaner) Patch(path string, body io.Reader, headers ...map[string]string) (*http.Response, func())

func (*HTTPClientCleaner) Post Uses

func (r *HTTPClientCleaner) Post(path string, body io.Reader) (*http.Response, func())

func (*HTTPClientCleaner) Put Uses

func (r *HTTPClientCleaner) Put(path string, body io.Reader) (*http.Response, func())

type InstanceAppFactory Uses

type InstanceAppFactory struct {
    App chainlink.Application
}

InstanceAppFactory is an InstanceAppFactory

func (InstanceAppFactory) NewApplication Uses

func (f InstanceAppFactory) NewApplication(config *orm.Config, onConnectCallbacks ...func(chainlink.Application)) chainlink.Application

NewApplication creates a new application with specified config

type InstantClock Uses

type InstantClock struct{}

InstantClock an InstantClock

func (InstantClock) After Uses

func (InstantClock) After(_ time.Duration) <-chan time.Time

After return channel of time

func (InstantClock) Now Uses

func (InstantClock) Now() time.Time

Now returns the current local time

type MemorySink Uses

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

MemorySink implements zap.Sink by writing all messages to a buffer.

func MemoryLogTestingOnly Uses

func MemoryLogTestingOnly() *MemorySink

func (*MemorySink) Close Uses

func (s *MemorySink) Close() error

Close is a dummy method to satisfy the zap.Sink interface

func (*MemorySink) String Uses

func (s *MemorySink) String() string

String returns the full log contents, as a string

func (*MemorySink) Sync Uses

func (s *MemorySink) Sync() error

Sync is a dummy method to satisfy the zap.Sink interface

func (*MemorySink) Write Uses

func (s *MemorySink) Write(p []byte) (n int, err error)

type MockAPIInitializer Uses

type MockAPIInitializer struct {
    Count int
}

func (*MockAPIInitializer) Initialize Uses

func (m *MockAPIInitializer) Initialize(store *store.Store) (models.User, error)

type MockChangePasswordPrompter Uses

type MockChangePasswordPrompter struct {
    models.ChangePasswordRequest
    // contains filtered or unexported fields
}

func (MockChangePasswordPrompter) Prompt Uses

func (m MockChangePasswordPrompter) Prompt() (models.ChangePasswordRequest, error)

type MockCookieAuthenticator Uses

type MockCookieAuthenticator struct {
    SessionID string
    Error     error
}

func (MockCookieAuthenticator) Authenticate Uses

func (m MockCookieAuthenticator) Authenticate(models.SessionRequest) (*http.Cookie, error)

func (MockCookieAuthenticator) Cookie Uses

func (m MockCookieAuthenticator) Cookie() (*http.Cookie, error)

type MockCountingPrompter Uses

type MockCountingPrompter struct {
    T              *testing.T
    EnteredStrings []string
    Count          int
    NotTerminal    bool
}

MockCountingPrompter is a mock counting prompt

func (*MockCountingPrompter) IsTerminal Uses

func (p *MockCountingPrompter) IsTerminal() bool

IsTerminal always returns true in tests

func (*MockCountingPrompter) PasswordPrompt Uses

func (p *MockCountingPrompter) PasswordPrompt(string) string

PasswordPrompt returns an entered string

func (*MockCountingPrompter) Prompt Uses

func (p *MockCountingPrompter) Prompt(string) string

Prompt returns an entered string

type MockCron Uses

type MockCron struct {
    Entries []MockCronEntry
    // contains filtered or unexported fields
}

MockCron represents a mock cron

func NewMockCron Uses

func NewMockCron() *MockCron

NewMockCron returns a new mock cron

func (*MockCron) AddFunc Uses

func (mc *MockCron) AddFunc(schd string, fn func()) (cron.EntryID, error)

AddFunc appends a schedule to mockcron entries

func (*MockCron) RunEntries Uses

func (mc *MockCron) RunEntries()

RunEntries run every function for each mockcron entry

func (*MockCron) Start Uses

func (*MockCron) Start()

Start starts the mockcron

func (*MockCron) Stop Uses

func (*MockCron) Stop() context.Context

Stop stops the mockcron

type MockCronEntry Uses

type MockCronEntry struct {
    Schedule string
    Function func()
}

MockCronEntry a cron schedule and function

type MockHeadTrackable Uses

type MockHeadTrackable struct {
    ConnectedCallback func(bn *models.Head)
    // contains filtered or unexported fields
}

MockHeadTrackable allows you to mock HeadTrackable

func (*MockHeadTrackable) Connect Uses

func (m *MockHeadTrackable) Connect(bn *models.Head) error

Connect increases the connected count by one

func (*MockHeadTrackable) ConnectedCount Uses

func (m *MockHeadTrackable) ConnectedCount() int32

ConnectedCount returns the count of connections made, safely.

func (*MockHeadTrackable) Disconnect Uses

func (m *MockHeadTrackable) Disconnect()

Disconnect increases the disconnected count by one

func (*MockHeadTrackable) DisconnectedCount Uses

func (m *MockHeadTrackable) DisconnectedCount() int32

DisconnectedCount returns the count of disconnections made, safely.

func (*MockHeadTrackable) OnNewLongestChain Uses

func (m *MockHeadTrackable) OnNewLongestChain(models.Head)

OnNewLongestChain increases the OnNewLongestChainCount count by one

func (*MockHeadTrackable) OnNewLongestChainCount Uses

func (m *MockHeadTrackable) OnNewLongestChainCount() int32

OnNewLongestChainCount returns the count of new heads, safely.

type MockPasswordPrompter Uses

type MockPasswordPrompter struct {
    Password string
}

func (MockPasswordPrompter) Prompt Uses

func (m MockPasswordPrompter) Prompt() string

type MockResponse Uses

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

MockResponse a mock response

type MockSessionRequestBuilder Uses

type MockSessionRequestBuilder struct {
    Count int
    Error error
}

func (*MockSessionRequestBuilder) Build Uses

func (m *MockSessionRequestBuilder) Build(string) (models.SessionRequest, error)

type MockSigner Uses

type MockSigner struct{}

func (MockSigner) SignHash Uses

func (s MockSigner) SignHash(common.Hash) (models.Signature, error)

type MockSubscription Uses

type MockSubscription struct {
    Errors chan error
    // contains filtered or unexported fields
}

MockSubscription a mock subscription

func EmptyMockSubscription Uses

func EmptyMockSubscription() *MockSubscription

EmptyMockSubscription return empty MockSubscription

func (*MockSubscription) Err Uses

func (mes *MockSubscription) Err() <-chan error

Err returns error channel from mes

func (*MockSubscription) Unsubscribe Uses

func (mes *MockSubscription) Unsubscribe()

Unsubscribe closes the subscription

type NeverSleeper Uses

type NeverSleeper struct{}

NeverSleeper is a struct that never sleeps

func (NeverSleeper) After Uses

func (ns NeverSleeper) After() time.Duration

After returns a duration

func (NeverSleeper) Duration Uses

func (ns NeverSleeper) Duration() time.Duration

Duration returns a duration

func (NeverSleeper) Reset Uses

func (ns NeverSleeper) Reset()

Reset resets the never sleeper

func (NeverSleeper) Sleep Uses

func (ns NeverSleeper) Sleep()

Sleep puts the never sleeper to sleep

type RendererMock Uses

type RendererMock struct {
    Renders []interface{}
}

RendererMock a mock renderer

func (*RendererMock) Render Uses

func (rm *RendererMock) Render(v interface{}) error

Render appends values to renderer mock

type SimulatedBackendClient Uses

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

SimulatedBackendClient is an eth.SimulatedBackendClient implementation using a simulated blockchain backend. Note that not all RPC methods are implemented here.

func (*SimulatedBackendClient) Call Uses

func (c *SimulatedBackendClient) Call(result interface{}, method string,
    args ...interface{}) error

Call mocks the ethereum client RPC calls used by chainlink, copying the return value into result.

func (*SimulatedBackendClient) Close Uses

func (c *SimulatedBackendClient) Close()

Close terminates the underlying blockchain's update loop.

func (*SimulatedBackendClient) GetBlockByNumber Uses

func (c *SimulatedBackendClient) GetBlockByNumber(hex string) (block eth.Block,
    err error)

GetBlockByNumber returns the block for the passed hex, or "latest", "earliest", "pending". Includes all transactions

func (*SimulatedBackendClient) GetBlockHeight Uses

func (c *SimulatedBackendClient) GetBlockHeight() (height uint64, err error)

GetBlockHeight returns height of latest block in the simulated blockchain.

func (*SimulatedBackendClient) GetChainID Uses

func (c *SimulatedBackendClient) GetChainID() (*big.Int, error)

GetChainID returns the ethereum ChainID.

func (*SimulatedBackendClient) GetERC20Balance Uses

func (c *SimulatedBackendClient) GetERC20Balance(address common.Address,
    contractAddress common.Address) (balance *big.Int, err error)

GetERC20Balance returns the balance of the given address for the token contract address.

func (*SimulatedBackendClient) GetEthBalance Uses

func (c *SimulatedBackendClient) GetEthBalance(address common.Address,
) (balance *assets.Eth, err error)

GetEthBalance returns the balance of the given addresses in Ether.

func (*SimulatedBackendClient) GetLatestBlock Uses

func (client *SimulatedBackendClient) GetLatestBlock() (eth.Block, error)

GetLatestBlock returns the last committed block of the best blockchain the blockchain node is aware of.

func (*SimulatedBackendClient) GetLogs Uses

func (c *SimulatedBackendClient) GetLogs(q ethereum.FilterQuery) (logs []eth.Log,
    err error)

GetLogs returns all logs that respect the passed filter query.

func (*SimulatedBackendClient) GetNonce Uses

func (c *SimulatedBackendClient) GetNonce(address common.Address) (nonce uint64, err error)

GetNonce returns the nonce (transaction count) for a given address.

func (*SimulatedBackendClient) GetTxReceipt Uses

func (c *SimulatedBackendClient) GetTxReceipt(
    receipt common.Hash) (*eth.TxReceipt, error)

GetTxReceipt returns the transaction receipt for the given transaction hash.

func (*SimulatedBackendClient) SendRawTx Uses

func (c *SimulatedBackendClient) SendRawTx(
    txBytes []byte) (txHash common.Hash, err error)

SendRawTx sends a signed transaction to the transaction pool.

func (*SimulatedBackendClient) Subscribe Uses

func (c *SimulatedBackendClient) Subscribe(ctx context.Context, namespace interface{},
    channelAndArgs ...interface{}) (eth.Subscription, error)

Subscribe is a dummy method present only to satisfy the eth.Client interface. The original method is for subscribing to events observed by the RPC client, but for a simulated backend that makes no sense.

func (*SimulatedBackendClient) SubscribeToLogs Uses

func (c *SimulatedBackendClient) SubscribeToLogs(ctx context.Context, channel chan<- eth.Log,
    q ethereum.FilterQuery) (eth.Subscription, error)

SubscribeToLogs registers a subscription for push notifications of logs from a given address.

func (*SimulatedBackendClient) SubscribeToNewHeads Uses

func (c *SimulatedBackendClient) SubscribeToNewHeads(ctx context.Context,
    channel chan<- eth.BlockHeader) (eth.Subscription, error)

SubscribeToNewHeads registers a subscription for push notifications of new blocks.

type TestApplication Uses

type TestApplication struct {
    *chainlink.ChainlinkApplication
    Config *TestConfig
    Server *httptest.Server

    Started bool
    EthMock *EthMock
    Backend *backends.SimulatedBackend
    // contains filtered or unexported fields
}

TestApplication holds the test application and test servers

func NewApplication Uses

func NewApplication(t testing.TB, flags ...string) (*TestApplication, func())

NewApplication creates a New TestApplication along with a NewConfig It mocks the keystore with no keys or accounts by default

func NewApplicationWithConfig Uses

func NewApplicationWithConfig(t testing.TB, tc *TestConfig, flags ...string) (*TestApplication, func())

NewApplicationWithConfig creates a New TestApplication with specified test config

func NewApplicationWithConfigAndKey Uses

func NewApplicationWithConfigAndKey(t testing.TB, tc *TestConfig, flags ...string) (*TestApplication, func())

NewApplicationWithConfigAndKey creates a new TestApplication with the given testconfig it will also provide an unlocked account on the keystore

func NewApplicationWithConfigAndKeyOnSimulatedBlockchain Uses

func NewApplicationWithConfigAndKeyOnSimulatedBlockchain(
    t testing.TB, tc *TestConfig, backend *backends.SimulatedBackend,
    flags ...string) (app *TestApplication, cleanup func())

func NewApplicationWithKey Uses

func NewApplicationWithKey(t testing.TB, flags ...string) (*TestApplication, func())

NewApplicationWithKey creates a new TestApplication along with a new config It uses the native keystore and will load any keys that are in the database

func (*TestApplication) AddUnlockedKey Uses

func (ta *TestApplication) AddUnlockedKey()

func (*TestApplication) ImportKey Uses

func (ta *TestApplication) ImportKey(content string)

ImportKey adds private key to the application disk keystore, not database.

func (*TestApplication) InstantClock Uses

func (ta *TestApplication) InstantClock() InstantClock

InstantClock create InstantClock

func (*TestApplication) MockCallerSubscriberClient Uses

func (ta *TestApplication) MockCallerSubscriberClient(flags ...string) *EthMock

MockCallerSubscriberClient create new EthMock Client

func (*TestApplication) MustCreateJobRun Uses

func (ta *TestApplication) MustCreateJobRun(txHashBytes []byte, blockHashBytes []byte) *models.JobRun

func (*TestApplication) MustSeedNewSession Uses

func (ta *TestApplication) MustSeedNewSession() string

func (*TestApplication) NewAuthenticatingClient Uses

func (ta *TestApplication) NewAuthenticatingClient(prompter cmd.Prompter) *cmd.Client

func (*TestApplication) NewBox Uses

func (ta *TestApplication) NewBox() packr.Box

func (*TestApplication) NewClientAndRenderer Uses

func (ta *TestApplication) NewClientAndRenderer() (*cmd.Client, *RendererMock)

NewClientAndRenderer creates a new cmd.Client for the test application

func (*TestApplication) NewHTTPClient Uses

func (ta *TestApplication) NewHTTPClient() HTTPClientCleaner

func (*TestApplication) Start Uses

func (ta *TestApplication) Start() error

func (*TestApplication) StartAndConnect Uses

func (ta *TestApplication) StartAndConnect() error

func (*TestApplication) Stop Uses

func (ta *TestApplication) Stop() error

Stop will stop the test application and perform cleanup

type TestConfig Uses

type TestConfig struct {
    *orm.Config
    // contains filtered or unexported fields
}

TestConfig struct with test store and wsServer

func BootstrapThrowawayORM Uses

func BootstrapThrowawayORM(t *testing.T, name string, migrate bool) (*TestConfig, *orm.ORM, func())

BootstrapThrowawayORM creates an ORM which runs in a separate database than the normal unit tests, so it you can do things like use other Postgres connection types with it.

func NewConfig Uses

func NewConfig(t testing.TB) (*TestConfig, func())

NewConfig returns a new TestConfig

func NewConfigWithWSServer Uses

func NewConfigWithWSServer(t testing.TB, wsserver *httptest.Server) *TestConfig

NewConfigWithWSServer return new config with specified wsserver

func NewTestConfig Uses

func NewTestConfig(t testing.TB, options ...interface{}) *TestConfig

NewTestConfig returns a test configuration

func (*TestConfig) SetEthereumServer Uses

func (tc *TestConfig) SetEthereumServer(wss *httptest.Server)

SetEthereumServer sets the ethereum server for testconfig with given wsserver

type TriggerClock Uses

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

TriggerClock implements the AfterNower interface, but must be manually triggered to resume computation on After.

func NewTriggerClock Uses

func NewTriggerClock(t testing.TB) *TriggerClock

NewTriggerClock returns a new TriggerClock, that a test can manually fire to continue processing in a Clock dependency.

func (*TriggerClock) After Uses

func (t *TriggerClock) After(_ time.Duration) <-chan time.Time

After waits on a manual trigger.

func (TriggerClock) Now Uses

func (t TriggerClock) Now() time.Time

Now returns the current local time

func (*TriggerClock) Trigger Uses

func (t *TriggerClock) Trigger()

Trigger sends a time to unblock the After call.

func (*TriggerClock) TriggerWithoutTimeout Uses

func (t *TriggerClock) TriggerWithoutTimeout()

TriggerWithoutTimeout is a special case where we know the trigger might block but don't care

Package cltest imports 76 packages (graph). Updated 2020-05-29. Refresh now. Tools for package owners.