Documentation
¶
Index ¶
- Constants
- Variables
- func AssertEventually(t *testing.T, f func() bool) bool
- func Context(tb testing.TB) context.Context
- func Head(val interface{}) *evmtypes.Head
- func MustExec(t *testing.T, ds sqlutil.DataSource, stmt string, args ...interface{})
- func MustInsertPipelineRun(t *testing.T, db *sqlx.DB) (runID int64)
- func MustInsertUnfinishedPipelineTaskRun(t *testing.T, db *sqlx.DB, pipelineRunID int64) (trID uuid.UUID)
- func MustNewSimTransactor(t testing.TB) *bind.TransactOpts
- func NewAddress() common.Address
- func NewAddressPtr() *common.Address
- func NewHash() common.Hash
- func NewIndependentSqlxDB(t testing.TB) *sqlx.DB
- func NewLegacyTransaction(nonce uint64, to common.Address, value *big.Int, gasLimit uint32, ...) *types.Transaction
- func NewRandomEVMChainID() *big.Int
- func NewSqlxDB(t testing.TB) *sqlx.DB
- func NewTestChainScopedConfig(t testing.TB, overrideFn func(c *toml.EVMConfig)) config.ChainScopedConfigdeprecated
- func NewWSServer(t *testing.T, chainID *big.Int, callback JSONRPCHandler) (ts *testWSServer)
- func RequireEventually(t *testing.T, f func() bool)
- func SkipShortDB(tb testing.TB)
- func WSServerURL(t *testing.T, s *httptest.Server) *url.URL
- func WaitTimeout(t *testing.T) time.Duration
- type Awaiter
- type HTTPServer
- type JSONRPCHandler
- type JSONRPCResponse
- type RawSub
Constants ¶
const DefaultWaitTimeout = 30 * time.Second
DefaultWaitTimeout is the default wait timeout. If you have a *testing.T, use WaitTimeout instead.
const TestInterval = 100 * time.Millisecond
TestInterval is just a sensible poll interval that gives fast tests without risk of spamming
Variables ¶
var FixtureChainID = big.NewInt(evmtypes.NullClientChainID)
FixtureChainID is set to a chainID that is unlikely to be used in production. It can no longer be zero due to a breaking change in go-ethereum: https://github.com/ethereum/go-ethereum/blob/master/core/types/transaction_signing.go#L193
var SimulatedChainID = big.NewInt(1337)
SimulatedChainID is the chain ID for the go-ethereum simulated backend
Functions ¶
func AssertEventually ¶
AssertEventually calls assert.Eventually with default wait and tick durations.
func MustExec ¶
func MustExec(t *testing.T, ds sqlutil.DataSource, stmt string, args ...interface{})
func MustNewSimTransactor ¶
func MustNewSimTransactor(t testing.TB) *bind.TransactOpts
MustNewSimTransactor returns a transactor for interacting with the geth simulated backend.
func NewAddressPtr ¶
func NewIndependentSqlxDB ¶
NewIndependentSqlxDB return a new independent test database, which does not use txdb and therefore supports txs etc. Use this with caution, as it is much more costly than NewSqlxDB.
func NewLegacyTransaction ¶
func NewRandomEVMChainID ¶
NewRandomEVMChainID returns a suitable random chain ID that will not conflict with fixtures
func NewTestChainScopedConfig
deprecated
func NewWSServer ¶
func NewWSServer(t *testing.T, chainID *big.Int, callback JSONRPCHandler) (ts *testWSServer)
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 RequireEventually ¶
RequireEventually calls assert.Eventually with default wait and tick durations.
func SkipShortDB ¶
SkipShortDB skips tb during -short runs, and notes the DB dependency.
func WSServerURL ¶
WSServerURL returns a ws:// url for the server
Types ¶
type Awaiter ¶
type Awaiter chan struct{}
func NewAwaiter ¶
func NewAwaiter() Awaiter
func (Awaiter) AwaitOrFail ¶
func (Awaiter) ItHappened ¶
func (a Awaiter) ItHappened()
type HTTPServer ¶ added in v0.2.0
type HTTPServer struct {
// contains filtered or unexported fields
}
func NewHTTPServer ¶ added in v0.2.0
func NewHTTPServer(t *testing.T, chainID *big.Int, callback JSONRPCHandler) *HTTPServer
NewHTTPServer starts an HTTP server which invokes callback for each message received. If chainID is set, then eth_chainId calls will be automatically handled.
func (*HTTPServer) Close ¶ added in v0.2.0
func (ts *HTTPServer) Close()
func (*HTTPServer) ServeHTTP ¶ added in v0.2.0
func (ts *HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*HTTPServer) URL ¶ added in v0.2.0
func (ts *HTTPServer) URL() *url.URL
type JSONRPCHandler ¶
type JSONRPCHandler func(reqMethod string, reqParams gjson.Result) JSONRPCResponse
JSONRPCHandler is called with the method and request param(s). respResult will be sent immediately. notifyResult is optional, and sent after a short delay.