{"modulePath":"github.com/GoPlugin/pluginV2","version":"v0.5.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package testutils\n\n## Constants\n\n```go\nconst DefaultWaitTimeout = 30 * time.Second\n```\nDefaultWaitTimeout is the default wait timeout. If you have a \\*testing.T, use WaitTimeout instead.\n\n```go\nconst (\n\t// Password just a password we use everywhere for testing\n\tPassword = \"16charlengthp4SsW0rD1!@#_\"\n)\n```\n\n```go\nconst TestInterval = 100 * time.Millisecond\n```\nTestInterval is just a sensible poll interval that gives fast tests without risk of spamming\n\n## Variables\n\n```go\nvar FixtureChainID = big.NewInt(0)\n```\nFixtureChainID matches the chain always added by fixtures.sql It is set to 0 since no real chain ever has this ID and allows a virtual \"test\" chain ID to be used without clashes\n\n```go\nvar SimulatedChainID = big.NewInt(1337)\n```\nSimulatedChainID is the chain ID for the go-ethereum simulated backend\n\n## Functions\n\n```go\nfunc AfterWaitTimeout(t *testing.T) \u003c-chan time.Time\n```\nAfterWaitTimeout returns a channel that will send a time value when the WaitTimeout is reached\n\n```go\nfunc AssertCount(t *testing.T, db *sqlx.DB, tableName string, expected int64)\n```\n\n```go\nfunc AssertEventually(t *testing.T, f func() bool)\n```\nAssertEventually waits for f to return true\n\n```go\nfunc Context(tb testing.TB) context.Context\n```\nContext returns a context with the test's deadline, if available.\n\n```go\nfunc IntToHex(n int) string\n```\nIntToHex converts int to geth-compatible hex\n\n```go\nfunc LoggerAssertMaxLevel(t *testing.T, lvl zapcore.Level) logger.Logger\n```\nLoggerAssertMaxLevel returns a test logger which is observed on cleanup and asserts that no lines were logged at a higher level.\n\n```go\nfunc MustNewSimTransactor(t *testing.T) *bind.TransactOpts\n```\nMustNewSimTransactor returns a transactor for interacting with the geth simulated backend.\n\n```go\nfunc MustParseBigInt(t *testing.T, input string) *big.Int\n```\nMustParseBigInt parses a big int value from string or fails the test\n\n```go\nfunc MustParseURL(t testing.TB, input string) *url.URL\n```\nMustParseURL parses the URL or fails the test\n\n```go\nfunc NewAddress() common.Address\n```\nNewAddress return a random new address\n\n```go\nfunc NewAddressPtr() *common.Address\n```\n\n```go\nfunc NewRandomEVMChainID() *big.Int\n```\nNewRandomEVMChainID returns a suitable random chain ID that will not conflict with fixtures\n\n```go\nfunc NewRandomPositiveInt64() int64\n```\nNewRandomPositiveInt64 returns a (non-cryptographically secure) random positive int64\n\n```go\nfunc NewTestFlagSet() *flag.FlagSet\n```\n\n```go\nfunc NewWSServer(t *testing.T, chainID *big.Int, callback JSONRPCHandler) (ts *testWSServer)\n```\nNewWSServer starts a websocket server which invokes callback for each message received. If chainID is set, then eth\\_chainId calls will be automatically handled.\n\n```go\nfunc Ptr[T any](v T) *T\n```\nPtr takes pointer of anything\n\n```go\nfunc Random32Byte() (b [32]byte)\n```\nRandom32Byte returns a random \\[32]byte\n\n```go\nfunc RandomizeName(n string) string\n```\nRandomizeName appends a random UUID to the provided name\n\n```go\nfunc RequireLogMessage(t *testing.T, observedLogs *observer.ObservedLogs, msg string)\n```\nRequireLogMessage fails the test if emitted logs don't contain the given message\n\n```go\nfunc SkipShort(tb testing.TB, why string)\n```\nSkipShort skips tb during -short runs, and notes why.\n\n```go\nfunc SkipShortDB(tb testing.TB)\n```\nSkipShortDB skips tb during -short runs, and notes the DB dependency.\n\n```go\nfunc WSServerURL(t *testing.T, s *httptest.Server) *url.URL\n```\nWSServerURL returns a ws:// url for the server\n\n```go\nfunc WaitForLogMessage(t *testing.T, observedLogs *observer.ObservedLogs, msg string)\n```\nWaitForLogMessage waits until at least one log message containing the specified msg is emitted. NOTE: This does not \"pop\" messages so it cannot be used multiple times to check for new instances of the same msg. See WaitForLogMessageCount instead.\n\nGet a \\*observer.ObservedLogs like so:\n\n\tobservedZapCore, observedLogs := observer.New(zap.DebugLevel)\n\tlggr := logger.TestLogger(t, observedZapCore)\n\n```go\nfunc WaitForLogMessageCount(t *testing.T, observedLogs *observer.ObservedLogs, msg string, count int)\n```\nWaitForLogMessageCount waits until at least count log message containing the specified msg is emitted\n\n```go\nfunc WaitTimeout(t *testing.T) time.Duration\n```\nWaitTimeout returns a timeout based on the test's Deadline, if available. Especially important to use in parallel tests, as their individual execution can get paused for arbitrary amounts of time.\n\n```go\nfunc WaitWithTimeout(t *testing.T, ch \u003c-chan struct{}, failMsg string)\n```\nWaitWithTimeout waits for the channel to close (or receive anything) and fatals the test if the default wait timeout is exceeded\n\n## Types\n\n```go\ntype JSONRPCHandler func(reqMethod string, reqParams gjson.Result) JSONRPCResponse\n```\nJSONRPCHandler is called with the method and request param(s). respResult will be sent immediately. notifyResult is optional, and sent after a short delay.\n\n```go\ntype JSONRPCResponse struct {\n\tResult, Notify string // raw JSON (i.e. quoted strings etc.)\n\n\tError struct {\n\t\tCode    int\n\t\tMessage string\n\t}\n}\n```\n\n","path":"github.com/GoPlugin/pluginV2/core/internal/testutils","name":"testutils","synopsis":"","isRedistributable":true}
