Documentation ¶
Index ¶
- Constants
- func AllJobs(t testing.TB, store *strpkg.Store) []models.JobSpec
- func AssertError(t testing.TB, want bool, err error)
- func AssertServerResponse(t testing.TB, resp *http.Response, expectedStatusCode int)
- func AssertSyncEventCountStays(t testing.TB, orm *orm.ORM, want int)
- func AssertValidHash(t testing.TB, length int, hash string)
- func BigHexInt(val interface{}) hexutil.Big
- func BuildInitiatorRequests(t *testing.T, initrs []models.Initiator) []models.InitiatorRequest
- func BuildTaskRequests(t *testing.T, initrs []models.TaskSpec) []models.TaskSpecRequest
- func CallbackOrTimeout(t testing.TB, msg string, callback func(), durationParams ...time.Duration)
- func CopyFile(t testing.TB, src, dst string)
- func CreateBridgeTypeViaWeb(t testing.TB, app *TestApplication, payload string) *models.BridgeTypeAuthentication
- func CreateHelloWorldJobViaWeb(t testing.TB, app *TestApplication, url string) models.JobSpec
- func CreateJobRunViaWeb(t testing.TB, app *TestApplication, j models.JobSpec, body ...string) models.JobRun
- func CreateJobRunWithStatus(t testing.TB, store *store.Store, j models.JobSpec, status models.RunStatus) models.JobRun
- func CreateJobSpecViaWeb(t testing.TB, app *TestApplication, job models.JobSpec) models.JobSpec
- func CreateSpecViaWeb(t testing.TB, app *TestApplication, spec string) models.JobSpec
- func CreateTx(t testing.TB, store *strpkg.Store, from common.Address, sentAt uint64) *models.Tx
- func DecodeSessionCookie(value string) (string, error)
- func EmptyCLIContext() *cli.Context
- func ExtractTargetAddressFromERC20EthEthCallMock(t *testing.T, arg ...interface{}) common.Address
- func FindJob(t testing.TB, s *strpkg.Store, id string) models.JobSpec
- func FindJobRun(t testing.TB, s *strpkg.Store, id string) models.JobRun
- func FindServiceAgreement(t testing.TB, s *strpkg.Store, id string) models.ServiceAgreement
- func FixtureCreateJobViaWeb(t *testing.T, app *TestApplication, path string) models.JobSpec
- func FixtureCreateServiceAgreementViaWeb(t *testing.T, app *TestApplication, path string) models.ServiceAgreement
- func GetAccountAddress(t testing.TB, store *strpkg.Store) common.Address
- func GetAccountAddresses(store *strpkg.Store) []common.Address
- func GetLastTxAttempt(t testing.TB, store *strpkg.Store) models.TxAttempt
- func Head(val interface{}) *models.Head
- func Int(val interface{}) *models.Big
- func JSONFromBytes(t testing.TB, body []byte) models.JSON
- func JSONFromFixture(t *testing.T, path string) models.JSON
- func JSONFromString(t testing.TB, body string, args ...interface{}) models.JSON
- func JSONResultFromFixture(t *testing.T, path string) models.JSON
- func JobRunStays(t testing.TB, store *strpkg.Store, jr models.JobRun, status models.RunStatus, ...) models.JobRun
- func JobRunStaysPendingConfirmations(t testing.TB, store *strpkg.Store, jr models.JobRun) models.JobRun
- func LogFromFixture(t *testing.T, path string) models.Log
- func MarkJobRunPendingBridge(jr models.JobRun, i int) models.JobRun
- func MustAllJobsWithStatus(t testing.TB, store *strpkg.Store, statuses ...models.RunStatus) []*models.JobRun
- func MustGenerateSessionCookie(value string) *http.Cookie
- func MustJSONDel(t *testing.T, json, path string) string
- func MustJSONSet(t *testing.T, json, path string, value interface{}) string
- func MustParseDuration(t testing.TB, durationStr string) time.Duration
- func MustParseURL(input string) *url.URL
- func MustReadFile(t testing.TB, file string) []byte
- func MustSha256(in string) string
- func MustUser(email, pwd string) models.User
- func NewAddress() common.Address
- func NewBigHexInt(val interface{}) *hexutil.Big
- func NewBlockHeader(number int) *models.BlockHeader
- func NewBridgeType(t testing.TB, info ...string) (*models.BridgeTypeAuthentication, *models.BridgeType)
- func NewHTTPMockServer(t *testing.T, status int, wantMethod string, response string, ...) (*httptest.Server, func())
- func NewHash() common.Hash
- func NewJob() models.JobSpec
- func NewJobRunner(s *strpkg.Store) (services.JobRunner, func())
- func NewJobSubscriber(t testing.TB) (*strpkg.Store, services.JobSubscriber, func())
- func NewJobWithLogInitiator() models.JobSpec
- func NewJobWithRunAtInitiator(t time.Time) models.JobSpec
- func NewJobWithRunLogInitiator() models.JobSpec
- func NewJobWithSALogInitiator() models.JobSpec
- func NewJobWithSchedule(sched string) models.JobSpec
- func NewJobWithWebInitiator() models.JobSpec
- func NewMockAuthenticatedHTTPClient(cfg store.Config) cmd.HTTPClient
- func NewRunLog(t *testing.T, jobID string, emitter common.Address, requester common.Address, ...) models.Log
- func NewServiceAgreementExecutionLog(t *testing.T, jobID string, logEmitter common.Address, ...) models.Log
- func NewSession(optionalSessionID ...string) models.Session
- func NewStore(t testing.TB) (*strpkg.Store, func())
- func NewStoreWithConfig(config *TestConfig) (*strpkg.Store, func())
- func NewTask(t *testing.T, taskType string, json ...string) models.TaskSpec
- func NewTx(from common.Address, sentAt uint64) *models.Tx
- func NewWSServer(msg string) (*httptest.Server, func())
- func NormalizedJSON(t testing.TB, input []byte) string
- func NullString(val interface{}) null.String
- func NullTime(t testing.TB, val interface{}) null.Time
- func NullableTime(t time.Time) null.Time
- func ObserveLogs() *observer.ObservedLogs
- func ParseISO8601(t testing.TB, s string) time.Time
- func ParseJSON(t testing.TB, body io.Reader) models.JSON
- func ParseJSONAPIErrors(t testing.TB, body io.Reader) *models.JSONAPIErrors
- func ParseJSONAPIResponse(t testing.TB, resp *http.Response, resource interface{}) error
- func ParseJSONAPIResponseMeta(input []byte) (map[string]*json.RawMessage, error)
- func ParseJSONAPIResponseMetaCount(input []byte) (int, error)
- func ParseNullableTime(t testing.TB, s string) null.Time
- func ParseResponseBody(t testing.TB, resp *http.Response) []byte
- func ReadLogs(app *TestApplication) (string, error)
- func RunResultWithData(val string) models.RunResult
- func RunResultWithDataAndLinkPayout(val string, amt *assets.Link) models.RunResult
- func RunResultWithError(err error) models.RunResult
- func RunResultWithResult(val string) models.RunResult
- func ServiceAgreementFromString(str string) (models.ServiceAgreement, error)
- func StringToHash(s string) common.Hash
- func StringToVersionedLogData0(t *testing.T, internalID, str string) []byte
- func StringToVersionedLogData20190123withFulfillmentParams(t *testing.T, internalID, str string) []byte
- func StringToVersionedLogData20190207withoutIndexes(t *testing.T, internalID string, requester common.Address, str string) []byte
- func TxReceiptFromFixture(t *testing.T, path string) models.TxReceipt
- func UnauthenticatedPatch(t testing.TB, url string, body io.Reader, headers map[string]string) (*http.Response, func())
- func UpdateJobRunViaWeb(t testing.TB, app *TestApplication, jr models.JobRun, ...) models.JobRun
- func WaitForJobRunStatus(t testing.TB, store *strpkg.Store, jr models.JobRun, status models.RunStatus) models.JobRun
- func WaitForJobRunToComplete(t testing.TB, store *strpkg.Store, jr models.JobRun) models.JobRun
- func WaitForJobRunToPendBridge(t testing.TB, store *strpkg.Store, jr models.JobRun) models.JobRun
- func WaitForJobRunToPendConfirmations(t testing.TB, store *strpkg.Store, jr models.JobRun) models.JobRun
- func WaitForJobRunToPendSleep(t testing.TB, store *strpkg.Store, jr models.JobRun) models.JobRun
- func WaitForJobs(t testing.TB, store *strpkg.Store, want int) []models.JobSpec
- func WaitForRuns(t testing.TB, j models.JobSpec, store *strpkg.Store, want int) []models.JobRun
- func WaitForRunsAtLeast(t testing.TB, j models.JobSpec, store *strpkg.Store, want int)
- func WaitForSyncEventCount(t testing.TB, orm *orm.ORM, want int)
- func WaitForTxAttemptCount(t testing.TB, store *strpkg.Store, want int) []models.TxAttempt
- func WebURL(t testing.TB, unparsed string) models.WebURL
- func WipePostgresDatabase(t testing.TB, c strpkg.Config)
- type BlockedRunner
- type CallbackAuthenticator
- type CommonJSON
- type EmptyRunner
- type ErrorsJSON
- type EthMock
- func (mock *EthMock) AllCalled() bool
- func (mock *EthMock) AssertAllCalled()
- func (mock *EthMock) Call(result interface{}, method string, args ...interface{}) error
- func (mock *EthMock) Clear()
- func (mock *EthMock) Context(context string, callback func(*EthMock))
- func (mock *EthMock) Dial(url string) (store.CallerSubscriber, error)
- func (mock *EthMock) EthSubscribe(ctx context.Context, channel interface{}, args ...interface{}) (models.EthSubscription, error)
- func (mock *EthMock) EventuallyAllCalled(t *testing.T)
- func (mock *EthMock) NoMagic()
- func (mock *EthMock) Register(method string, response interface{}, ...)
- func (mock *EthMock) RegisterError(method, errMsg string)
- func (mock *EthMock) RegisterNewHead(blockNumber int64) chan models.BlockHeader
- func (mock *EthMock) RegisterNewHeads() chan models.BlockHeader
- func (mock *EthMock) RegisterSubscription(name string, channels ...interface{}) MockSubscription
- func (mock *EthMock) Remaining() string
- func (mock *EthMock) ShouldCall(setup func(mock *EthMock)) ethMockDuring
- type EventWebSocketServer
- type HTTPClientCleaner
- func (r *HTTPClientCleaner) Delete(path string) (*http.Response, func())
- func (r *HTTPClientCleaner) Get(path string, headers ...map[string]string) (*http.Response, func())
- func (r *HTTPClientCleaner) Patch(path string, body io.Reader, headers ...map[string]string) (*http.Response, func())
- func (r *HTTPClientCleaner) Post(path string, body io.Reader) (*http.Response, func())
- type InstanceAppFactory
- type InstantClock
- type MockAPIInitializer
- type MockChangePasswordPrompter
- type MockCookieAuthenticator
- type MockCountingPrompter
- type MockCron
- type MockCronEntry
- type MockHeadTrackable
- func (m *MockHeadTrackable) Connect(bn *models.Head) error
- func (m *MockHeadTrackable) ConnectedCount() int32
- func (m *MockHeadTrackable) Disconnect()
- func (m *MockHeadTrackable) DisconnectedCount() int32
- func (m *MockHeadTrackable) OnNewHead(*models.Head)
- func (m *MockHeadTrackable) OnNewHeadCount() int32
- type MockPasswordPrompter
- type MockResponse
- type MockRunChannel
- type MockSessionRequestBuilder
- type MockSigner
- type MockSubscription
- type NeverClock
- type NeverSleeper
- type RendererMock
- type SettableClock
- type TestApplication
- func NewApplication(t testing.TB) (*TestApplication, func())
- func NewApplicationWithConfig(t testing.TB, tc *TestConfig) (*TestApplication, func())
- func NewApplicationWithConfigAndKey(t testing.TB, tc *TestConfig) (*TestApplication, func())
- func NewApplicationWithKey(t testing.TB) (*TestApplication, func())
- func (ta *TestApplication) AddUnlockedKey()
- func (ta *TestApplication) ImportKey(content string)
- func (ta *TestApplication) InstantClock() InstantClock
- func (ta *TestApplication) MockEthClient(flags ...string) *EthMock
- func (ta *TestApplication) MockStartAndConnect() (*EthMock, error)
- func (ta *TestApplication) MustSeedUserSession() models.User
- func (ta *TestApplication) NewAuthenticatingClient(prompter cmd.Prompter) *cmd.Client
- func (ta *TestApplication) NewBox() packr.Box
- func (ta *TestApplication) NewClientAndRenderer() (*cmd.Client, *RendererMock)
- func (ta *TestApplication) NewHTTPClient() HTTPClientCleaner
- func (ta *TestApplication) StartAndConnect() error
- func (ta *TestApplication) Stop() error
- func (ta *TestApplication) WaitForConnection() error
- type TestConfig
- type TriggerClock
Constants ¶
const ( // RootDir the root directory for cltest RootDir = "/tmp/chainlink_test" // Username the test username Username = "testusername" // APIEmail of the API user APIEmail = "email@test.net" // Password the password Password = "password" // APISessionID ID for API user APISessionID = "session" // SessionSecret is the hardcoded secret solely used for test SessionSecret = "clsession_test_secret" )
const Strict = "strict"
Strict flag makes the mock eth client panic if an unexpected call is made
Variables ¶
This section is empty.
Functions ¶
func AssertServerResponse ¶
AssertServerResponse is used to match against a client response, will print any errors returned if the request fails.
func AssertSyncEventCountStays ¶
AssertSyncEventCountStays ensures that the event sync count stays consistent for a period of time
func AssertValidHash ¶
AssertValidHash checks that a string matches a specific hash format, includes a leading 0x and has a specific length (in bytes)
func BuildInitiatorRequests ¶
func BuildTaskRequests ¶
func CallbackOrTimeout ¶
func CreateBridgeTypeViaWeb ¶
func CreateBridgeTypeViaWeb( t testing.TB, app *TestApplication, payload string, ) *models.BridgeTypeAuthentication
CreateBridgeTypeViaWeb creates a bridgetype via web using /v2/bridge_types
func CreateHelloWorldJobViaWeb ¶
CreateHelloWorldJobViaWeb creates a HelloWorld JobSpec with the given MockServer Url
func CreateJobRunViaWeb ¶
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 ¶
func CreateJobSpecViaWeb ¶
CreateJobSpecViaWeb creates a jobspec via web using /v2/specs
func CreateSpecViaWeb ¶
CreateJobSpecViaWeb creates a jobspec via web using /v2/specs
func DecodeSessionCookie ¶
func EmptyCLIContext ¶
func ExtractTargetAddressFromERC20EthEthCallMock ¶
ExtractTargetAddressFromERC20EthEthCallMock extracts the contract address and the method data, for checking in a test.
func FindJobRun ¶
FindJobRun returns JobRun for given JobRunID
func FindServiceAgreement ¶
func FixtureCreateJobViaWeb ¶
FixtureCreateJobViaWeb creates a job from a fixture using /v2/specs
func FixtureCreateServiceAgreementViaWeb ¶
func FixtureCreateServiceAgreementViaWeb( t *testing.T, app *TestApplication, path string, ) models.ServiceAgreement
FixtureCreateServiceAgreementViaWeb creates a service agreement from a fixture using /v2/service_agreements
func GetAccountAddress ¶
GetAccountAddress returns Address of the account in the keystore of the passed in store
func GetAccountAddresses ¶
GetAccountAddresses returns the Address of all registered accounts
func JSONFromBytes ¶
JSONFromBytes creates JSON from a given byte array
func JSONFromFixture ¶
JSONFromFixture create models.JSON from file path
func JSONFromString ¶
JSONFromString create JSON from given body and arguments
func JSONResultFromFixture ¶
JSONResultFromFixture create model.JSON with params.result found in the given file path
func JobRunStays ¶
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 JobRunStaysPendingConfirmations ¶
func JobRunStaysPendingConfirmations( t testing.TB, store *strpkg.Store, jr models.JobRun, ) models.JobRun
JobRunStaysPendingConfirmations tests if a JobRun will stay at the PendingConfirmations Status
func LogFromFixture ¶
LogFromFixture create ethtypes.log from file path
func MarkJobRunPendingBridge ¶
MarkJobRunPendingBridge marks the jobrun as Pending Bridge Status
func MustAllJobsWithStatus ¶
func MustJSONDel ¶
MustJSONDel uses sjson.Delete to remove a path from a JSON string and returns the string
func MustJSONSet ¶
MustJSONSet uses sjson.Set to set a path in a JSON string and returns the string See https://github.com/tidwall/sjson
func MustParseURL ¶
func MustReadFile ¶
MustReadFile loads a file but should never fail
func MustSha256 ¶
func NewBigHexInt ¶
NewBigHexInt creates new BigHexInt from value
func NewBlockHeader ¶
func NewBlockHeader(number int) *models.BlockHeader
NewBlockHeader return a new BlockHeader with given number
func NewBridgeType ¶
func NewBridgeType(t testing.TB, info ...string) (*models.BridgeTypeAuthentication, *models.BridgeType)
NewBridgeType create new bridge type given info slice
func NewHTTPMockServer ¶
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 NewJobSubscriber ¶
NewJobSubscriber creates a new JobSubscriber
func NewJobWithLogInitiator ¶
NewJobWithLogInitiator create new Job with ethlog inititaor
func NewJobWithRunAtInitiator ¶
NewJobWithRunAtInitiator create new Job with RunAt inititaor
func NewJobWithRunLogInitiator ¶
NewJobWithRunLogInitiator creates a new JobSpec with the RunLog initiator
func NewJobWithSALogInitiator ¶
NewJobWithSALogInitiator creates new JobSpec with the ServiceAgreement initiator
func NewJobWithSchedule ¶
NewJobWithSchedule create new job with the given schedule
func NewJobWithWebInitiator ¶
NewJobWithWebInitiator create new Job with web inititaor
func NewMockAuthenticatedHTTPClient ¶
func NewMockAuthenticatedHTTPClient(cfg store.Config) cmd.HTTPClient
func NewRunLog ¶
func NewRunLog( t *testing.T, jobID string, emitter common.Address, requester common.Address, blk int, json string, ) models.Log
NewRunLog create models.Log for given jobid, address, block, and json
func NewServiceAgreementExecutionLog ¶
func NewServiceAgreementExecutionLog( t *testing.T, jobID string, logEmitter common.Address, executionRequester common.Address, blockHeight int, serviceAgreementJSON string, ) models.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 ¶
func NewStoreWithConfig ¶
func NewStoreWithConfig(config *TestConfig) (*strpkg.Store, func())
NewStoreWithConfig creates a new store with given config
func NewWSServer ¶
NewWSServer returns a new wsserver
func NullString ¶
NullString creates null.String from given value
func NullableTime ¶
NullableTime will return a valid nullable time given time.Time
func ParseISO8601 ¶
ParseISO8601 given the time string it Must parse the time and return it
func ParseJSONAPIErrors ¶
func ParseJSONAPIResponse ¶
ParseJSONAPIResponse parses the response and returns the JSONAPI resource.
func ParseJSONAPIResponseMeta ¶
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 ¶
ParseJSONAPIResponseMetaCount parses the bytes of the root document and returns the value of the 'count' key from the 'meta' section.
func ParseNullableTime ¶
ParseNullableTime given a time string parse it into a null.Time
func ParseResponseBody ¶
ParseResponseBody will parse the given response into a byte slice
func ReadLogs ¶
func ReadLogs(app *TestApplication) (string, error)
ReadLogs returns the contents of the applications log file as a string
func RunResultWithData ¶
RunResultWithData creates a run result with a given data JSON object
func RunResultWithDataAndLinkPayout ¶
RunResultWithDataAndLinkPayout creates a run result with a given data JSON object and link amount as a payout
func RunResultWithError ¶
RunResultWithError creates a runresult with given error
func RunResultWithResult ¶
RunResultWithResult creates a RunResult with given result
func ServiceAgreementFromString ¶
func ServiceAgreementFromString(str string) (models.ServiceAgreement, error)
func StringToHash ¶
func TxReceiptFromFixture ¶
TxReceiptFromFixture create ethtypes.log from file path
func UnauthenticatedPatch ¶
func UpdateJobRunViaWeb ¶
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 ¶
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 ¶
WaitForJobRunToComplete waits for a JobRun to reach Completed Status
func WaitForJobRunToPendBridge ¶
func WaitForJobRunToPendBridge( t testing.TB, store *strpkg.Store, jr models.JobRun, ) models.JobRun
WaitForJobRunToPendBridge waits for a JobRun to reach PendingBridge Status
func WaitForJobRunToPendConfirmations ¶
func WaitForJobRunToPendConfirmations( t testing.TB, store *strpkg.Store, jr models.JobRun, ) models.JobRun
WaitForJobRunToPendConfirmations waits for a JobRun to reach PendingConfirmations Status
func WaitForJobRunToPendSleep ¶
WaitForJobRunToPendSleep waits for a JobRun to reach PendingBridge Status
func WaitForJobs ¶
WaitForJobs waits for the wanted number of jobs.
func WaitForRuns ¶
WaitForRuns waits for the wanted number of runs then returns a slice of the JobRuns
func WaitForRunsAtLeast ¶
WaitForRunsAtLeast waits for at least the passed number of runs to start.
func WaitForSyncEventCount ¶
WaitForSyncEventCount checks if the sync event count eventually reaches the amound specified in parameter want.
func WaitForTxAttemptCount ¶
Types ¶
type BlockedRunner ¶
type BlockedRunner struct {
Done chan struct{}
}
BlockedRunner is a Runner that blocks until its channel is posted to
func (BlockedRunner) Run ¶
func (r BlockedRunner) Run(app services.Application) error
Run runs the blocked runner, doesn't return until the channel is signalled
type CallbackAuthenticator ¶
CallbackAuthenticator contains a call back authenticator method
func (CallbackAuthenticator) Authenticate ¶
Authenticate authenticates store and pwd with the callback authenticator
type CommonJSON ¶
type CommonJSON struct { ID string `json:"id"` Name string `json:"name"` Digest string `json:"digest"` }
CommonJSON has an ID, and Name
func ParseCommonJSON ¶
func ParseCommonJSON(t testing.TB, body io.Reader) CommonJSON
ParseCommonJSON will unmarshall given body into CommonJSON
type EmptyRunner ¶
type EmptyRunner struct{}
EmptyRunner is an EmptyRunner
func (EmptyRunner) Run ¶
func (r EmptyRunner) Run(app services.Application) error
Run runs the empty runner
type ErrorsJSON ¶
type ErrorsJSON struct {
Errors []string `json:"errors"`
}
ErrorsJSON has an errors attribute
func ParseErrorsJSON ¶
func ParseErrorsJSON(t testing.TB, body io.Reader) ErrorsJSON
ParseErrorsJSON will unmarshall given body into ErrorsJSON
type EthMock ¶
type EthMock struct { Responses []MockResponse Subscriptions []MockSubscription // contains filtered or unexported fields }
EthMock is a mock ethereum client
func MockEthOnStore ¶
MockEthOnStore given store return new EthMock Client
func (*EthMock) AssertAllCalled ¶
func (mock *EthMock) AssertAllCalled()
AssertAllCalled immediately checks that all calls have been made
func (*EthMock) Context ¶
Context adds helpful context to EthMock values set in the callback function.
func (*EthMock) Dial ¶
func (mock *EthMock) Dial(url string) (store.CallerSubscriber, error)
Dial mock dial
func (*EthMock) EthSubscribe ¶
func (mock *EthMock) EthSubscribe( ctx context.Context, channel interface{}, args ...interface{}, ) (models.EthSubscription, error)
EthSubscribe registers a subscription to the channel
func (*EthMock) EventuallyAllCalled ¶
EventuallyAllCalled eventually will return after all the mock subscriptions and responses are called
func (*EthMock) Register ¶
func (mock *EthMock) Register( method string, response interface{}, callback ...func(interface{}, ...interface{}) error, )
Register register mock responses and append to Ethmock
func (*EthMock) RegisterError ¶
RegisterError register mock errors to EthMock
func (*EthMock) RegisterNewHead ¶
func (mock *EthMock) RegisterNewHead(blockNumber int64) chan models.BlockHeader
RegisterNewHead register new head at given blocknumber
func (*EthMock) RegisterNewHeads ¶
func (mock *EthMock) RegisterNewHeads() chan models.BlockHeader
RegisterNewHeads registers a newheads subscription
func (*EthMock) RegisterSubscription ¶
func (mock *EthMock) RegisterSubscription(name string, channels ...interface{}) MockSubscription
RegisterSubscription register a mock subscription to the given name and channels
func (*EthMock) ShouldCall ¶
type EventWebSocketServer ¶
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 ¶
func NewEventWebSocketServer(t *testing.T) (*EventWebSocketServer, func())
NewEventWebSocketServer returns a new EventWebSocketServer
func (*EventWebSocketServer) Broadcast ¶
func (wss *EventWebSocketServer) Broadcast(message string) error
Broadcast sends a message to every web socket client connected to the EventWebSocketServer
func (*EventWebSocketServer) WriteCloseMessage ¶
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 ¶
type HTTPClientCleaner struct { HTTPClient cmd.HTTPClient // contains filtered or unexported fields }
func (*HTTPClientCleaner) Delete ¶
func (r *HTTPClientCleaner) Delete(path string) (*http.Response, func())
type InstanceAppFactory ¶
type InstanceAppFactory struct {
App services.Application
}
InstanceAppFactory is an InstanceAppFactory
func (InstanceAppFactory) NewApplication ¶
func (f InstanceAppFactory) NewApplication(config store.Config, onConnectCallbacks ...func(services.Application)) services.Application
NewApplication creates a new application with specified config
type InstantClock ¶
type InstantClock struct{}
InstantClock an InstantClock
type MockAPIInitializer ¶
type MockAPIInitializer struct {
Count int
}
func (*MockAPIInitializer) Initialize ¶
type MockChangePasswordPrompter ¶
type MockChangePasswordPrompter struct { models.ChangePasswordRequest // contains filtered or unexported fields }
func (MockChangePasswordPrompter) Prompt ¶
func (m MockChangePasswordPrompter) Prompt() (models.ChangePasswordRequest, error)
type MockCookieAuthenticator ¶
type MockCookieAuthenticator struct {
Error error
}
func (MockCookieAuthenticator) Authenticate ¶
func (m MockCookieAuthenticator) Authenticate(models.SessionRequest) (*http.Cookie, error)
type MockCountingPrompter ¶
MockCountingPrompter is a mock counting prompt
func (*MockCountingPrompter) IsTerminal ¶
func (p *MockCountingPrompter) IsTerminal() bool
IsTerminal always returns true in tests
func (*MockCountingPrompter) PasswordPrompt ¶
func (p *MockCountingPrompter) PasswordPrompt(string) string
PasswordPrompt returns an entered string
func (*MockCountingPrompter) Prompt ¶
func (p *MockCountingPrompter) Prompt(string) string
Prompt returns an entered string
type MockCron ¶
type MockCron struct {
Entries []MockCronEntry
}
MockCron represents a mock cron
func (*MockCron) RunEntries ¶
func (mc *MockCron) RunEntries()
RunEntries run every function for each mockcron entry
type MockCronEntry ¶
type MockCronEntry struct { Schedule string Function func() }
MockCronEntry a cron schedule and function
type MockHeadTrackable ¶
type MockHeadTrackable struct { ConnectedCallback func(bn *models.Head) // contains filtered or unexported fields }
MockHeadTrackable allows you to mock HeadTrackable
func (*MockHeadTrackable) Connect ¶
func (m *MockHeadTrackable) Connect(bn *models.Head) error
Connect increases the connected count by one
func (*MockHeadTrackable) ConnectedCount ¶
func (m *MockHeadTrackable) ConnectedCount() int32
ConnectedCount returns the count of connections made, safely.
func (*MockHeadTrackable) Disconnect ¶
func (m *MockHeadTrackable) Disconnect()
Disconnect increases the disconnected count by one
func (*MockHeadTrackable) DisconnectedCount ¶
func (m *MockHeadTrackable) DisconnectedCount() int32
DisconnectedCount returns the count of disconnections made, safely.
func (*MockHeadTrackable) OnNewHead ¶
func (m *MockHeadTrackable) OnNewHead(*models.Head)
OnNewHead increases the OnNewHeadCount count by one
func (*MockHeadTrackable) OnNewHeadCount ¶
func (m *MockHeadTrackable) OnNewHeadCount() int32
OnNewHeadCount returns the count of new heads, safely.
type MockPasswordPrompter ¶
type MockPasswordPrompter struct {
Password string
}
func (MockPasswordPrompter) Prompt ¶
func (m MockPasswordPrompter) Prompt() string
type MockResponse ¶
type MockResponse struct {
// contains filtered or unexported fields
}
MockResponse a mock response
type MockRunChannel ¶
func NewMockRunChannel ¶
func NewMockRunChannel() *MockRunChannel
func (*MockRunChannel) Close ¶
func (m *MockRunChannel) Close()
func (*MockRunChannel) Receive ¶
func (m *MockRunChannel) Receive() <-chan store.RunRequest
func (*MockRunChannel) Send ¶
func (m *MockRunChannel) Send(jobRunID string) error
type MockSessionRequestBuilder ¶
func (*MockSessionRequestBuilder) Build ¶
func (m *MockSessionRequestBuilder) Build(string) (models.SessionRequest, error)
type MockSigner ¶
type MockSigner struct{}
type MockSubscription ¶
type MockSubscription struct { Errors chan error // contains filtered or unexported fields }
MockSubscription a mock subscription
func EmptyMockSubscription ¶
func EmptyMockSubscription() MockSubscription
EmptyMockSubscription return empty MockSubscription
func (MockSubscription) Err ¶
func (mes MockSubscription) Err() <-chan error
Err returns error channel from mes
func (MockSubscription) Unsubscribe ¶
func (mes MockSubscription) Unsubscribe()
Unsubscribe closes the subscription
type NeverClock ¶
type NeverClock struct{}
NeverClock a never clock
type NeverSleeper ¶
type NeverSleeper struct{}
NeverSleeper is a struct that never sleeps
func (NeverSleeper) Duration ¶
func (ns NeverSleeper) Duration() time.Duration
Duration returns a duration
type RendererMock ¶
type RendererMock struct {
Renders []interface{}
}
RendererMock a mock renderer
func (*RendererMock) Render ¶
func (rm *RendererMock) Render(v interface{}) error
Render appends values to renderer mock
type SettableClock ¶
type SettableClock struct {
// contains filtered or unexported fields
}
SettableClock a settable clock
func UseSettableClock ¶
func UseSettableClock(s *store.Store) *SettableClock
UseSettableClock creates a SettableClock on the store
func (*SettableClock) After ¶
func (*SettableClock) After(_ time.Duration) <-chan time.Time
After return channel of time
func (*SettableClock) SetTime ¶
func (clock *SettableClock) SetTime(t time.Time)
SetTime set the current time
type TestApplication ¶
type TestApplication struct { *services.ChainlinkApplication Config strpkg.Config Server *httptest.Server // contains filtered or unexported fields }
TestApplication holds the test application and test servers
func NewApplication ¶
func NewApplication(t testing.TB) (*TestApplication, func())
NewApplication creates a New TestApplication along with a NewConfig
func NewApplicationWithConfig ¶
func NewApplicationWithConfig(t testing.TB, tc *TestConfig) (*TestApplication, func())
NewApplicationWithConfig creates a New TestApplication with specified test config
func NewApplicationWithConfigAndKey ¶
func NewApplicationWithConfigAndKey(t testing.TB, tc *TestConfig) (*TestApplication, func())
NewApplicationWithConfigAndKey creates a new TestApplication with the given testconfig it will also provide an unlocked account on the keystore
func NewApplicationWithKey ¶
func NewApplicationWithKey(t testing.TB) (*TestApplication, func())
NewApplicationWithKey creates a new TestApplication along with a new config
func (*TestApplication) AddUnlockedKey ¶
func (ta *TestApplication) AddUnlockedKey()
func (*TestApplication) ImportKey ¶
func (ta *TestApplication) ImportKey(content string)
ImportKey adds private key to the application disk keystore, not database.
func (*TestApplication) InstantClock ¶
func (ta *TestApplication) InstantClock() InstantClock
InstantClock create InstantClock
func (*TestApplication) MockEthClient ¶
func (ta *TestApplication) MockEthClient(flags ...string) *EthMock
MockEthClient create new EthMock Client
func (*TestApplication) MockStartAndConnect ¶
func (ta *TestApplication) MockStartAndConnect() (*EthMock, error)
func (*TestApplication) MustSeedUserSession ¶
func (ta *TestApplication) MustSeedUserSession() models.User
func (*TestApplication) NewAuthenticatingClient ¶
func (ta *TestApplication) NewAuthenticatingClient(prompter cmd.Prompter) *cmd.Client
func (*TestApplication) NewBox ¶
func (ta *TestApplication) NewBox() packr.Box
func (*TestApplication) NewClientAndRenderer ¶
func (ta *TestApplication) NewClientAndRenderer() (*cmd.Client, *RendererMock)
NewClientAndRenderer creates a new cmd.Client for the test application
func (*TestApplication) NewHTTPClient ¶
func (ta *TestApplication) NewHTTPClient() HTTPClientCleaner
func (*TestApplication) StartAndConnect ¶
func (ta *TestApplication) StartAndConnect() error
func (*TestApplication) Stop ¶
func (ta *TestApplication) Stop() error
Stop will stop the test application and perform cleanup
func (*TestApplication) WaitForConnection ¶
func (ta *TestApplication) WaitForConnection() error
WaitForConnection wait for the StartAndConnect callback to be called
type TestConfig ¶
TestConfig struct with test store and wsServer
func NewConfig ¶
func NewConfig(t testing.TB) (*TestConfig, func())
NewConfig returns a new TestConfig
func NewConfigWithWSServer ¶
func NewConfigWithWSServer(t testing.TB, wsserver *httptest.Server) *TestConfig
NewConfigWithWSServer return new config with specified wsserver
func (*TestConfig) SetEthereumServer ¶
func (tc *TestConfig) SetEthereumServer(wss *httptest.Server)
SetEthereumServer sets the ethereum server for testconfig with given wsserver
type TriggerClock ¶
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 ¶
func NewTriggerClock() *TriggerClock
NewTriggerClock returns a new TriggerClock, that a test can manually fire to continue processing in a Clock dependency.
func (*TriggerClock) After ¶
func (t *TriggerClock) After(_ time.Duration) <-chan time.Time
After waits on a manual trigger.
func (*TriggerClock) Trigger ¶
func (t *TriggerClock) Trigger()
Trigger sends a time to unblock the After call.