Documentation ¶
Overview ¶
Importing cltest should only be for top level black box (X_test package) integration tests, for example testing against the Application object itself. Consider using a smaller scoped package: utils or testutils/* if possible.
Index ¶
- Constants
- Variables
- func AllExternalInitiators(t testing.TB, db *sqlx.DB) []bridges.ExternalInitiator
- func AssertCount(t *testing.T, db *sqlx.DB, tableName string, expected int64)
- func AssertCountStays(t testing.TB, db *sqlx.DB, tableName string, want int64)
- func AssertError(t testing.TB, want bool, err error)
- func AssertEthTxAttemptCountStays(t testing.TB, db *sqlx.DB, want int) []int64
- func AssertPipelineRunsStays(t testing.TB, pipelineSpecID int32, db *sqlx.DB, want int) []pipeline.Run
- func AssertPipelineTaskRunsErrored(t testing.TB, runs []pipeline.TaskRun)
- func AssertPipelineTaskRunsSuccessful(t testing.TB, runs []pipeline.TaskRun)
- func AssertRecordEventually(t *testing.T, db *sqlx.DB, model interface{}, stmt string, check func() bool)
- func AssertServerResponse(t testing.TB, resp *http.Response, expectedStatusCode int)
- func AwaitJobActive(t testing.TB, jobSpawner job.Spawner, jobID int32, waitFor time.Duration)
- func BatchElemMatchesParams(req rpc.BatchElem, arg interface{}, method string) bool
- func BatchElemMustMatchParams(t *testing.T, req rpc.BatchElem, hash common.Hash, method string)
- func CallbackOrTimeout(t testing.TB, msg string, callback func(), durationParams ...time.Duration)
- func ClearDBTables(t *testing.T, db *sqlx.DB, tables ...string)
- func CreateExternalInitiatorViaWeb(t testing.TB, app *TestApplication, payload string) *webpresenters.ExternalInitiatorAuthentication
- func CreateJobRunViaExternalInitiatorV2(t testing.TB, app *TestApplication, jobID uuid.UUID, eia auth.Token, ...) webpresenters.PipelineRunResource
- func CreateJobRunViaUser(t testing.TB, app *TestApplication, jobID uuid.UUID, body string) webpresenters.PipelineRunResource
- func CreateJobViaWeb(t testing.TB, app *TestApplication, request []byte) job.Job
- func CreateJobViaWeb2(t testing.TB, app *TestApplication, spec string) webpresenters.JobResource
- func CreateUserWithRole(t testing.TB, role sessions.UserRole) sessions.User
- func DecodeSessionCookie(value string) (string, error)
- func DeleteJobViaWeb(t testing.TB, app *TestApplication, jobID int32)
- func DynamicFeeTransactionsFromTipCaps(tipCaps ...int64) []evmtypes.Transaction
- func DynamicFeeTransactionsFromTipCapsTxType(code evmtypes.TxType, tipCaps ...int64) []evmtypes.Transaction
- func EmptyCLIContext() *cli.Context
- func EventuallyExpectationsMet(t *testing.T, mock testifyExpectationsAsserter, timeout time.Duration, ...)
- func FlagSetApplyFromAction(action interface{}, flagSet *flag.FlagSet, parentCommand string)
- func GetLogs(t *testing.T, rv interface{}, logs EthereumLogIterator) []interface{}
- func Head(val interface{}) *evmtypes.Head
- 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 LegacyTransactionsFromGasPrices(gasPrices ...int64) []evmtypes.Transaction
- func LegacyTransactionsFromGasPricesTxType(code evmtypes.TxType, gasPrices ...int64) []evmtypes.Transaction
- func LogFromFixture(t *testing.T, path string) types.Log
- func MakeConfigDigest(t *testing.T) ocrtypes.ConfigDigest
- func MakeDirectRequestJobSpec(t *testing.T) *job.Job
- func Mine(backend *backends.SimulatedBackend, blockTime time.Duration) (stopMining func())
- func MinimalOCRNonBootstrapSpec(contractAddress, transmitterAddress ethkey.EIP55Address, peerID p2pkey.PeerID, ...) string
- func MockApplicationEthCalls(t *testing.T, app *TestApplication, ethClient *evmclimocks.Client, ...)
- func MustAddKeyToKeystore(t testing.TB, key ethkey.KeyV2, chainID *big.Int, ethKeyStore keystore.Eth)
- func MustAddRandomKeyToKeystore(t testing.TB, ethKeyStore keystore.Eth) (ethkey.KeyV2, common.Address)
- func MustBytesToConfigDigest(t *testing.T, b []byte) ocrtypes.ConfigDigest
- func MustCreateBridge(t testing.TB, db *sqlx.DB, opts BridgeOpts, cfg pg.QConfig) (bta *bridges.BridgeTypeAuthentication, bt *bridges.BridgeType)
- func MustGenerateRandomKey(t testing.TB) ethkey.KeyV2
- func MustGenerateRandomKeyState(t testing.TB) ethkey.State
- func MustGenerateSessionCookie(t testing.TB, value string) *http.Cookie
- func MustGetStateForKey(t testing.TB, kst keystore.Eth, key ethkey.KeyV2) ethkey.State
- func MustInsertConfirmedEthTxBySaveFetchedReceipts(t *testing.T, txStore txmgr.EvmTxStore, fromAddress common.Address, ...) (etx txmgr.EvmTx)
- func MustInsertConfirmedEthTxWithLegacyAttempt(t *testing.T, txStore txmgr.EvmTxStore, nonce int64, ...) txmgr.EvmTx
- func MustInsertConfirmedEthTxWithReceipt(t *testing.T, txStore txmgr.TestEvmTxStore, fromAddress common.Address, ...) (etx txmgr.EvmTx)
- func MustInsertConfirmedMissingReceiptEthTxWithLegacyAttempt(t *testing.T, txStore txmgr.EvmTxStore, nonce int64, ...) txmgr.EvmTx
- func MustInsertEthReceipt(t *testing.T, txStore txmgr.TestEvmTxStore, blockNumber int64, ...) txmgr.EvmReceipt
- func MustInsertExternalInitiator(t *testing.T, orm bridges.ORM) (ei bridges.ExternalInitiator)
- func MustInsertExternalInitiatorWithOpts(t *testing.T, orm bridges.ORM, opts ExternalInitiatorOpts) (ei bridges.ExternalInitiator)
- func MustInsertFatalErrorEthTx(t *testing.T, txStore txmgr.EvmTxStore, fromAddress common.Address) txmgr.EvmTx
- func MustInsertHead(t *testing.T, db *sqlx.DB, cfg pg.QConfig, number int64) evmtypes.Head
- func MustInsertInProgressEthTxWithAttempt(t *testing.T, txStore txmgr.EvmTxStore, nonce evmtypes.Nonce, ...) txmgr.EvmTx
- func MustInsertKeeperJob(t *testing.T, db *sqlx.DB, korm keeper.ORM, from ethkey.EIP55Address, ...) job.Job
- func MustInsertKeeperRegistry(t *testing.T, db *sqlx.DB, korm keeper.ORM, ethKeyStore keystore.Eth, ...) (keeper.Registry, job.Job)
- func MustInsertOffchainreportingOracleSpec(t *testing.T, db *sqlx.DB, transmitterAddress ethkey.EIP55Address) job.OCROracleSpec
- func MustInsertPipelineRun(t *testing.T, db *sqlx.DB) (run pipeline.Run)
- func MustInsertPipelineRunWithStatus(t *testing.T, db *sqlx.DB, pipelineSpecID int32, status pipeline.RunStatus) (run pipeline.Run)
- func MustInsertPipelineSpec(t *testing.T, db *sqlx.DB) (spec pipeline.Spec)
- func MustInsertRandomKey(t testing.TB, keystore keystore.Eth, opts ...interface{}) (ethkey.KeyV2, common.Address)
- func MustInsertRandomKeyReturningState(t testing.TB, keystore keystore.Eth, opts ...interface{}) (ethkey.State, common.Address)
- func MustInsertRevertedEthReceipt(t *testing.T, txStore txmgr.TestEvmTxStore, blockNumber int64, ...) txmgr.EvmReceipt
- func MustInsertUnconfirmedEthTx(t *testing.T, txStore txmgr.EvmTxStore, nonce int64, ...) txmgr.EvmTx
- func MustInsertUnconfirmedEthTxWithAttemptState(t *testing.T, txStore txmgr.EvmTxStore, nonce int64, ...) txmgr.EvmTx
- func MustInsertUnconfirmedEthTxWithBroadcastDynamicFeeAttempt(t *testing.T, txStore txmgr.EvmTxStore, nonce int64, ...) txmgr.EvmTx
- func MustInsertUnconfirmedEthTxWithBroadcastLegacyAttempt(t *testing.T, txStore txmgr.EvmTxStore, nonce int64, ...) txmgr.EvmTx
- func MustInsertUnconfirmedEthTxWithInsufficientEthAttempt(t *testing.T, txStore txmgr.EvmTxStore, nonce int64, ...) txmgr.EvmTx
- func MustInsertUnfinishedPipelineTaskRun(t *testing.T, db *sqlx.DB, pipelineRunID int64) (tr pipeline.TaskRun)
- func MustInsertUnstartedEthTx(t *testing.T, txStore txmgr.EvmTxStore, fromAddress common.Address, ...) txmgr.EvmTx
- func MustInsertUpkeepForRegistry(t *testing.T, db *sqlx.DB, cfg pg.QConfig, registry keeper.Registry) keeper.UpkeepRegistration
- func MustInsertV2JobSpec(t *testing.T, db *sqlx.DB, transmitterAddress common.Address) job.Job
- func MustInsertWebhookSpec(t *testing.T, db *sqlx.DB) (job.Job, job.WebhookSpec)
- func MustJSONMarshal(t *testing.T, val interface{}) string
- func MustNewUser(t *testing.T, email, password string) sessions.User
- func MustParseDuration(t testing.TB, durationStr string) time.Duration
- func MustParseURL(t testing.TB, input string) *url.URL
- func MustRandomBytes(t *testing.T, l int) (b []byte)
- func MustRandomP2PPeerID(t *testing.T) p2ppeer.ID
- func MustRandomUser(t testing.TB) sessions.User
- func MustReadFile(t testing.TB, file string) []byte
- func MustSendingKeyStates(t *testing.T, ethKeyStore keystore.Eth, chainID *big.Int) []ethkey.State
- func MustWebURL(t *testing.T, s string) *models.WebURL
- func NewBridgeType(t testing.TB, opts BridgeOpts) (*bridges.BridgeTypeAuthentication, *bridges.BridgeType)
- func NewChainSetMockWithOneChain(t testing.TB, ethClient evmclient.Client, cfg evmconfig.ChainScopedConfig) evm.ChainSet
- func NewContractMockReceiver(t *testing.T, ethMock *evmclimocks.Client, abi abi.ABI, address common.Address) contractMockReceiver
- func NewDynamicFeeEthTxAttempt(t *testing.T, etxID int64) txmgr.EvmTxAttempt
- func NewEIP55Address() ethkey.EIP55Address
- func NewEthConfirmer(t testing.TB, txStore txmgr.EvmTxStore, ethClient evmclient.Client, ...) (*txmgr.EvmConfirmer, error)
- func NewEthMocks(t testing.TB) *evmclimocks.Client
- func NewEthMocksWithDefaultChain(t testing.TB) (c *evmclimocks.Client)
- func NewEthMocksWithStartupAssertions(t testing.TB) *evmclimocks.Client
- func NewEthMocksWithTransactionsOnBlocksAssertions(t testing.TB) *evmclimocks.Client
- func NewEthReceipt(t *testing.T, blockNumber int64, blockHash common.Hash, txHash common.Hash, ...) txmgr.EvmReceipt
- func NewEthTx(t *testing.T, fromAddress common.Address) txmgr.EvmTx
- func NewEventBroadcaster(t testing.TB, dbURL url.URL) pg.EventBroadcaster
- func NewHTTPMockServer(t *testing.T, status int, wantMethod string, response string, ...) *httptest.Server
- func NewHTTPMockServerWithAlterableResponse(t *testing.T, response func() string) (server *httptest.Server)
- func NewHTTPMockServerWithAlterableResponseAndRequest(t *testing.T, response func() string, callback func(r *http.Request)) (server *httptest.Server)
- func NewHTTPMockServerWithRequest(t *testing.T, status int, response string, callback func(r *http.Request)) *httptest.Server
- func NewKeyStore(t testing.TB, db *sqlx.DB, cfg pg.QConfig) keystore.Master
- func NewLegacyEthTxAttempt(t *testing.T, etxID int64) txmgr.EvmTxAttempt
- func NewMockAuthenticatedHTTPClient(lggr logger.Logger, cfg cmd.ClientOpts, sessionID string) cmd.HTTPClient
- func NewPeerID() p2ppeer.ID
- func NewRandomPositiveInt64() int64
- func NewSession(optionalSessionID ...string) clsessions.Session
- func NewSimulatedBackend(t *testing.T, alloc core.GenesisAlloc, gasLimit uint32) *backends.SimulatedBackend
- func NewTestChainScopedConfig(t testing.TB) evmconfig.ChainScopedConfig
- func NewTxStore(t *testing.T, db *sqlx.DB, cfg pg.QConfig) txmgr.TestEvmTxStore
- func NewWSServer(t *testing.T, chainID *big.Int, callback testutils.JSONRPCHandler) string
- 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 ParseResponseBody(t testing.TB, resp *http.Response) []byte
- func RandomLog(t *testing.T) types.Log
- func RawNewRoundLog(t *testing.T, contractAddr common.Address, blockHash common.Hash, ...) types.Log
- func RawNewRoundLogWithTopics(t *testing.T, contractAddr common.Address, blockHash common.Hash, ...) types.Log
- func RequireTxSuccessful(t testing.TB, client TransactionReceipter, txHash common.Hash) *types.Receipt
- func SimulateIncomingHeads(t *testing.T, args SimulateIncomingHeadsArgs) (done chan struct{})
- func TxReceiptFromFixture(t *testing.T, path string) *types.Receipt
- func UnauthenticatedGet(t testing.TB, url string, headers map[string]string) (*http.Response, func())
- func UnauthenticatedPost(t testing.TB, url string, body io.Reader, headers map[string]string) (*http.Response, func())
- func WaitForCount(t *testing.T, db *sqlx.DB, tableName string, want int64)
- func WaitForPipeline(t testing.TB, nodeID int, jobID int32, expectedPipelineRuns int, ...) []pipeline.Run
- func WaitForPipelineComplete(t testing.TB, nodeID int, jobID int32, expectedPipelineRuns int, ...) []pipeline.Run
- func WaitForPipelineError(t testing.TB, nodeID int, jobID int32, expectedPipelineRuns int, ...) []pipeline.Run
- func WaitForSpecErrorV2(t *testing.T, db *sqlx.DB, jobID int32, count int) []job.SpecError
- func WebURL(t testing.TB, unparsed string) models.WebURL
- type Awaiter
- type BlockedRunner
- type Blocks
- func (b *Blocks) ForkAt(t *testing.T, blockNum int64, numHashes int) *Blocks
- func (b *Blocks) HashesMap() map[int64]common.Hash
- func (b *Blocks) Head(number uint64) *evmtypes.Head
- func (b *Blocks) LogOnBlockNum(i uint64, addr common.Address) types.Log
- func (b *Blocks) LogOnBlockNumRemoved(i uint64, addr common.Address) types.Log
- func (b *Blocks) LogOnBlockNumWithIndex(i uint64, logIndex uint, addr common.Address) types.Log
- func (b *Blocks) LogOnBlockNumWithIndexRemoved(i uint64, logIndex uint, addr common.Address) types.Log
- func (b *Blocks) LogOnBlockNumWithTopics(i uint64, logIndex uint, addr common.Address, topics []common.Hash) types.Log
- func (b *Blocks) NewHead(number uint64) *evmtypes.Head
- type BridgeOpts
- type EmptyRunner
- type EthereumLogIterator
- type EventWebSocketServer
- type ExternalInitiatorOpts
- 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())
- func (r *HTTPClientCleaner) Put(path string, body io.Reader) (*http.Response, func())
- type HeadBuffer
- type HeadTrackableFunc
- type InstanceAppFactory
- type InstantClock
- type JobPipelineConfig
- type JobPipelineV2TestHelper
- type MockAPIInitializer
- type MockChangePasswordPrompter
- type MockCookieAuthenticator
- type MockCountingPrompter
- type MockCron
- type MockCronEntry
- type MockHeadTrackable
- type MockPasswordPrompter
- type MockSecretGenerator
- type MockSessionRequestBuilder
- type MockSubscription
- type NeverSleeper
- type RendererMock
- type SimulateIncomingHeadsArgs
- type TestApplication
- func NewApplication(t testing.TB, flagsAndDeps ...interface{}) *TestApplication
- func NewApplicationEVMDisabled(t *testing.T) *TestApplication
- func NewApplicationWithConfig(t testing.TB, cfg chainlink.GeneralConfig, flagsAndDeps ...interface{}) *TestApplication
- func NewApplicationWithConfigAndKey(t testing.TB, c chainlink.GeneralConfig, flagsAndDeps ...interface{}) *TestApplication
- func NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain(t testing.TB, cfg chainlink.GeneralConfig, backend *backends.SimulatedBackend, ...) *TestApplication
- func NewApplicationWithConfigV2OnSimulatedBlockchain(t testing.TB, cfg chainlink.GeneralConfig, backend *backends.SimulatedBackend, ...) *TestApplication
- func NewApplicationWithKey(t *testing.T, flagsAndDeps ...interface{}) *TestApplication
- func (ta *TestApplication) Import(content string)
- func (ta *TestApplication) MustSeedNewSession(roleFixtureUserAPIEmail string) (id string)
- func (ta *TestApplication) NewAuthenticatingShell(prompter cmd.Prompter) *cmd.Shell
- func (ta *TestApplication) NewClientOpts() cmd.ClientOpts
- func (ta *TestApplication) NewHTTPClient(roleFixtureUserAPIEmail string) HTTPClientCleaner
- func (ta *TestApplication) NewShellAndRenderer() (*cmd.Shell, *RendererMock)
- func (ta *TestApplication) Start(ctx context.Context) error
- func (ta *TestApplication) Stop() error
- type TransactionReceipter
Constants ¶
const ( // APIKey of the fixture API user APIKey = "2d25e62eaf9143e993acaf48691564b2" // APISecret of the fixture API user. APISecret = "1eCP/w0llVkchejFaoBpfIGaLRxZK54lTXBCT22YLW+pdzE4Fafy/XO5LoJ2uwHi" // Collection of test fixture DB user emails per role APIEmailAdmin = "apiuser@chainlink.test" APIEmailEdit = "apiuser-edit@chainlink.test" APIEmailRun = "apiuser-run@chainlink.test" APIEmailViewOnly = "apiuser-view-only@chainlink.test" // Password just a password we use everywhere for testing Password = testutils.Password // SessionSecret is the hardcoded secret solely used for test SessionSecret = "clsession_test_secret" // DefaultPeerID is the peer ID of the default p2p key DefaultPeerID = "12D3KooWPjceQrSwdWXPyLLeABRXmuqt69Rg3sBYbU1Nft9HyQ6X" // DefaultOCRKeyBundleID is the ID of the default ocr key bundle DefaultOCRKeyBundleID = "f5bf259689b26f1374efb3c9a9868796953a0f814bb2d39b968d0e61b58620a5" // DefaultOCR2KeyBundleID is the ID of the fixture ocr2 key bundle DefaultOCR2KeyBundleID = "92be59c45d0d7b192ef88d391f444ea7c78644f8607f567aab11d53668c27a4d" // Private key seed of test keys created with `big.NewInt(1)`, representations of value present in `scrub_logs` script KeyBigIntSeed = 1 )
const ( // DBPollingInterval can't be too short to avoid DOSing the test database DBPollingInterval = 100 * time.Millisecond // AssertNoActionTimeout shouldn't be too long, or it will slow down tests AssertNoActionTimeout = 3 * time.Second )
const (
UseRealExternalInitiatorManager = "UseRealExternalInitiatorManager"
)
Variables ¶
var ( DefaultP2PPeerID p2pkey.PeerID FixtureChainID = *testutils.FixtureChainID DefaultCosmosKey = cosmoskey.MustNewInsecure(keystest.NewRandReaderFromSeed(KeyBigIntSeed)) DefaultCSAKey = csakey.MustNewV2XXXTestingOnly(big.NewInt(KeyBigIntSeed)) DefaultOCRKey = ocrkey.MustNewV2XXXTestingOnly(big.NewInt(KeyBigIntSeed)) DefaultOCR2Key = ocr2key.MustNewInsecure(keystest.NewRandReaderFromSeed(KeyBigIntSeed), "evm") DefaultP2PKey = p2pkey.MustNewV2XXXTestingOnly(big.NewInt(KeyBigIntSeed)) DefaultSolanaKey = solkey.MustNewInsecure(keystest.NewRandReaderFromSeed(KeyBigIntSeed)) DefaultStarkNetKey = starkkey.MustNewInsecure(keystest.NewRandReaderFromSeed(KeyBigIntSeed)) DefaultVRFKey = vrfkey.MustNewV2XXXTestingOnly(big.NewInt(KeyBigIntSeed)) DefaultDKGSignKey = dkgsignkey.MustNewXXXTestingOnly(big.NewInt(KeyBigIntSeed)) DefaultDKGEncryptKey = dkgencryptkey.MustNewXXXTestingOnly(big.NewInt(KeyBigIntSeed)) )
Functions ¶
func AllExternalInitiators ¶
func AssertCountStays ¶
func AssertEthTxAttemptCountStays ¶
AssertEthTxAttemptCountStays asserts that the number of tx attempts remains at the provided value
func AssertPipelineRunsStays ¶
func AssertPipelineRunsStays(t testing.TB, pipelineSpecID int32, db *sqlx.DB, want int) []pipeline.Run
AssertPipelineRunsStays asserts that the number of pipeline runs for a particular job remains at the provided values
func AssertRecordEventually ¶
func AssertServerResponse ¶
AssertServerResponse is used to match against a client response, will print any errors returned if the request fails.
func AwaitJobActive ¶
func BatchElemMatchesParams ¶
func CallbackOrTimeout ¶
func ClearDBTables ¶
ClearDBTables deletes all rows from the given tables
func CreateExternalInitiatorViaWeb ¶
func CreateExternalInitiatorViaWeb( t testing.TB, app *TestApplication, payload string, ) *webpresenters.ExternalInitiatorAuthentication
CreateExternalInitiatorViaWeb creates a bridgetype via web using /v2/bridge_types
func CreateJobRunViaExternalInitiatorV2 ¶
func CreateJobRunViaExternalInitiatorV2( t testing.TB, app *TestApplication, jobID uuid.UUID, eia auth.Token, body string, ) webpresenters.PipelineRunResource
func CreateJobRunViaUser ¶
func CreateJobRunViaUser( t testing.TB, app *TestApplication, jobID uuid.UUID, body string, ) webpresenters.PipelineRunResource
func CreateJobViaWeb ¶
func CreateJobViaWeb2 ¶
func CreateJobViaWeb2(t testing.TB, app *TestApplication, spec string) webpresenters.JobResource
func CreateUserWithRole ¶
CreateUserWithRole inserts a new user with specified role and associated test DB email into the test DB
func DecodeSessionCookie ¶
func DeleteJobViaWeb ¶
func DeleteJobViaWeb(t testing.TB, app *TestApplication, jobID int32)
func DynamicFeeTransactionsFromTipCaps ¶
func DynamicFeeTransactionsFromTipCaps(tipCaps ...int64) []evmtypes.Transaction
DynamicFeeTransactionsFromTipCaps returns EIP-1559 transactions with the given TipCaps (FeeCap is arbitrary)
func DynamicFeeTransactionsFromTipCapsTxType ¶
func DynamicFeeTransactionsFromTipCapsTxType(code evmtypes.TxType, tipCaps ...int64) []evmtypes.Transaction
func EmptyCLIContext ¶
func FlagSetApplyFromAction ¶
FlagSetApplyFromAction applies the flags from action to the flagSet. `parentCommand` will filter the app commands and only applies the flags if the command/subcommand has a parent with that name, if left empty no filtering is done
func GetLogs ¶
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 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 LegacyTransactionsFromGasPrices ¶
func LegacyTransactionsFromGasPrices(gasPrices ...int64) []evmtypes.Transaction
LegacyTransactionsFromGasPrices returns transactions matching the given gas prices
func LegacyTransactionsFromGasPricesTxType ¶
func LegacyTransactionsFromGasPricesTxType(code evmtypes.TxType, gasPrices ...int64) []evmtypes.Transaction
func LogFromFixture ¶
LogFromFixture create ethtypes.log from file path
func MakeConfigDigest ¶
func MakeConfigDigest(t *testing.T) ocrtypes.ConfigDigest
func Mine ¶
func Mine(backend *backends.SimulatedBackend, blockTime time.Duration) (stopMining func())
Mine forces the simulated backend to produce a new block every 2 seconds
func MockApplicationEthCalls ¶
func MockApplicationEthCalls(t *testing.T, app *TestApplication, ethClient *evmclimocks.Client, sub *commonmocks.Subscription)
MockApplicationEthCalls mocks all calls made by the chainlink application as standard when starting and stopping
func MustAddKeyToKeystore ¶
func MustBytesToConfigDigest ¶
func MustBytesToConfigDigest(t *testing.T, b []byte) ocrtypes.ConfigDigest
func MustCreateBridge ¶
func MustCreateBridge(t testing.TB, db *sqlx.DB, opts BridgeOpts, cfg pg.QConfig) (bta *bridges.BridgeTypeAuthentication, bt *bridges.BridgeType)
MustCreateBridge creates a bridge Be careful not to specify a name here unless you ABSOLUTELY need to This is because name is a unique index and identical names used across transactional tests will lock/deadlock
func MustGetStateForKey ¶
func MustInsertConfirmedEthTxWithReceipt ¶
func MustInsertConfirmedEthTxWithReceipt(t *testing.T, txStore txmgr.TestEvmTxStore, fromAddress common.Address, nonce, blockNum int64) (etx txmgr.EvmTx)
Inserts into eth_receipts but does not update eth_txes or eth_tx_attempts
func MustInsertEthReceipt ¶
func MustInsertExternalInitiatorWithOpts ¶
func MustInsertExternalInitiatorWithOpts(t *testing.T, orm bridges.ORM, opts ExternalInitiatorOpts) (ei bridges.ExternalInitiator)
func MustInsertHead ¶
func MustInsertKeeperJob ¶
func MustInsertOffchainreportingOracleSpec ¶
func MustInsertOffchainreportingOracleSpec(t *testing.T, db *sqlx.DB, transmitterAddress ethkey.EIP55Address) job.OCROracleSpec
func MustInsertPipelineRun ¶
func MustInsertPipelineSpec ¶
func MustInsertRandomKey ¶
func MustInsertRandomKey( t testing.TB, keystore keystore.Eth, opts ...interface{}, ) (ethkey.KeyV2, common.Address)
MustInsertRandomKey inserts a randomly generated (not cryptographically secure) key for testing By default it is enabled for the fixture chain
func MustInsertUnconfirmedEthTxWithAttemptState ¶
func MustInsertUnconfirmedEthTxWithAttemptState(t *testing.T, txStore txmgr.EvmTxStore, nonce int64, fromAddress common.Address, txAttemptState txmgrtypes.TxAttemptState, opts ...interface{}) txmgr.EvmTx
func MustInsertV2JobSpec ¶
func MustInsertWebhookSpec ¶
func MustJSONMarshal ¶
func MustRandomUser ¶
MustRandomUser inserts a new admin user with a random email into the test DB
func MustReadFile ¶
MustReadFile loads a file but should never fail
func MustSendingKeyStates ¶
func NewBridgeType ¶
func NewBridgeType(t testing.TB, opts BridgeOpts) (*bridges.BridgeTypeAuthentication, *bridges.BridgeType)
NewBridgeType create new bridge type given info slice
func NewContractMockReceiver ¶
func NewDynamicFeeEthTxAttempt ¶
func NewDynamicFeeEthTxAttempt(t *testing.T, etxID int64) txmgr.EvmTxAttempt
func NewEIP55Address ¶
func NewEIP55Address() ethkey.EIP55Address
func NewEthConfirmer ¶
func NewEthConfirmer(t testing.TB, txStore txmgr.EvmTxStore, ethClient evmclient.Client, config evmconfig.ChainScopedConfig, ks keystore.Eth, fn txmgrcommon.ResumeCallback) (*txmgr.EvmConfirmer, error)
func NewEthMocks ¶
func NewEthMocks(t testing.TB) *evmclimocks.Client
func NewEthMocksWithDefaultChain ¶
func NewEthMocksWithDefaultChain(t testing.TB) (c *evmclimocks.Client)
func NewEthMocksWithStartupAssertions ¶
func NewEthMocksWithStartupAssertions(t testing.TB) *evmclimocks.Client
func NewEthMocksWithTransactionsOnBlocksAssertions ¶
func NewEthMocksWithTransactionsOnBlocksAssertions(t testing.TB) *evmclimocks.Client
NewEthMocksWithTransactionsOnBlocksAssertions sets an Eth mock with transactions on blocks
func NewEthReceipt ¶
func NewEventBroadcaster ¶
func NewHTTPMockServer ¶
func NewHTTPMockServer( t *testing.T, status int, wantMethod string, response string, callback ...func(http.Header, string), ) *httptest.Server
NewHTTPMockServer create http test server with passed in parameters
func NewHTTPMockServerWithRequest ¶
func NewHTTPMockServerWithRequest( t *testing.T, status int, response string, callback func(r *http.Request), ) *httptest.Server
NewHTTPMockServerWithRequest creates http test server that makes the request available in the callback
func NewKeyStore ¶
NewKeyStore returns a new, unlocked keystore
func NewLegacyEthTxAttempt ¶
func NewLegacyEthTxAttempt(t *testing.T, etxID int64) txmgr.EvmTxAttempt
func NewMockAuthenticatedHTTPClient ¶
func NewMockAuthenticatedHTTPClient(lggr logger.Logger, cfg cmd.ClientOpts, sessionID string) cmd.HTTPClient
func NewRandomPositiveInt64 ¶
func NewRandomPositiveInt64() int64
func NewSession ¶
func NewSession(optionalSessionID ...string) clsessions.Session
func NewSimulatedBackend ¶
func NewSimulatedBackend(t *testing.T, alloc core.GenesisAlloc, gasLimit uint32) *backends.SimulatedBackend
func NewTestChainScopedConfig ¶
func NewTestChainScopedConfig(t testing.TB) evmconfig.ChainScopedConfig
func NewTxStore ¶ added in v2.1.0
func NewWSServer ¶
NewWSServer starts a websocket server which invokes callback for each message received. If chainID is set, then eth_chainId calls will be automatically handled.
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 ParseResponseBody ¶
ParseResponseBody will parse the given response into a byte slice
func RawNewRoundLog ¶
func RequireTxSuccessful ¶
func SimulateIncomingHeads ¶
func SimulateIncomingHeads(t *testing.T, args SimulateIncomingHeadsArgs) (done chan struct{})
SimulateIncomingHeads spawns a goroutine which sends a stream of heads and closes the returned channel when finished.
func TxReceiptFromFixture ¶
TxReceiptFromFixture create ethtypes.log from file path
func UnauthenticatedGet ¶
func UnauthenticatedPost ¶
func WaitForPipeline ¶
func WaitForPipelineComplete ¶
func WaitForPipelineError ¶
func WaitForSpecErrorV2 ¶
WaitForSpecErrorV2 polls until the passed in jobID has count number of job spec errors.
Types ¶
type Awaiter ¶
type Awaiter chan struct{}
func NewAwaiter ¶
func NewAwaiter() Awaiter
func (Awaiter) AwaitOrFail ¶
func (Awaiter) ItHappened ¶
func (a Awaiter) ItHappened()
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(context.Context, chainlink.Application) error
Run runs the blocked runner, doesn't return until the channel is signalled
type Blocks ¶
type Blocks struct { Hashes []common.Hash Heads map[int64]*evmtypes.Head // contains filtered or unexported fields }
Blocks - a helper logic to construct a range of linked heads and an ability to fork and create logs from them
func (*Blocks) LogOnBlockNum ¶
func (*Blocks) LogOnBlockNumRemoved ¶
func (*Blocks) LogOnBlockNumWithIndex ¶
func (*Blocks) LogOnBlockNumWithIndexRemoved ¶
func (*Blocks) LogOnBlockNumWithTopics ¶
type BridgeOpts ¶
type EmptyRunner ¶
type EmptyRunner struct{}
EmptyRunner is an EmptyRunner
func (EmptyRunner) Run ¶
func (r EmptyRunner) Run(context.Context, chainlink.Application) error
Run runs the empty runner
type EthereumLogIterator ¶
type EthereumLogIterator interface{ Next() bool }
EthereumLogIterator is the interface provided by gethwrapper representations of EVM logs.
type EventWebSocketServer ¶
type EventWebSocketServer struct { *httptest.Server Connected chan struct{} Disconnected chan struct{} ReceivedText chan string ReceivedBinary chan []byte 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) ConnectionsCount ¶
func (wss EventWebSocketServer) ConnectionsCount() int
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 ExternalInitiatorOpts ¶
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 HeadBuffer ¶
HeadBuffer - stores heads in sequence, with increasing timestamps
func NewHeadBuffer ¶
func NewHeadBuffer(t *testing.T) *HeadBuffer
func (*HeadBuffer) Append ¶
func (hb *HeadBuffer) Append(head *evmtypes.Head)
type HeadTrackableFunc ¶
func (HeadTrackableFunc) OnNewLongestChain ¶
func (fn HeadTrackableFunc) OnNewLongestChain(ctx context.Context, head *evmtypes.Head)
type InstanceAppFactory ¶
type InstanceAppFactory struct {
App chainlink.Application
}
InstanceAppFactory is an InstanceAppFactory
func (InstanceAppFactory) NewApplication ¶
func (f InstanceAppFactory) NewApplication(context.Context, chainlink.GeneralConfig, logger.Logger, *sqlx.DB) (chainlink.Application, error)
NewApplication creates a new application with specified config
type InstantClock ¶
type InstantClock struct{}
InstantClock an InstantClock
type JobPipelineConfig ¶ added in v2.2.0
type JobPipelineV2TestHelper ¶
func NewJobPipelineV2 ¶
type MockAPIInitializer ¶
type MockAPIInitializer struct { Count int // contains filtered or unexported fields }
func NewMockAPIInitializer ¶
func NewMockAPIInitializer(t testing.TB) *MockAPIInitializer
func (*MockAPIInitializer) Initialize ¶
type MockChangePasswordPrompter ¶
type MockChangePasswordPrompter struct { web.UpdatePasswordRequest // contains filtered or unexported fields }
func (MockChangePasswordPrompter) Prompt ¶
func (m MockChangePasswordPrompter) Prompt() (web.UpdatePasswordRequest, error)
type MockCookieAuthenticator ¶
type MockCookieAuthenticator struct { SessionID string Error error // contains filtered or unexported fields }
func (MockCookieAuthenticator) Authenticate ¶
func (m MockCookieAuthenticator) Authenticate(sessions.SessionRequest) (*http.Cookie, error)
func (MockCookieAuthenticator) Cookie ¶
func (m MockCookieAuthenticator) Cookie() (*http.Cookie, error)
func (MockCookieAuthenticator) Logout ¶
func (m MockCookieAuthenticator) Logout() error
type MockCountingPrompter ¶
type MockCountingPrompter struct { T *testing.T EnteredStrings []string Count int NotTerminal bool }
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 // contains filtered or unexported fields }
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 {
// contains filtered or unexported fields
}
MockHeadTrackable allows you to mock HeadTrackable
func (*MockHeadTrackable) OnNewLongestChain ¶
func (m *MockHeadTrackable) OnNewLongestChain(context.Context, *evmtypes.Head)
OnNewLongestChain increases the OnNewLongestChainCount count by one
func (*MockHeadTrackable) OnNewLongestChainCount ¶
func (m *MockHeadTrackable) OnNewLongestChainCount() int32
OnNewLongestChainCount returns the count of new heads, safely.
type MockPasswordPrompter ¶
type MockPasswordPrompter struct {
Password string
}
func (MockPasswordPrompter) Prompt ¶
func (m MockPasswordPrompter) Prompt() string
type MockSecretGenerator ¶
type MockSecretGenerator struct{}
type MockSessionRequestBuilder ¶
func (*MockSessionRequestBuilder) Build ¶
func (m *MockSessionRequestBuilder) Build(string) (sessions.SessionRequest, error)
type MockSubscription ¶
type MockSubscription struct { Errors chan error // contains filtered or unexported fields }
MockSubscription a mock subscription
func EmptyMockSubscription ¶
func EmptyMockSubscription(t testing.TB) *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 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{}, headers ...string) error
Render appends values to renderer mock
type SimulateIncomingHeadsArgs ¶
type SimulateIncomingHeadsArgs struct {
StartBlock, EndBlock int64
HeadTrackables []httypes.HeadTrackable
Blocks *Blocks
}
type TestApplication ¶
type TestApplication struct { *chainlink.ChainlinkApplication Logger logger.Logger Server *httptest.Server Started bool Backend *backends.SimulatedBackend Keys []ethkey.KeyV2 // contains filtered or unexported fields }
TestApplication holds the test application and test servers
func NewApplication ¶
func NewApplication(t testing.TB, flagsAndDeps ...interface{}) *TestApplication
NewApplication creates a New TestApplication along with a NewConfig It mocks the keystore with no keys or accounts by default
func NewApplicationEVMDisabled ¶
func NewApplicationEVMDisabled(t *testing.T) *TestApplication
NewApplicationEVMDisabled creates a new application with default config but EVM disabled Useful for testing controllers
func NewApplicationWithConfig ¶
func NewApplicationWithConfig(t testing.TB, cfg chainlink.GeneralConfig, flagsAndDeps ...interface{}) *TestApplication
NewApplicationWithConfig creates a New TestApplication with specified test config. This should only be used in full integration tests. For controller tests, see NewApplicationEVMDisabled.
func NewApplicationWithConfigAndKey ¶
func NewApplicationWithConfigAndKey(t testing.TB, c chainlink.GeneralConfig, flagsAndDeps ...interface{}) *TestApplication
NewApplicationWithConfigAndKey creates a new TestApplication with the given testorm it will also provide an unlocked account on the keystore
func NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain ¶
func NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain( t testing.TB, cfg chainlink.GeneralConfig, backend *backends.SimulatedBackend, flagsAndDeps ...interface{}, ) *TestApplication
NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain is like NewApplicationWithConfigAndKeyOnSimulatedBlockchain but cfg should be v2, and configtest.NewGeneralConfigSimulated used to include the simulated chain (testutils.SimulatedChainID).
func NewApplicationWithConfigV2OnSimulatedBlockchain ¶
func NewApplicationWithConfigV2OnSimulatedBlockchain( t testing.TB, cfg chainlink.GeneralConfig, backend *backends.SimulatedBackend, flagsAndDeps ...interface{}, ) *TestApplication
func NewApplicationWithKey ¶
func NewApplicationWithKey(t *testing.T, flagsAndDeps ...interface{}) *TestApplication
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) Import ¶
func (ta *TestApplication) Import(content string)
ImportKey adds private key to the application keystore and database
func (*TestApplication) MustSeedNewSession ¶
func (ta *TestApplication) MustSeedNewSession(roleFixtureUserAPIEmail string) (id string)
func (*TestApplication) NewAuthenticatingShell ¶ added in v2.3.0
func (ta *TestApplication) NewAuthenticatingShell(prompter cmd.Prompter) *cmd.Shell
func (*TestApplication) NewClientOpts ¶
func (ta *TestApplication) NewClientOpts() cmd.ClientOpts
func (*TestApplication) NewHTTPClient ¶
func (ta *TestApplication) NewHTTPClient(roleFixtureUserAPIEmail string) HTTPClientCleaner
func (*TestApplication) NewShellAndRenderer ¶ added in v2.3.0
func (ta *TestApplication) NewShellAndRenderer() (*cmd.Shell, *RendererMock)
NewShellAndRenderer creates a new cmd.Shell for the test application
func (*TestApplication) Start ¶
func (ta *TestApplication) Start(ctx context.Context) error
Start starts the chainlink app and registers Stop to clean up at end of test.
func (*TestApplication) Stop ¶
func (ta *TestApplication) Stop() error
Stop will stop the test application and perform cleanup