rpctest

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package rpctest provides utilities for testing RPC methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server is a fake RPC endpoint that responds only to a single requests that is definded in a golden-file.

Request golden-files have the following format to define a single request and the corresponding response:s

// Comments and empty lines will be ignored.
// Request starts with ">".
> [{"jsonrpc":"2.0","id":1,"method":"eth_chainId"}]
// Response starts with "<".
< [{"jsonrpc":"2.0","id":1,"result":"0x1"}]

func NewFileServer

func NewFileServer(t *testing.T, filename string) *Server

NewFileServer returns a new instance of Server that serves the golden-file from the given filename.

func NewServer

func NewServer(t *testing.T, r io.Reader) *Server

NewServer returns a new instance of Server that serves the golden-file from Reader r.

func (*Server) Close

func (srv *Server) Close()

Close shuts down the server.

func (*Server) ServeHTTP

func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) URL

func (srv *Server) URL() string

URL returns the servers RPC endpoint url.

Jump to

Keyboard shortcuts

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