ethtest

package
v0.0.0-...-0aae19c Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockBodies

type BlockBodies []*types.Body

BlockBodies is the network packet for block content distribution.

func (BlockBodies) Code

func (bb BlockBodies) Code() int

type BlockHeaders

type BlockHeaders []*types.Header

func (BlockHeaders) Code

func (bh BlockHeaders) Code() int

type Chain

type Chain struct {
	// contains filtered or unexported fields
}

func (*Chain) ForkID

func (c *Chain) ForkID() forkid.ID

ForkID gets the fork id of the chain.

func (*Chain) GetHeaders

func (c *Chain) GetHeaders(req GetBlockHeaders) (BlockHeaders, error)

func (*Chain) Head

func (c *Chain) Head() *types.Block

Head returns the chain head.

func (*Chain) Len

func (c *Chain) Len() int

Len returns the length of the chain.

func (*Chain) Shorten

func (c *Chain) Shorten(height int) *Chain

Shorten returns a copy chain of a desired height from the imported

func (*Chain) TD

func (c *Chain) TD(height int) *big.Int

TD calculates the total difficulty of the chain.

func (*Chain) WriteTo

func (c *Chain) WriteTo(writer io.Writer) error

type Conn

type Conn struct {
	*rlpx.Conn
	// contains filtered or unexported fields
}

Conn represents an individual connection with a peer

func (*Conn) Read

func (c *Conn) Read() Message

func (*Conn) ReadAndServe

func (c *Conn) ReadAndServe(chain *Chain, timeout time.Duration) Message

ReadAndServe serves GetBlockHeaders requests while waiting on another message from the node.

func (*Conn) Write

func (c *Conn) Write(msg Message) error

type Disconnect

type Disconnect struct {
	Reason p2p.DiscReason
}

Disconnect is the RLP structure for a disconnect message.

func (Disconnect) Code

func (d Disconnect) Code() int

type Error

type Error struct {
	// contains filtered or unexported fields
}

func (*Error) Code

func (e *Error) Code() int

func (*Error) Error

func (e *Error) Error() string

func (*Error) String

func (e *Error) String() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type GetBlockBodies

type GetBlockBodies []common.Hash

GetBlockBodies represents a GetBlockBodies request

func (GetBlockBodies) Code

func (gbb GetBlockBodies) Code() int

type GetBlockHeaders

type GetBlockHeaders struct {
	Origin  hashOrNumber // Block from which to retrieve headers
	Amount  uint64       // Maximum number of headers to retrieve
	Skip    uint64       // Blocks to skip between consecutive headers
	Reverse bool         // Query direction (false = rising towards latest, true = falling towards genesis)
}

GetBlockHeaders represents a block header query.

func (GetBlockHeaders) Code

func (g GetBlockHeaders) Code() int

type Hello

type Hello struct {
	Version    uint64
	Name       string
	Caps       []p2p.Cap
	ListenPort uint64
	ID         []byte // secp256k1 public key

	// Ignore additional fields (for forward compatibility).
	Rest []rlp.RawValue `rlp:"tail"`
}

Hello is the RLP structure of the protocol handshake.

func (Hello) Code

func (h Hello) Code() int

type Message

type Message interface {
	Code() int
}

type NewBlock

type NewBlock struct {
	Block *types.Block
	TD    *big.Int
}

NewBlock is the network packet for the block propagation message.

func (NewBlock) Code

func (nb NewBlock) Code() int

type NewBlockHashes

type NewBlockHashes []struct {
	Hash   common.Hash // Hash of one particular block being announced
	Number uint64      // Number of one particular block being announced
}

NewBlockHashes is the network packet for the block announcements.

func (NewBlockHashes) Code

func (nbh NewBlockHashes) Code() int

type NewPooledTransactionHashes

type NewPooledTransactionHashes [][32]byte

NewPooledTransactionHashes is the network packet for the tx hash propagation message.

func (NewPooledTransactionHashes) Code

func (nb NewPooledTransactionHashes) Code() int

type Ping

type Ping struct{}

func (Ping) Code

func (p Ping) Code() int

type Pong

type Pong struct{}

func (Pong) Code

func (p Pong) Code() int

type Status

type Status struct {
	ProtocolVersion uint32
	NetworkID       uint64
	TD              *big.Int
	Head            common.Hash
	Genesis         common.Hash
	ForkID          forkid.ID
}

Status is the network packet for the status message for eth/64 and later.

func (Status) Code

func (s Status) Code() int

type Suite

type Suite struct {
	Dest *enode.Node
	// contains filtered or unexported fields
}

Suite represents a structure used to test the eth protocol of a node(s).

func NewSuite

func NewSuite(dest *enode.Node, chainfile string, genesisfile string) *Suite

NewSuite creates and returns a new eth-test suite that can be used to test the given node against the given blockchain data.

func (*Suite) AllTests

func (s *Suite) AllTests() []utesting.Test

func (*Suite) TestBroadcast

func (s *Suite) TestBroadcast(t *utesting.T)

TestBroadcast tests whether a block announcement is correctly propagated to the given node's peer(s).

func (*Suite) TestGetBlockBodies

func (s *Suite) TestGetBlockBodies(t *utesting.T)

TestGetBlockBodies tests whether the given node can respond to a `GetBlockBodies` request and that the response is accurate.

func (*Suite) TestGetBlockHeaders

func (s *Suite) TestGetBlockHeaders(t *utesting.T)

TestGetBlockHeaders tests whether the given node can respond to a `GetBlockHeaders` request and that the response is accurate.

func (*Suite) TestLargeAnnounce

func (s *Suite) TestLargeAnnounce(t *utesting.T)

TestLargeAnnounce tests the announcement mechanism with a large block.

func (*Suite) TestMaliciousHandshake

func (s *Suite) TestMaliciousHandshake(t *utesting.T)

TestMaliciousHandshake tries to send malicious data during the handshake.

func (*Suite) TestMaliciousStatus

func (s *Suite) TestMaliciousStatus(t *utesting.T)

TestMaliciousStatus sends a status package with a large total difficulty.

func (*Suite) TestMaliciousTx

func (s *Suite) TestMaliciousTx(t *utesting.T)

func (*Suite) TestStatus

func (s *Suite) TestStatus(t *utesting.T)

TestStatus attempts to connect to the given node and exchange a status message with it, and then check to make sure the chain head is correct.

func (*Suite) TestTransaction

func (s *Suite) TestTransaction(t *utesting.T)

type Transactions

type Transactions []*types.Transaction

func (Transactions) Code

func (t Transactions) Code() int

Jump to

Keyboard shortcuts

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