testutil

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AMPublishCode added in v0.0.6

func AMPublishCode(
	t testing.TB,
	am core.ArtifactManager,
	domain core.RecordRef,
	request core.RecordRef,
	mtype core.MachineType,
	code []byte,
) (
	typeRef *core.RecordRef,
	codeRef *core.RecordRef,
	classRef *core.RecordRef,
	err error,
)

AMPublishCode publishes code on ledger

func Build added in v0.2.0

func Build() (string, string, error)

Build compiles and return path to insgorund and insgocc binaries.

func CBORMarshal added in v0.0.6

func CBORMarshal(t testing.TB, o interface{}) []byte

CBORMarshal - testing serialize helper

func CBORUnMarshal added in v0.0.6

func CBORUnMarshal(t testing.TB, data []byte) interface{}

CBORUnMarshal - testing deserialize helper

func CBORUnMarshalToSlice added in v0.2.0

func CBORUnMarshalToSlice(t testing.TB, in []byte) []interface{}

CBORUnMarshalToSlice - wrapper for CBORUnMarshal, expects slice

func ChangeGoPath

func ChangeGoPath(path string) (string, error)

ChangeGoPath prepends `path` to GOPATH environment variable accounting for possibly for default value. Returns original value of the environment variable, don't forget to restore it with defer:

defer os.Setenv("GOPATH", origGoPath)

func WriteFile

func WriteFile(dir string, name string, text string) error

WriteFile dumps `text` into file named `name` into directory `dir`. Creates directory if needed as well as file

Types

type ContractsBuilder added in v0.0.6

type ContractsBuilder struct {
	ArtifactManager core.ArtifactManager
	IccPath         string
	Classes         map[string]*core.RecordRef
	Codes           map[string]*core.RecordRef
	// contains filtered or unexported fields
}

ContractsBuilder for tests

func NewContractBuilder added in v0.0.6

func NewContractBuilder(am core.ArtifactManager, icc string) *ContractsBuilder

NewContractBuilder returns a new `ContractsBuilder`, takes in: path to tmp directory, artifact manager, ...

func (*ContractsBuilder) Build added in v0.0.6

func (cb *ContractsBuilder) Build(contracts map[string]string) error

Build ...

func (*ContractsBuilder) Clean added in v0.3.0

func (cb *ContractsBuilder) Clean()

type TestArtifactManager added in v0.0.6

type TestArtifactManager struct {
	Types   []core.MachineType
	Codes   map[core.RecordRef]*TestCodeDescriptor
	Objects map[core.RecordRef]*TestObjectDescriptor
	Classes map[core.RecordRef]*TestClassDescriptor
}

TestArtifactManager implementation for tests

func NewTestArtifactManager added in v0.0.6

func NewTestArtifactManager() *TestArtifactManager

NewTestArtifactManager implementation for tests

func (*TestArtifactManager) ActivateClass added in v0.0.6

func (t *TestArtifactManager) ActivateClass(domain core.RecordRef, request core.RecordRef) (*core.RecordRef, error)

ActivateClass implementation for tests

func (*TestArtifactManager) ActivateObject added in v0.3.0

func (t *TestArtifactManager) ActivateObject(domain core.RecordRef, request core.RecordRef, class core.RecordRef, parent core.RecordRef, memory []byte) (*core.RecordRef, error)

ActivateObject implementation for tests

func (*TestArtifactManager) ActivateObjectDelegate added in v0.3.0

func (t *TestArtifactManager) ActivateObjectDelegate(domain, request, class, parent core.RecordRef, memory []byte) (*core.RecordRef, error)

ActivateObjectDelegate implementation for tests

func (*TestArtifactManager) DeactivateClass added in v0.0.6

func (t *TestArtifactManager) DeactivateClass(domain core.RecordRef, request core.RecordRef, class core.RecordRef) (*core.RecordRef, error)

DeactivateClass implementation for tests

func (*TestArtifactManager) DeactivateObject added in v0.3.0

func (t *TestArtifactManager) DeactivateObject(domain core.RecordRef, request core.RecordRef, obj core.RecordRef) (*core.RecordRef, error)

DeactivateObject implementation for tests

func (*TestArtifactManager) DeclareType added in v0.0.6

func (t *TestArtifactManager) DeclareType(domain core.RecordRef, request core.RecordRef, typeDec []byte) (*core.RecordRef, error)

DeclareType implementation for tests

func (*TestArtifactManager) DeployCode added in v0.0.6

func (t *TestArtifactManager) DeployCode(domain core.RecordRef, request core.RecordRef, codeMap map[core.MachineType][]byte) (*core.RecordRef, error)

DeployCode implementation for tests

func (*TestArtifactManager) GetClass added in v0.3.0

func (t *TestArtifactManager) GetClass(object core.RecordRef, state *core.RecordRef) (core.ClassDescriptor, error)

GetClass implementation for tests

func (*TestArtifactManager) GetCode added in v0.0.6

func (t *TestArtifactManager) GetCode(code core.RecordRef, machinePref []core.MachineType) (core.CodeDescriptor, error)

GetCode implementation for tests

func (*TestArtifactManager) GetDelegate added in v0.3.0

func (t *TestArtifactManager) GetDelegate(head, asClass core.RecordRef) (*core.RecordRef, error)

GetDelegate implementation for tests

func (*TestArtifactManager) GetObject added in v0.3.0

func (t *TestArtifactManager) GetObject(object core.RecordRef, state *core.RecordRef) (core.ObjectDescriptor, error)

GetObject implementation for tests

func (*TestArtifactManager) RootRef added in v0.0.6

func (t *TestArtifactManager) RootRef() *core.RecordRef

RootRef implementation for tests

func (*TestArtifactManager) Start added in v0.0.6

func (t *TestArtifactManager) Start(components core.Components) error

Start implementation for tests

func (*TestArtifactManager) Stop added in v0.0.6

func (t *TestArtifactManager) Stop() error

Stop implementation for tests

func (*TestArtifactManager) UpdateClass added in v0.0.6

func (t *TestArtifactManager) UpdateClass(domain core.RecordRef, request core.RecordRef, class core.RecordRef, code core.RecordRef, migrationRefs []core.RecordRef) (*core.RecordRef, error)

UpdateClass implementation for tests

func (*TestArtifactManager) UpdateObject added in v0.3.0

func (t *TestArtifactManager) UpdateObject(domain core.RecordRef, request core.RecordRef, obj core.RecordRef, memory []byte) (*core.RecordRef, error)

UpdateObject implementation for tests

type TestClassDescriptor added in v0.0.6

type TestClassDescriptor struct {
	AM    *TestArtifactManager
	ARef  *core.RecordRef
	ACode *core.RecordRef
}

TestClassDescriptor ...

func (*TestClassDescriptor) CodeDescriptor added in v0.0.6

func (t *TestClassDescriptor) CodeDescriptor(machinePref []core.MachineType) (core.CodeDescriptor, error)

CodeDescriptor ...

func (*TestClassDescriptor) HeadRef added in v0.0.6

func (t *TestClassDescriptor) HeadRef() *core.RecordRef

HeadRef ...

func (*TestClassDescriptor) StateRef added in v0.0.6

func (t *TestClassDescriptor) StateRef() *core.RecordRef

StateRef ...

type TestCodeDescriptor added in v0.0.6

type TestCodeDescriptor struct {
	ARef         core.RecordRef
	ACode        []byte
	AMachineType core.MachineType
}

TestCodeDescriptor implementation for tests

func (*TestCodeDescriptor) Code added in v0.0.6

func (t *TestCodeDescriptor) Code() []byte

Code implementation for tests

func (*TestCodeDescriptor) MachineType added in v0.0.6

func (t *TestCodeDescriptor) MachineType() core.MachineType

MachineType implementation for tests

func (*TestCodeDescriptor) Ref added in v0.0.6

func (t *TestCodeDescriptor) Ref() *core.RecordRef

Ref implementation for tests

type TestMessageBus added in v0.4.0

type TestMessageBus struct {
	LogicRunner core.LogicRunner
}

TestMessageBus can execute messages on LogicRunner.

func NewTestMessageBus added in v0.4.0

func NewTestMessageBus(lr core.LogicRunner) *TestMessageBus

NewTestMessageBus creates TestMessageBus which mocks the real one.

func (*TestMessageBus) Register added in v0.4.0

func (eb *TestMessageBus) Register(p core.MessageType, handler core.MessageHandler) error

Register is the dummy mock of Register method

func (*TestMessageBus) Send added in v0.4.0

func (eb *TestMessageBus) Send(msg core.Message) (resp core.Reply, err error)

Send executes message on LogicRunner.

func (*TestMessageBus) SendAsync added in v0.4.0

func (*TestMessageBus) SendAsync(msg core.Message)

SendAsync sends message async

func (*TestMessageBus) Start added in v0.4.0

func (*TestMessageBus) Start(components core.Components) error

Start is the dummy mock of Start method.

func (*TestMessageBus) Stop added in v0.4.0

func (*TestMessageBus) Stop() error

Stop is the dummy mock of Stop method.

type TestObjectDescriptor added in v0.0.6

type TestObjectDescriptor struct {
	AM                *TestArtifactManager
	Data              []byte
	Code              *core.RecordRef
	Class             *core.RecordRef
	Delegates         map[core.RecordRef]core.RecordRef
	ChildrenContainer []core.RecordRef
}

TestObjectDescriptor implementation for tests

func (*TestObjectDescriptor) Children added in v0.3.0

func (t *TestObjectDescriptor) Children() core.RefIterator

Children implementation for tests

func (*TestObjectDescriptor) ClassDescriptor added in v0.0.6

func (t *TestObjectDescriptor) ClassDescriptor(state *core.RecordRef) (core.ClassDescriptor, error)

ClassDescriptor implementation for tests

func (*TestObjectDescriptor) HeadRef added in v0.0.6

func (t *TestObjectDescriptor) HeadRef() *core.RecordRef

HeadRef implementation for tests

func (*TestObjectDescriptor) Memory added in v0.0.6

func (t *TestObjectDescriptor) Memory() []byte

Memory implementation for tests

func (*TestObjectDescriptor) StateRef added in v0.0.6

func (t *TestObjectDescriptor) StateRef() *core.RecordRef

StateRef implementation for tests

Jump to

Keyboard shortcuts

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