test

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2018 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package test offers testing utilities to ipfs-cluster like mocks

Index

Constants

This section is empty.

Variables

View Source
var (
	TestCid1 = "QmP63DkAFEnDYNjDYBpyNDfttu1fvUw99x1brscPzpqmmq"
	TestCid2 = "QmP63DkAFEnDYNjDYBpyNDfttu1fvUw99x1brscPzpqmma"
	TestCid3 = "QmP63DkAFEnDYNjDYBpyNDfttu1fvUw99x1brscPzpqmmb"
	// ErrorCid is meant to be used as a Cid which causes errors. i.e. the
	// ipfs mock fails when pinning this CID.
	ErrorCid       = "QmP63DkAFEnDYNjDYBpyNDfttu1fvUw99x1brscPzpqmmc"
	TestPeerID1, _ = peer.IDB58Decode("QmXZrtE5jQwXNqCJMfHUTQkvhQ4ZAnqMnmzFMJfLewuabc")
	TestPeerID2, _ = peer.IDB58Decode("QmUZ13osndQ5uL4tPWHXe3iBgBgq9gfewcBMSCAuMBsDJ6")
	TestPeerID3, _ = peer.IDB58Decode("QmPGDFvBkgWhvzEK9qaTWrWurSwqXNmhnK3hgELPdZZNPa")
	TestPeerID4, _ = peer.IDB58Decode("QmZ8naDy5mEz4GLuQwjWt9MPYqHTBbsm8tQBrNSjiq6zBc")
	TestPeerID5, _ = peer.IDB58Decode("QmZVAo3wd8s5eTTy2kPYs34J9PvfxpKPuYsePPYGjgRRjg")
	TestPeerID6, _ = peer.IDB58Decode("QmR8Vu6kZk7JvAN2rWVWgiduHatgBq2bb15Yyq8RRhYSbx")
)

Common variables used all around tests.

View Source
var ErrBadCid = errors.New("this is an expected error when using ErrorCid")

ErrBadCid is returned when using ErrorCid. Operations with that CID always fail.

Functions

func NewMockRPCClient

func NewMockRPCClient(t *testing.T) *rpc.Client

NewMockRPCClient creates a mock ipfs-cluster RPC server and returns a client to it.

func NewMockRPCClientWithHost added in v0.3.0

func NewMockRPCClientWithHost(t *testing.T, h host.Host) *rpc.Client

NewMockRPCClientWithHost returns a mock ipfs-cluster RPC server initialized with a given host.

Types

type IpfsMock

type IpfsMock struct {
	Addr string
	Port int
	// contains filtered or unexported fields
}

IpfsMock is an ipfs daemon mock which should sustain the functionality used by ipfscluster.

func NewIpfsMock

func NewIpfsMock() *IpfsMock

NewIpfsMock returns a new mock.

func (*IpfsMock) Close

func (m *IpfsMock) Close()

Close closes the mock server. It's important to call after each test or the listeners are left hanging around.

Jump to

Keyboard shortcuts

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