testing

package
v0.0.0-...-26d7e6f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2021 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Password = "password"
)

Variables

This section is empty.

Functions

func EmptyCLIContext

func EmptyCLIContext() *cli.Context
func Head(val interface{}) *models.Head

Head given the value convert it into an Head

func MustAddAccountToKeyStore

func MustAddAccountToKeyStore(
	t testing.TB,
	account *models.Account,
	keyJSONBytes []byte,
	store esStore.Store,
	keyStore client.KeyStoreInterface,
)

func MustAddAttemptToTx

func MustAddAttemptToTx(t *testing.T, store esStore.Store, txID uuid.UUID, attempt *models.TxAttempt)

func MustAddRandomAccountToKeystore

func MustAddRandomAccountToKeystore(
	t testing.TB,
	store esStore.Store,
	keyStore client.KeyStoreInterface,
	opts ...interface{},
) (account *models.Account, address common.Address)

func MustGenerateRandomAccount

func MustGenerateRandomAccount(t testing.TB, opts ...interface{}) (account *models.Account, keyJSONBytes []byte)

func MustInsertConfirmedTxWithAttempt

func MustInsertConfirmedTxWithAttempt(t *testing.T, store esStore.Store, nonce int64, broadcastBeforeBlockNum int64, fromAddress common.Address) *models.Tx

func MustInsertFatalErrorTx

func MustInsertFatalErrorTx(t *testing.T, store esStore.Store, fromAddress common.Address) *models.Tx

func MustInsertInProgressTxWithAttempt

func MustInsertInProgressTxWithAttempt(t *testing.T, store esStore.Store, nonce int64, fromAddress common.Address) *models.Tx

func MustInsertRandomAccount

func MustInsertRandomAccount(t testing.TB, store esStore.Store, opts ...interface{}) *models.Account

MustInsertRandomAccount inserts a randomly generated (not cryptographically secure) account for testing If using this with the keystore, it should be called before the keystore loads keys from the database

func MustInsertTxReceipt

func MustInsertTxReceipt(
	t *testing.T,
	store esStore.Store,
	blockNumber int64,
	blockHash common.Hash,
	txHash common.Hash,
	attempt *models.TxAttempt,
) *models.TxReceipt

func MustInsertUnconfirmedTxWithBroadcastAttempt

func MustInsertUnconfirmedTxWithBroadcastAttempt(t *testing.T, store esStore.Store, nonce int64, fromAddress common.Address) *models.Tx

func MustJSONDel

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

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 NewAddress

func NewAddress() common.Address

NewAddress return a random new address

func NewConfig

func NewConfig(t testing.TB) *types.Config

NewConfig creates a new Config for testing

func NewHash

func NewHash() common.Hash

NewHash return random Keccak256

func NewRandomInt64

func NewRandomInt64() int64

func NewStore

func NewStore(t testing.TB) store.Store

NewStore creates a new Store for testing

func NewTx

func NewTx(t *testing.T, fromAddress common.Address) *models.Tx

func NewTxAttempt

func NewTxAttempt(t *testing.T, txID uuid.UUID) *models.TxAttempt

func Random32Byte

func Random32Byte() (b [32]byte)

Types

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) OnNewLongestChain

func (m *MockHeadTrackable) OnNewLongestChain(context.Context, *models.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 NeverSleeper

type NeverSleeper struct{}

NeverSleeper is a struct that never sleeps

func (NeverSleeper) After

func (ns NeverSleeper) After() time.Duration

After returns a duration

func (NeverSleeper) Duration

func (ns NeverSleeper) Duration() time.Duration

Duration returns a duration

func (NeverSleeper) Reset

func (ns NeverSleeper) Reset()

Reset resets the never sleeper

func (NeverSleeper) Sleep

func (ns NeverSleeper) Sleep()

Sleep puts the never sleeper to sleep

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL