mocks

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 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",
	}

	// List of a few peer IDs in case multiple are required.
	GenericPeerIDs = []peer.ID{
		peer.ID([]byte{0x0, 0x24, 0x8, 0x1, 0x12, 0x20, 0xe5, 0xc, 0xbd, 0xb8, 0xff, 0xed, 0x5a, 0x74, 0x48, 0x4, 0x2, 0x33, 0x4e, 0x42, 0xc, 0x40, 0xab, 0x28, 0x3a, 0x28, 0xdb, 0x5, 0x7e, 0xc6, 0xf5, 0x0, 0x6f, 0x36, 0xa2, 0x8d, 0x82, 0x48}),
		peer.ID([]byte{0x0, 0x24, 0x8, 0x1, 0x12, 0x20, 0x19, 0x2a, 0x38, 0x8d, 0xf9, 0x66, 0xa1, 0x14, 0xea, 0x6c, 0xce, 0x1f, 0xf2, 0x3b, 0xee, 0x3b, 0x56, 0xe9, 0x56, 0x27, 0x7e, 0x70, 0x1b, 0x49, 0x9c, 0x25, 0x5, 0x8e, 0xb, 0xda, 0xa3, 0x87}),
		peer.ID([]byte{0x0, 0x24, 0x8, 0x1, 0x12, 0x20, 0x68, 0xbc, 0x89, 0x26, 0x87, 0xd5, 0x10, 0x62, 0xa8, 0x6, 0x83, 0xb4, 0xae, 0x62, 0xe1, 0x87, 0xe7, 0xcd, 0x4e, 0x2b, 0x58, 0xa5, 0x82, 0x3b, 0x6a, 0xf6, 0x57, 0x83, 0x38, 0x80, 0x5b, 0xc2}),
		peer.ID([]byte{0x0, 0x24, 0x8, 0x1, 0x12, 0x20, 0x26, 0xa8, 0xd0, 0xc6, 0x7c, 0x0, 0xcb, 0xf, 0x7e, 0x23, 0xd9, 0x1c, 0x88, 0xef, 0xc6, 0x2a, 0xd5, 0xa3, 0x18, 0xb5, 0xde, 0xa7, 0x21, 0x44, 0xb0, 0x38, 0xa7, 0xc9, 0x18, 0x6f, 0xd1, 0x25}),
		peer.ID([]byte{0x0, 0x24, 0x8, 0x1, 0x12, 0x20, 0x5e, 0x5d, 0x44, 0xfe, 0xde, 0xbc, 0xd7, 0xbd, 0x82, 0xcd, 0x49, 0x23, 0xe8, 0x48, 0x46, 0x56, 0xca, 0x61, 0x13, 0x9d, 0xf4, 0x14, 0x5, 0x8a, 0x87, 0xdd, 0xd2, 0xd9, 0xd6, 0x1c, 0xc4, 0xc2}),
		peer.ID([]byte{0x0, 0x24, 0x8, 0x1, 0x12, 0x20, 0x37, 0xf2, 0xf0, 0x1a, 0x4f, 0x1a, 0xaf, 0xd3, 0x48, 0xf4, 0xe8, 0xa7, 0x4b, 0xb, 0xfe, 0x5, 0xbb, 0x18, 0x1, 0xcb, 0x44, 0x1d, 0xe4, 0x4, 0x31, 0x5c, 0x55, 0xf, 0xbd, 0xae, 0x77, 0x95}),
		peer.ID([]byte{0x0, 0x24, 0x8, 0x1, 0x12, 0x20, 0x9, 0xb1, 0x4c, 0x68, 0xd5, 0x17, 0x29, 0x76, 0xbc, 0xca, 0xe8, 0xa8, 0x76, 0x7c, 0x2b, 0x82, 0x68, 0xa1, 0xae, 0xe8, 0x35, 0x4b, 0x42, 0xff, 0x5f, 0xaa, 0xe9, 0x6, 0x2d, 0x46, 0xa1, 0x9c}),
		peer.ID([]byte{0x0, 0x24, 0x8, 0x1, 0x12, 0x20, 0xc3, 0x36, 0xd9, 0xea, 0x3, 0x29, 0x85, 0x17, 0x8e, 0x60, 0xa, 0xc5, 0xf, 0x5d, 0xe3, 0xe8, 0xd, 0x1c, 0x53, 0x7b, 0x31, 0x82, 0x58, 0xc9, 0x4e, 0x80, 0x97, 0x8d, 0x6d, 0x1c, 0x97, 0x86}),
		peer.ID([]byte{0x0, 0x24, 0x8, 0x1, 0x12, 0x20, 0x49, 0xbd, 0x82, 0x34, 0x7d, 0x97, 0xd, 0xb5, 0x52, 0xf5, 0x82, 0x47, 0x8b, 0xc, 0x42, 0x16, 0x22, 0xa5, 0x24, 0x32, 0xf2, 0x24, 0xfb, 0xc7, 0x44, 0xd1, 0xfc, 0xe1, 0x2e, 0xd3, 0x70, 0xa7}),
		peer.ID([]byte{0x0, 0x24, 0x8, 0x1, 0x12, 0x20, 0x24, 0x49, 0x1b, 0x67, 0x6, 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15, 0xc6}),
		peer.ID([]byte{0x0, 0x24, 0x8, 0x1, 0x12, 0x20, 0xc6, 0x8f, 0x95, 0xd3, 0x98, 0x66, 0x40, 0x6b, 0xc4, 0x6c, 0x19, 0x5e, 0x80, 0xe0, 0x8c, 0x9b, 0x15, 0x4f, 0x8c, 0x6b, 0xd0, 0x1d, 0x5b, 0x83, 0x23, 0x7b, 0x9a, 0x97, 0xc0, 0x9b, 0x9d, 0x9b}),
	}
)

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, string) (codes.Code, string, execute.ResultMap, execute.Cluster, error)
	ExecutionResultFunc        func(id string) (execute.Result, bool)
	PublishFunctionInstallFunc func(ctx context.Context, uri string, cid string, subgroup 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, subgroup string) (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, subgroup 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
}

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

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