engine

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GossipNetwork Gossip network type.
	GossipNetwork = byte(0)
	// KadcastNetwork  Kadcast network type.
	KadcastNetwork = byte(1)
)

Variables

View Source
var (
	// EnableHarness a test CLI param to enable harness bootstrapping.
	EnableHarness = flag.Bool("enable", false, "Enable Test Harness bootstrapping")
	// RPCNetworkType a test CLI param to set jsonrpc network type (unix or tcp).
	RPCNetworkType = flag.String("rpc_transport", "unix", "JSON-RPC transport type (unix/tcp)")
	// KeepAlive a test CLI param to keep harness running even after all tests have passed.
	// It's useful when additional manual tests should be done.
	KeepAlive = flag.Bool("keepalive", false, "Keep Test Harness alive after tests pass")

	// ErrDisabledHarness yields a disabled test harness.
	ErrDisabledHarness = errors.New("disabled test harness")

	// MOCK_ADDRESS is optional string for the mock address to listen to, eg: 127.0.0.1:8080.
	MOCK_ADDRESS = os.Getenv("MOCK_ADDRESS")

	// REQUIRE_SESSION is a flag to set the GRPC session.
	REQUIRE_SESSION = os.Getenv("REQUIRE_SESSION")

	// RUSK_EXE_PATH path to rusk executable.
	RUSK_EXE_PATH = os.Getenv("RUSK_PATH")
)

Functions

func ConstructWireFrame

func ConstructWireFrame(cmd topics.Topic, payload *bytes.Buffer) ([]byte, error)

ConstructWireFrame creates a frame according to the wire protocol.

func Profile1

func Profile1(index int, node *DuskNode, consensusKeysPath string)

Profile1 builds the default dusk.toml definition.

func Profile2

func Profile2(index int, node *DuskNode, walletPath string)

Profile2 builds dusk.toml with lite driver enabled (suitable for bench testing).

func Profile3 added in v0.4.0

func Profile3(index int, node *DuskNode, walletPath string)

Profile3 builds dusk.toml with kadcast enabled and gossip disabled.

func Profile4 added in v0.4.4

func Profile4(index int, node *DuskNode, walletPath string)

Profile4 builds dusk.toml with kadcast enabled over unix socket.

func WriteFrame

func WriteFrame(buf *bytes.Buffer) (*bytes.Buffer, error)

WriteFrame writes a frame to a buffer. TODO: remove *bytes.Buffer from the returned parameters.

Types

type DuskNode

type DuskNode struct {
	Id              string //nolint
	ConfigProfileID string

	// Fields represents a dusk-blockchain instance.
	Cfg config.Registry
	Gql *graphql.Client

	GRPCClient *client.NodeClient

	// Dusk-blockchain node directory.
	Dir string
}

DuskNode is the struct representing a node instance in the local Network.

func NewDuskNode

func NewDuskNode(graphqlPort, nodeID int, profileID string, requireSession bool) *DuskNode

NewDuskNode instantiates a new DuskNode.

type GrpcClient added in v0.4.0

type GrpcClient interface {
	// GetSessionConn returns a connection to the grpc server.
	GetSessionConn(options ...grpc.DialOption) (*grpc.ClientConn, error)
	// GracefulClose closes the connection.
	GracefulClose(options ...grpc.DialOption)
}

GrpcClient is an interface that abstracts the way to connect to the grpc server (i.e. with or without a session).

type Network

type Network struct {
	NetworkType byte
	Reuse       bool
	// contains filtered or unexported fields
}

Network describes the current network configuration in terms of nodes and processes.

func (*Network) AddGrpcClient added in v0.4.0

func (n *Network) AddGrpcClient(nodeID, network, addr string)

AddGrpcClient creates the right grpc client linked to the node through the Id of the latter.

func (*Network) AddNode added in v0.4.0

func (n *Network) AddNode(node *DuskNode)

AddNode to the network.

func (*Network) BatchSendTransferTx added in v0.4.3

func (n *Network) BatchSendTransferTx(t *testing.T, senderNodeInd uint, batchSize uint, amount, fee uint64, timeout time.Duration) error

BatchSendTransferTx sends a transfer call from node of index senderNodeInd to senderNodeInd+1 node.

func (*Network) Bootstrap

func (n *Network) Bootstrap(workspace string) error

Bootstrap performs all actions needed to initialize and start a local network. This network is alive by the end of all tests execution.

