coretesting

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: Apache-2.0 Imports: 16 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KVStoreService

func KVStoreService(ctx context.Context, moduleName string) store.KVStoreService

func NewMemDB

func NewMemDB() store.KVStoreWithBatch

NewMemDB creates a new MemDB.

func NewNopLogger

func NewNopLogger() log.Logger

NewNopLogger returns a new logger that does nothing.

func NewTestEnvironment added in v0.0.2

func NewTestEnvironment(cfg TestEnvironmentConfig) (TestContext, TestEnvironment)

Types

type MemDB

type MemDB struct {
	// contains filtered or unexported fields
}

MemDB is a simple in-memory key-value store with Batch support.

func (*MemDB) Close

func (db *MemDB) Close() error

Close closes the MemDB, releasing any resources held.

func (*MemDB) Delete

func (bt *MemDB) Delete(key []byte) error

func (*MemDB) DeleteSync

func (bt *MemDB) DeleteSync(key []byte) error

func (*MemDB) Get

func (bt *MemDB) Get(key []byte) ([]byte, error)

func (*MemDB) Has

func (bt *MemDB) Has(key []byte) (bool, error)

func (*MemDB) Iterator

func (bt *MemDB) Iterator(start, end []byte) (store.Iterator, error)

func (*MemDB) NewBatch

func (db *MemDB) NewBatch() store.Batch

NewBatch returns a new memDBBatch.

func (*MemDB) NewBatchWithSize

func (db *MemDB) NewBatchWithSize(size int) store.Batch

NewBatchWithSize returns a new memDBBatch with the given size.

func (*MemDB) Print

func (db *MemDB) Print() error

func (*MemDB) ReverseIterator

func (bt *MemDB) ReverseIterator(start, end []byte) (store.Iterator, error)

func (*MemDB) Set

func (bt *MemDB) Set(key, value []byte) error

func (*MemDB) SetSync

func (bt *MemDB) SetSync(key, value []byte) error

func (*MemDB) Stats

func (db *MemDB) Stats() map[string]string

type MemKV

type MemKV struct {
	// contains filtered or unexported fields
}

MemKV a lightweight memory db

func NewMemKV

func NewMemKV() MemKV

NewMemKV creates a wrapper around `btree.BTreeG`.

func (MemKV) Delete

func (bt MemKV) Delete(key []byte) error

func (MemKV) Get

func (bt MemKV) Get(key []byte) ([]byte, error)

func (MemKV) Has

func (bt MemKV) Has(key []byte) (bool, error)

func (MemKV) Iterator

func (bt MemKV) Iterator(start, end []byte) (store.Iterator, error)

func (MemKV) ReverseIterator

func (bt MemKV) ReverseIterator(start, end []byte) (store.Iterator, error)

func (MemKV) Set

func (bt MemKV) Set(key, value []byte) error

type TestBranchService added in v0.0.2

type TestBranchService struct{}

func (TestBranchService) Execute added in v0.0.2

func (bs TestBranchService) Execute(ctx context.Context, f func(ctx context.Context) error) error

func (TestBranchService) ExecuteWithGasLimit added in v0.0.2

func (bs TestBranchService) ExecuteWithGasLimit(
	ctx context.Context,
	gasLimit uint64,
	f func(ctx context.Context) error,
) (gasUsed uint64, err error)

type TestContext added in v0.0.2

type TestContext struct {
	context.Context
}

func Context

func Context() TestContext

func (TestContext) WithExecMode added in v0.0.2

func (t TestContext) WithExecMode(mode transaction.ExecMode) TestContext

WithExecMode sets the exec mode on a testing ctx and returns the updated ctx.

func (TestContext) WithGas added in v0.0.2

func (t TestContext) WithGas(gasConfig gas.GasConfig, gasMeter gas.Meter) TestContext

WithGas sets the gas config and meter on a testing ctx and returns the updated ctx.

func (TestContext) WithHeaderInfo added in v0.0.2

func (t TestContext) WithHeaderInfo(info header.Info) TestContext

WithHeaderInfo sets the header on a testing ctx and returns the updated ctx.

type TestEnvironment added in v0.0.2

type TestEnvironment struct {
	appmodulev2.Environment
	// contains filtered or unexported fields
}

func (TestEnvironment) EventService added in v0.0.2

func (env TestEnvironment) EventService() TestEventService

func (TestEnvironment) HeaderService added in v0.0.2

func (env TestEnvironment) HeaderService() TestHeaderService

func (TestEnvironment) KVStoreService added in v0.0.2

func (env TestEnvironment) KVStoreService() store.KVStoreService

type TestEnvironmentConfig added in v0.0.2

type TestEnvironmentConfig struct {
	ModuleName  string
	Logger      corelog.Logger
	MsgRouter   router.Service
	QueryRouter router.Service
}

type TestEventService added in v0.0.2

type TestEventService struct {
	// contains filtered or unexported fields
}

func NewTestEventService added in v0.0.2

func NewTestEventService(ctx context.Context, moduleName string) TestEventService

NewTestEventService attaches an event service to the context. Adding an existing module will reset the events.

func (TestEventService) EventManager added in v0.0.2

func (e TestEventService) EventManager(ctx context.Context) event.Manager

func (TestEventService) GetEvents added in v0.0.2

func (e TestEventService) GetEvents(ctx context.Context) []event.Event

func (TestEventService) GetProtoEvents added in v0.0.2

func (e TestEventService) GetProtoEvents(ctx context.Context) []transaction.Msg

type TestGasService added in v0.0.2

type TestGasService struct{}

func (TestGasService) GasConfig added in v0.0.2

func (m TestGasService) GasConfig(ctx context.Context) gas.GasConfig

func (TestGasService) GasMeter added in v0.0.2

func (m TestGasService) GasMeter(ctx context.Context) gas.Meter

type TestHeaderService added in v0.0.2

type TestHeaderService struct{}

func (TestHeaderService) HeaderInfo added in v0.0.2

func (e TestHeaderService) HeaderInfo(ctx context.Context) header.Info

type TestTransactionService added in v0.0.2

type TestTransactionService struct{}

func (TestTransactionService) ExecMode added in v0.0.2

Directories

Path Synopsis
Package gas is a generated GoMock package.
Package gas is a generated GoMock package.

Jump to

Keyboard shortcuts

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