mocks

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NoopLogger = zerolog.New(io.Discard)

	GenericError = errors.New("dummy error")

	GenericPeerID = peer.ID([]byte{0x0, 0x24, 0x8, 0x1, 0x12, 0x20, 0x56, 0x77, 0x86, 0x82, 0x76, 0xa, 0xc5, 0x9, 0x63, 0xde, 0xe4, 0x31, 0xfc, 0x44, 0x75, 0xdd, 0x5a, 0x27, 0xee, 0x6b, 0x94, 0x13, 0xed, 0xe2, 0xa3, 0x6d, 0x8a, 0x1d, 0x57, 0xb6, 0xb8, 0x91})

	GenericAddress = "/ip4/127.0.0.1/tcp/9000/p2p/12D3KooWRp3AVk7qtc2Av6xiqgAza1ZouksQaYcS2cvN94kHSCoa"

	GenericString = "test"

	GenericUUID = uuid.UUID{0xd1, 0xc2, 0x44, 0xaf, 0xa3, 0x1d, 0x48, 0x87, 0x93, 0x9d, 0xd6, 0xc7, 0xf, 0xe, 0x4f, 0xd0}

	GenericExecutionResult = execute.Result{
		Code: codes.Unknown,
		Result: execute.RuntimeOutput{
			Stdout:   "generic-execution-result",
			Stderr:   "generic-execution-log",
			ExitCode: 0,
		},
		RequestID: GenericUUID.String(),
	}

	GenericExecutionRequest = execute.Request{
		FunctionID: "generic-function-id",
		Method:     "wasm",
		Parameters: []execute.Parameter{
			{
				Name:  "generic-param-name",
				Value: "generic-param-value",
			},
		},
	}

	GenericManifest = blockless.FunctionManifest{
		ID:          "generic-id",
		Name:        "generic-name",
		Description: "generic-description",
		Function: blockless.Function{
			ID:      "function-id",
			Name:    "function-name",
			Runtime: "generic-runtime",
		},
		Deployment: blockless.Deployment{
			CID:      "generic-cid",
			Checksum: "1234567890",
			URI:      "generic-uri",
		},
		FSRootPath: "/var/tmp/blockless/",
		Entry:      "/var/tmp/blockless/app.wasm",
	}
)

Global variables that can be used for testing. They are valid non-nil values for commonly needed types.

Functions

This section is empty.

Types

type Executor

type Executor struct {
	ExecFunctionFunc func(string, execute.Request) (execute.Result, error)
}

func BaselineExecutor

func BaselineExecutor(t *testing.T) *Executor

func (*Executor) ExecuteFunction

func (e *Executor) ExecuteFunction(requestID string, req execute.Request) (execute.Result, error)

type FStore

type FStore struct {
	InstallFunc            func(string, string) error
	GetFunc                func(string) (*blockless.FunctionManifest, error)
	InstalledFunc          func(string) (bool, error)
	InstalledFunctionsFunc func() ([]string, error)
	SyncFunc               func(string) error
}

func BaselineFStore

func BaselineFStore(t *testing.T) *FStore

func (*FStore) Get

func (f *FStore) Get(cid string) (*blockless.FunctionManifest, error)

func (*FStore) Install

func (f *FStore) Install(address string, cid string) error

func (*FStore) Installed

func (f *FStore) Installed(cid string) (bool, error)

func (*FStore) InstalledFunctions

func (f *FStore) InstalledFunctions() ([]string, error)

func (*FStore) Sync

func (f *FStore) Sync(cid string) error

type Node

type Node struct {
	ExecuteFunctionFunc        func(context.Context, execute.Request) (codes.Code, string, execute.ResultMap, execute.Cluster, error)
	ExecutionResultFunc        func(id string) (execute.Result, bool)
	PublishFunctionInstallFunc func(ctx context.Context, uri string, cid string) error
}

Node implements the `Node` interface expected by the API.

func BaselineNode

func BaselineNode(t *testing.T) *Node

func (*Node) ExecuteFunction

func (n *Node) ExecuteFunction(ctx context.Context, req execute.Request) (codes.Code, string, execute.ResultMap, execute.Cluster, error)

func (*Node) ExecutionResult

func (n *Node) ExecutionResult(id string) (execute.Result, bool)

func (*Node) PublishFunctionInstall

func (n *Node) PublishFunctionInstall(ctx context.Context, uri string, cid string) error

type PeerStore

type PeerStore struct {
	GetFunc    func(peer.ID) (blockless.Peer, error)
	StoreFunc  func(peer.ID, multiaddr.Multiaddr, peer.AddrInfo) error
	PeersFunc  func() ([]blockless.Peer, error)
	RemoveFunc func(peer.ID) error
}

func BaselinePeerStore

func BaselinePeerStore(t *testing.T) *PeerStore

func (*PeerStore) Get

func (p *PeerStore) Get(id peer.ID) (blockless.Peer, error)

func (*PeerStore) Peers

func (p *PeerStore) Peers() ([]blockless.Peer, error)

func (*PeerStore) Remove

func (p *PeerStore) Remove(id peer.ID) error

func (*PeerStore) Store

func (p *PeerStore) Store(id peer.ID, addr multiaddr.Multiaddr, info peer.AddrInfo) error

type Store

type Store struct {
	GetFunc       func(key string) (string, error)
	SetFunc       func(key string, value string) error
	GetRecordFunc func(key string, value interface{}) error
	SetRecordFunc func(key string, value interface{}) error
	DeleteFunc    func(key string) error
	KeysFunc      func() ([]string, error)
}

func BaselineStore

func BaselineStore(t *testing.T) *Store

func (*Store) Delete

func (s *Store) Delete(key string) error

func (*Store) Get

func (s *Store) Get(key string) (string, error)

func (*Store) GetRecord

func (s *Store) GetRecord(key string, value interface{}) error

func (*Store) Keys

func (s *Store) Keys() ([]string, error)

func (*Store) Set

func (s *Store) Set(key string, value string) error

func (*Store) SetRecord

func (s *Store) SetRecord(key string, value interface{}) error

Jump to

Keyboard shortcuts

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