utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: LGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GOSSAMER_INTEGRATION_TEST_MODE = os.Getenv("GOSSAMER_INTEGRATION_TEST_MODE")

	HOSTNAME = os.Getenv("HOSTNAME")
	PORT     = os.Getenv("PORT")

	NETWORK_SIZE = os.Getenv("NETWORK_SIZE")

	ContentTypeJSON = "application/json"
)

nolint

View Source
var (

	// BaseRPCPort is the starting RPC port for test nodes
	BaseRPCPort = 8540
)

TODO: #799

Functions

func CheckNodeStarted

func CheckNodeStarted(t *testing.T, gossamerHost string) error

CheckNodeStarted check if gossamer node is already started

func DecodeRPC

func DecodeRPC(t *testing.T, body []byte, target interface{}) error

DecodeRPC will decode []body into target interface

func KillProcess

func KillProcess(t *testing.T, cmd *exec.Cmd) error

KillProcess kills a instance of gossamer

func PostRPC

func PostRPC(t *testing.T, method, host, params string) ([]byte, error)

PostRPC utils for sending payload to endpoint and getting []byte back

func TearDown

func TearDown(t *testing.T, nodes []*Node) (errorList []error)

TearDown will stop gossamer nodes

Types

type ErrCode

type ErrCode int

ErrCode is a int type used for the rpc error codes

type Error

type Error struct {
	Message   string                 `json:"message"`
	ErrorCode ErrCode                `json:"code"`
	Data      map[string]interface{} `json:"data"`
}

Error is a struct that holds the error message and the error code for a error

func (*Error) Error

func (e *Error) Error() string

Error returns the error Message string

type Node

type Node struct {
	Process *exec.Cmd
	Key     string
	RPCPort string
	Idx     int
}

Node represents a gossamer process

func RunGossamer

func RunGossamer(t *testing.T, idx int, basePath string) (*Node, error)

RunGossamer will start a gossamer instance and check if its online and returns CMD, otherwise return err

func StartNodes

func StartNodes(t *testing.T, num int) ([]*Node, error)

StartNodes will spin up `num` gossamer nodes

type ServerResponse

type ServerResponse struct {
	// JSON-RPC Version
	Version string `json:"jsonrpc"`
	// Resulting values
	Result json.RawMessage `json:"result"`
	// Any generated errors
	Error *Error `json:"error"`
	// Request id
	ID *json.RawMessage `json:"id"`
}

ServerResponse wraps the RPC response

Jump to

Keyboard shortcuts

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