func (*Network) CalculateTPS added in v0.4.3

func (n *Network) CalculateTPS(ind uint) (uint64, float32, int64, int, error)

CalculateTPS makes an attempt to fetch last block height of a specified node.

func (*Network) GetBalance added in v0.4.0

func (n *Network) GetBalance(ind uint) (uint64, uint64, error)

GetBalance makes an attempt to get wallet balance of a specified node. Returns both UnlockedBalance and LockedBalance.

func (*Network) GetGrpcConn added in v0.4.0

func (n *Network) GetGrpcConn(i uint, opts ...grpc.DialOption) (*grpc.ClientConn, error)

GetGrpcConn gets a connection to the GRPC server of a node. It delegates eventual sessions to the underlying client.

func (*Network) GetLastBlockHeight added in v0.4.0

func (n *Network) GetLastBlockHeight(ind uint) (uint64, error)

GetLastBlockHeight makes an attempt to fetch last block height of a specified node.

func (*Network) GetWalletAddress added in v0.4.0

func (n *Network) GetWalletAddress(ind uint) (string, []byte, error)

GetWalletAddress makes an attempt to get wallet address of a specified node.

func (*Network) IsSessionRequired added in v0.4.0

func (n *Network) IsSessionRequired() bool

IsSessionRequired returns whether a session is required or otherwise.

func (*Network) IsSynced added in v0.4.0

func (n *Network) IsSynced(threshold uint64) (uint64, error)

IsSynced checks if each node blockchain tip is close to the blockchain tip of node 0. threshold param is the number of blocks the last block can differ.

func (*Network) MonitorTPS added in v0.4.3

func (n *Network) MonitorTPS(delay time.Duration)

MonitorTPS tries to measure network TPS each N seconds.

func (*Network) PrintWalletsInfo added in v0.4.0

func (n *Network) PrintWalletsInfo(t *testing.T)

PrintWalletsInfo prints wallet address and balance of all network nodes.

func (*Network) PublishTopic

func (n *Network) PublishTopic(nodeIndex uint, topic, payload string) error

nolint PublishTopic publishes an event bus topic to the specified node via rpc call.

func (*Network) SendBidCmd added in v0.3.0

func (n *Network) SendBidCmd(ind uint, amount, locktime uint64) ([]byte, error)

SendBidCmd sends gRPC command SendBid and returns tx hash.

func (*Network) SendQuery

func (n *Network) SendQuery(nodeIndex uint, query string, result interface{}) error

SendQuery sends a graphql query to the specified network node.

func (*Network) SendStakeCmd added in v0.4.0

func (n *Network) SendStakeCmd(ind uint, amount, locktime uint64) ([]byte, error)

SendStakeCmd sends gRPC command SendStake and returns tx hash.

func (*Network) SendTransferTxCmd added in v0.4.0

func (n *Network) SendTransferTxCmd(senderNodeInd, recvNodeInd uint, amount, fee uint64) ([]byte, error)

SendTransferTxCmd sends gRPC command SendTransfer and returns tx hash.

func (*Network) SendWireMsg

func (n *Network) SendWireMsg(ind uint, msg []byte, writeTimeout int) error

SendWireMsg sends a P2P message to the specified network node. Message should be in form of topic id + marshaled payload.

The utility sets up a valid inbound peer connection with a localnet node. After the handshake procedure, it writes the message to the Peer connection.

func (*Network) Size added in v0.4.0

func (n *Network) Size() int

Size of the network intended as nunber of nodes.

func (*Network) StartNode added in v0.3.0

func (n *Network) StartNode(i int, node *DuskNode, workspace string) error

StartNode locally. nolint

func (*Network) Teardown

func (n *Network) Teardown()

Teardown the network.

func (*Network) WaitUntil added in v0.3.0

func (n *Network) WaitUntil(t *testing.T, ind uint, targetHeight uint64, waitFor time.Duration, tick time.Duration)

WaitUntil blocks until the node at index ind reaches the target height.

func (*Network) WaitUntilTx added in v0.3.0

func (n *Network) WaitUntilTx(t *testing.T, ind uint, txID string) string

WaitUntilTx blocks until the node at index ind accepts the specified Tx Returns hash of the block that includes this tx.

type Profiles

type Profiles map[string]func(index int, node *DuskNode, walletPath string)

Profiles is a map with the node name as key and Profile function.

Jump to

Keyboard shortcuts

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