Documentation ¶
Index ¶
- Variables
- func CompareBlocks(one, two []*ethgo.Block) bool
- func CompareLogs(one, two []*ethgo.Log) bool
- func MethodSig(name string) []byte
- func MultiAddr(t *testing.T, c func(s *TestServer, addr string))
- func TestInfuraEndpoint(t *testing.T) string
- type Contract
- func (c *Contract) AddCallback(f func() string)
- func (c *Contract) AddConstructor(args ...string)
- func (c *Contract) AddDualCaller(funcName string, args ...string)
- func (c *Contract) AddEvent(e *Event)
- func (c *Contract) AddOutputCaller(funcName string)
- func (c *Contract) Compile() (*compiler.Artifact, error)
- func (c *Contract) EmitEvent(funcName string, name string, args ...string)
- func (c *Contract) GetEvent(name string) *Event
- func (c *Contract) Print() string
- type Event
- type MockBlock
- func (m *MockBlock) Block() *ethgo.Block
- func (m *MockBlock) Extra(data string) *MockBlock
- func (m *MockBlock) GetLogs() (logs []*ethgo.Log)
- func (m *MockBlock) GetNum() int
- func (m *MockBlock) Hash() ethgo.Hash
- func (m *MockBlock) Log(data string) *MockBlock
- func (m *MockBlock) Num(i int) *MockBlock
- func (m *MockBlock) Parent(i int) *MockBlock
- type MockClient
- func (d *MockClient) AddLogs(logs []*ethgo.Log)
- func (d *MockClient) AddScenario(m MockList)
- func (d *MockClient) BlockNumber() (uint64, error)
- func (d *MockClient) ChainID() (*big.Int, error)
- func (d *MockClient) GetAllLogs() (res []*ethgo.Log)
- func (d *MockClient) GetBlockByHash(hash ethgo.Hash, full bool) (*ethgo.Block, error)
- func (d *MockClient) GetBlockByNumber(i ethgo.BlockNumber, full bool) (*ethgo.Block, error)
- func (d *MockClient) GetLastBlocks(n uint64) (res []*ethgo.Block)
- func (d *MockClient) GetLogs(filter *ethgo.LogFilter) ([]*ethgo.Log, error)
- func (m *MockClient) SetChainID(id *big.Int)
- type MockList
- type MockLog
- type ServerConfigCallback
- type TestServer
- func (t *TestServer) Account(i int) ethgo.Address
- func (t *TestServer) Call(msg *ethgo.CallMsg) (string, error)
- func (t *TestServer) DeployContract(c *Contract) (*compiler.Artifact, ethgo.Address, error)
- func (t *TestServer) Fund(address ethgo.Address) (*ethgo.Receipt, error)
- func (t *TestServer) HTTPAddr() string
- func (t *TestServer) IPCPath() string
- func (t *TestServer) ProcessBlock() error
- func (t *TestServer) ProcessBlockWithReceipt() (*ethgo.Receipt, error)
- func (t *TestServer) SendTxn(txn *ethgo.Transaction) (*ethgo.Receipt, error)
- func (t *TestServer) Transfer(address ethgo.Address, value *big.Int) (*ethgo.Receipt, error)
- func (t *TestServer) TxnTo(address ethgo.Address, method string) (*ethgo.Receipt, error)
- func (t *TestServer) WSAddr() string
- func (t *TestServer) WaitForReceipt(hash ethgo.Hash) (*ethgo.Receipt, error)
- type TestServerConfig
Constants ¶
This section is empty.
Variables ¶
var ( DefaultGasPrice = uint64(1879048192) // 0x70000000 DefaultGasLimit = uint64(5242880) // 0x500000 )
var (
DummyAddr = ethgo.HexToAddress("0x015f68893a39b3ba0681584387670ff8b00f4db2")
)
Functions ¶
func CompareBlocks ¶
func CompareLogs ¶
func MultiAddr ¶
func MultiAddr(t *testing.T, c func(s *TestServer, addr string))
MultiAddr creates new servers to test different addresses
func TestInfuraEndpoint ¶
TestInfuraEndpoint returns the testing infura endpoint to make testing requests
Types ¶
type Contract ¶
type Contract struct {
// contains filtered or unexported fields
}
Contract is a test contract
func (*Contract) AddCallback ¶
func (*Contract) AddConstructor ¶
AddConstructor creates a constructor with args that set contract variables
func (*Contract) AddDualCaller ¶
AddDualCaller adds a call function that returns the same values that takes
func (*Contract) AddOutputCaller ¶
AddOutputCaller adsd a view function that does not take any input
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event is a test event
type MockClient ¶
type MockClient struct {
// contains filtered or unexported fields
}
func (*MockClient) AddLogs ¶
func (d *MockClient) AddLogs(logs []*ethgo.Log)
func (*MockClient) AddScenario ¶
func (d *MockClient) AddScenario(m MockList)
func (*MockClient) BlockNumber ¶
func (d *MockClient) BlockNumber() (uint64, error)
func (*MockClient) GetAllLogs ¶
func (d *MockClient) GetAllLogs() (res []*ethgo.Log)
func (*MockClient) GetBlockByHash ¶
func (*MockClient) GetBlockByNumber ¶
func (d *MockClient) GetBlockByNumber(i ethgo.BlockNumber, full bool) (*ethgo.Block, error)
func (*MockClient) GetLastBlocks ¶
func (d *MockClient) GetLastBlocks(n uint64) (res []*ethgo.Block)
func (*MockClient) SetChainID ¶
func (m *MockClient) SetChainID(id *big.Int)
type ServerConfigCallback ¶
type ServerConfigCallback func(c *TestServerConfig)
ServerConfigCallback is the callback to modify the config
type TestServer ¶
type TestServer struct {
// contains filtered or unexported fields
}
TestServer is a Geth test server
func DeployTestServer ¶
func DeployTestServer(t *testing.T, cb ServerConfigCallback) *TestServer
DeployTestServer creates a new Geth test server
func NewTestServer ¶
func NewTestServer(t *testing.T, addrs ...string) *TestServer
func (*TestServer) Account ¶
func (t *TestServer) Account(i int) ethgo.Address
Account returns a specific account
func (*TestServer) Call ¶
func (t *TestServer) Call(msg *ethgo.CallMsg) (string, error)
Call sends a contract call
func (*TestServer) DeployContract ¶
DeployContract deploys a contract with account 0 and returns the address
func (*TestServer) HTTPAddr ¶
func (t *TestServer) HTTPAddr() string
HTTPAddr returns the http endpoint
func (*TestServer) ProcessBlock ¶
func (t *TestServer) ProcessBlock() error
func (*TestServer) ProcessBlockWithReceipt ¶
func (t *TestServer) ProcessBlockWithReceipt() (*ethgo.Receipt, error)
ProcessBlock processes a new block
func (*TestServer) SendTxn ¶
func (t *TestServer) SendTxn(txn *ethgo.Transaction) (*ethgo.Receipt, error)
SendTxn sends a transaction
func (*TestServer) WSAddr ¶
func (t *TestServer) WSAddr() string
WSAddr returns the websocket endpoint
func (*TestServer) WaitForReceipt ¶
WaitForReceipt waits for the receipt
type TestServerConfig ¶
type TestServerConfig struct {
Period int
}
TestServerConfig is the configuration of the server