Documentation ¶
Index ¶
- Variables
- func CheckNodeStarted(t *testing.T, gossamerHost string) error
- func CreateConfigBabeMaxThreshold()
- func CreateConfigLogGrandpa()
- func CreateConfigNoBabe()
- func CreateDefaultConfig()
- func DecodeRPC(t *testing.T, body []byte, target interface{}) error
- func DecodeRPC_NT(body []byte, target interface{}) error
- func DecodeWebsocket(t *testing.T, body []byte, target interface{}) error
- func EpochLength(t *testing.T, node *Node) uint64
- func GenerateGenesisOneAuth()
- func GenerateGenesisSixAuth()
- func GenerateGenesisThreeAuth()
- func GetBlock(t *testing.T, node *Node, hash common.Hash) *types.Block
- func GetBlockHash(t *testing.T, node *Node, num string) (common.Hash, error)
- func GetChainHead(t *testing.T, node *Node) *types.Header
- func GetChainHeadWithError(t *testing.T, node *Node) (*types.Header, error)
- func GetFinalizedHead(t *testing.T, node *Node) common.Hash
- func GetFinalizedHeadByRound(t *testing.T, node *Node, round uint64) (common.Hash, error)
- func GetHeader(t *testing.T, node *Node, hash common.Hash) *types.Header
- func GetPeers(t *testing.T, node *Node) []common.PeerInfo
- func GetStorage(t *testing.T, node *Node, key []byte) []byte
- func HeaderResponseToHeader(t *testing.T, header *modules.ChainBlockHeaderResponse) *types.Header
- func KillProcess(t *testing.T, cmd *exec.Cmd) error
- func NewEndpoint(port string) string
- func PauseBABE(t *testing.T, node *Node) error
- func PostRPC(method, host, params string) ([]byte, error)
- func PostRPCWithRetry(method, host, params string, retry int) ([]byte, error)
- func SetLogLevel(lvl log.Lvl)
- func SlotDuration(t *testing.T, node *Node) time.Duration
- func StartGossamer(t *testing.T, node *Node, websocket bool) error
- func StartNodes(t *testing.T, nodes []*Node) error
- func StopNodes(t *testing.T, nodes []*Node) (errs []error)
- func TearDown(t *testing.T, nodes []*Node) (errorList []error)
- func TestDir(t *testing.T, name string) string
- type ErrCode
- type Error
- type Framework
- func (fw *Framework) CallRPC(idx int, method, params string) (respJSON interface{}, err error)
- func (fw *Framework) CheckEqual(c1, c2 int, field string) bool
- func (fw *Framework) GetRecord(callIdx int) interface{}
- func (fw *Framework) KillNodes(t *testing.T) []error
- func (fw *Framework) PrintDB()
- func (fw *Framework) StartNodes(t *testing.T) (errorList []error)
- type Node
- func InitGossamer(idx int, basePath, genesis, config string) (*Node, error)
- func InitNodes(num int, config string) ([]*Node, error)
- func InitializeAndStartNodes(t *testing.T, num int, genesis, config string) ([]*Node, error)
- func InitializeAndStartNodesWebsocket(t *testing.T, num int, genesis, config string) ([]*Node, error)
- func RunGossamer(t *testing.T, idx int, basepath, genesis, config string, websocket bool) (*Node, error)
- type ServerResponse
- type WebsocketResponse
Constants ¶
This section is empty.
Variables ¶
var ( MODE = os.Getenv("MODE") HOSTNAME = os.Getenv("HOSTNAME") PORT = os.Getenv("PORT") LOGLEVEL = os.Getenv("LOG") NETWORK_SIZE = os.Getenv("NETWORK_SIZE") ContentTypeJSON = "application/json" )
nolint
var ( // KeyList is the list of built-in keys KeyList = []string{"alice", "bob", "charlie", "dave", "eve", "ferdie", "george", "heather", "ian"} // BaseRPCPort is the starting RPC port for test nodes BaseRPCPort = 8540 // BaseWSPort is the starting Websocket port for test nodes BaseWSPort = 8546 // GenesisOneAuth is the genesis file that has 1 authority GenesisOneAuth string = filepath.Join(currentDir, "../utils/genesis_oneauth.json") // GenesisThreeAuths is the genesis file that has 3 authorities GenesisThreeAuths string = filepath.Join(currentDir, "../utils/genesis_threeauths.json") // GenesisSixAuths is the genesis file that has 6 authorities GenesisSixAuths string = filepath.Join(currentDir, "../utils/genesis_sixauths.json") // GenesisDefault is the default gssmr genesis file GenesisDefault string = filepath.Join(currentDir, "../..", "chain/gssmr/genesis.json") // ConfigDefault is the default config file ConfigDefault string = filepath.Join(currentDir, "../utils/config_default.toml") // ConfigLogGrandpa is a config file where log levels are set to CRIT except for GRANDPA ConfigLogGrandpa string = filepath.Join(currentDir, "../utils/config_log_grandpa.toml") // ConfigNoBABE is a config file with BABE disabled ConfigNoBABE string = filepath.Join(currentDir, "../utils/config_nobabe.toml") // ConfigBABEMaxThreshold is a config file with BABE threshold set to maximum (node can produce block every slot) ConfigBABEMaxThreshold string = filepath.Join(currentDir, "../utils/config_babe_max_threshold.toml") )
var ( // CHAIN METHODS ChainGetBlock = "chain_getBlock" ChainGetHeader = "chain_getHeader" ChainGetFinalizedHead = "chain_getFinalizedHead" ChainGetFinalizedHeadByRound = "chain_getFinalizedHeadByRound" ChainGetBlockHash = "chain_getBlockHash" // AUTHOR METHODS AuthorSubmitExtrinsic = "author_submitExtrinsic" AuthorPendingExtrinsics = "author_pendingExtrinsics" // STATE METHODS StateGetStorage = "state_getStorage" // DEV METHODS DevControl = "dev_control" // GRANDPA GrandpaProveFinality = "grandpa_proveFinality" )
nolint
Functions ¶
func CheckNodeStarted ¶
CheckNodeStarted check if gossamer node is started
func CreateConfigBabeMaxThreshold ¶ added in v0.2.0
func CreateConfigBabeMaxThreshold()
CreateConfigBabeMaxThreshold generates and creates babe max threshold config file.
func CreateConfigLogGrandpa ¶ added in v0.2.0
func CreateConfigLogGrandpa()
CreateConfigLogGrandpa generates and creates grandpa config file.
func CreateConfigNoBabe ¶ added in v0.2.0
func CreateConfigNoBabe()
CreateConfigNoBabe generates and creates no babe config file.
func CreateDefaultConfig ¶ added in v0.3.0
func CreateDefaultConfig()
CreateDefaultConfig generates and creates default config file.
func DecodeRPC_NT ¶ added in v0.2.0
DecodeRPC_NT will decode []body into target interface (NT is Not Test testing required)
func DecodeWebsocket ¶ added in v0.2.0
DecodeWebsocket will decode body into target interface
func EpochLength ¶ added in v0.3.0
EpochLength Calls dev endpoint for epoch length
func GenerateGenesisOneAuth ¶ added in v0.2.0
func GenerateGenesisOneAuth()
GenerateGenesisOneAuth generates Genesis file with one authority.
func GenerateGenesisSixAuth ¶ added in v0.2.0
func GenerateGenesisSixAuth()
GenerateGenesisSixAuth generates Genesis file with six authority.
func GenerateGenesisThreeAuth ¶ added in v0.2.0
func GenerateGenesisThreeAuth()
GenerateGenesisThreeAuth generates Genesis file with three authority.
func GetBlockHash ¶ added in v0.2.0
GetBlockHash calls the endpoint chain_getBlockHash to get the latest chain head
func GetChainHead ¶ added in v0.2.0
GetChainHead calls the endpoint chain_getHeader to get the latest chain head
func GetChainHeadWithError ¶ added in v0.2.0
GetChainHeadWithError calls the endpoint chain_getHeader to get the latest chain head
func GetFinalizedHead ¶ added in v0.2.0
GetFinalizedHead calls the endpoint chain_getFinalizedHead to get the latest finalized head
func GetFinalizedHeadByRound ¶ added in v0.2.0
GetFinalizedHeadByRound calls the endpoint chain_getFinalizedHeadByRound to get the finalized head at a given round TODO: add setID, hard-coded at 1 for now
func GetStorage ¶ added in v0.2.0
GetStorage calls the endpoint state_getStorage
func HeaderResponseToHeader ¶ added in v0.2.0
HeaderResponseToHeader converts a *ChainBlockHeaderResponse to a *types.Header
func KillProcess ¶
KillProcess kills a instance of gossamer
func NewEndpoint ¶ added in v0.2.0
NewEndpoint will create a new endpoint string based on utils.HOSTNAME and port
func PauseBABE ¶ added in v0.2.0
PauseBABE calls the endpoint dev_control with the params ["babe", "stop"]
func PostRPCWithRetry ¶ added in v0.2.0
PostRPCWithRetry is a wrapper around `PostRPC` that calls it `retry` number of times.
func SetLogLevel ¶ added in v0.2.0
SetLogLevel sets the logging level for this package
func SlotDuration ¶ added in v0.3.0
SlotDuration Calls dev endpoint for slot duration
func StartGossamer ¶ added in v0.2.0
StartGossamer starts given node
func StartNodes ¶
StartNodes starts given array of nodes
Types ¶
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
type Framework ¶ added in v0.2.0
type Framework struct {
// contains filtered or unexported fields
}
Framework struct to hold references to framework data
func InitFramework ¶ added in v0.2.0
InitFramework creates given quanity of nodes
func (*Framework) CallRPC ¶ added in v0.2.0
CallRPC call RPC method with given params for node at idx
func (*Framework) CheckEqual ¶ added in v0.2.0
CheckEqual returns true if the field values are equal
func (*Framework) GetRecord ¶ added in v0.2.0
GetRecord return value of record for node and call index
type Node ¶
type Node struct { Process *exec.Cmd Key string RPCPort string Idx int WSPort string // contains filtered or unexported fields }
Node represents a gossamer process
func InitGossamer ¶ added in v0.2.0
InitGossamer initializes given node number and returns node reference
func InitializeAndStartNodes ¶ added in v0.2.0
InitializeAndStartNodes 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
type WebsocketResponse ¶ added in v0.2.0
type WebsocketResponse struct { // JSON-RPC Version Version string `json:"jsonrpc"` // Method name called Method string `json:"method"` // Resulting values Result json.RawMessage `json:"result"` // Params values including results Params json.RawMessage `json:"params"` // Any generated errors Error *Error `json:"error"` // Request id Subscription *json.RawMessage `json:"subscription"` // Request id ID *json.RawMessage `json:"id"` }
WebsocketResponse wraps the Websocket response