Documentation ¶
Index ¶
- Constants
- Variables
- func CompareBlocks(one, two []*core.Block) bool
- func CompareLogs(one, two []*core.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() *core.Block
- func (m *MockBlock) Extra(data string) *MockBlock
- func (m *MockBlock) GetLogs() (logs []*core.Log)
- func (m *MockBlock) GetNum() int
- func (m *MockBlock) Hash() core.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 []*core.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 []*core.Log)
- func (d *MockClient) GetBlockByHash(hash core.Hash, full bool) (*core.Block, error)
- func (d *MockClient) GetBlockByNumber(i core.BlockNumber, full bool) (*core.Block, error)
- func (d *MockClient) GetLastBlocks(n uint64) (res []*core.Block)
- func (d *MockClient) GetLogs(filter *core.LogFilter) ([]*core.Log, error)
- func (m *MockClient) SetChainID(id *big.Int)
- type MockList
- type MockLog
- type Server
- func (t *Server) Account(i int) core.Address
- func (t *Server) Call(msg *core.CallMsg) (string, error)
- func (t *Server) DeployContract(c *Contract) (*compiler.Artifact, core.Address, error)
- func (t *Server) Fund(address core.Address) (*core.Receipt, error)
- func (t *Server) HTTPAddr() string
- func (t *Server) HttpClient() *ethClient
- func (t *Server) IPCPath() string
- func (t *Server) ProcessBlock() error
- func (t *Server) ProcessBlockRaw() error
- func (t *Server) ProcessBlockWithReceipt() (*core.Receipt, error)
- func (t *Server) ProcessRawTxWithReceipt() (*core.Receipt, error)
- func (t *Server) SendRawTxn(fromKey string, txn *core.Transaction) (*core.Receipt, error)
- func (t *Server) Transfer(address core.Address, value *big.Int) (*core.Receipt, error)
- func (t *Server) TxnTo(address core.Address, method string) (*core.Receipt, error)
- func (t *Server) WSAddr() string
- func (t *Server) WaitForReceipt(hash core.Hash) (*core.Receipt, error)
- func (t *Server) WsClient() *ethClient
- type ServerConfig
- type ServerConfigCallback
- type TestServer
- func (t *TestServer) Account(i int) core.Address
- func (t *TestServer) Call(msg *core.CallMsg) (string, error)
- func (t *TestServer) DeployContract(c *Contract) (*compiler.Artifact, core.Address, error)
- func (t *TestServer) Fund(address core.Address) (*core.Receipt, error)
- func (t *TestServer) HTTPAddr() string
- func (t *TestServer) IPCPath() string
- func (t *TestServer) ProcessBlock() error
- func (t *TestServer) ProcessBlockRaw() error
- func (t *TestServer) ProcessBlockWithReceipt() (*core.Receipt, error)
- func (t *TestServer) ProcessRawTxWithReceipt() (*core.Receipt, error)
- func (t *TestServer) SendRawTxn(txn *core.Transaction) (*core.Receipt, error)
- func (t *TestServer) SendTxn(txn *core.Transaction) (*core.Receipt, error)
- func (t *TestServer) Transfer(address core.Address, value *big.Int) (*core.Receipt, error)
- func (t *TestServer) TxnTo(address core.Address, method string) (*core.Receipt, error)
- func (t *TestServer) WSAddr() string
- func (t *TestServer) WaitForReceipt(hash core.Hash) (*core.Receipt, error)
- type TestServerConfig
Constants ¶
const ( FromKey string = "0a9b29e781f64c48a38a46d7a29b78f3c3a3b380e573cb50e2e917d5e7c3be3a" FromAddr string = "0x3A92a507acD85dcBE848680eD9D2340DB70be2d0" ToAddr string = "0xdb04bd70d2D834D6845D515278E4De1F1Cba4572" Value int64 = 1e18 )
Variables ¶
var ( DefaultGasPrice = uint64(1879048192) // 0x70000000 DefaultGasLimit = uint64(5242880) // 0x500000 )
var (
DummyAddr = core.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 []*core.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 []*core.Log)
func (*MockClient) GetBlockByHash ¶
func (*MockClient) GetBlockByNumber ¶
func (d *MockClient) GetBlockByNumber(i core.BlockNumber, full bool) (*core.Block, error)
func (*MockClient) GetLastBlocks ¶
func (d *MockClient) GetLastBlocks(n uint64) (res []*core.Block)
func (*MockClient) SetChainID ¶
func (m *MockClient) SetChainID(id *big.Int)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a Geth test server
func NewTestingServer ¶
NewTestingServer just for testing
func (*Server) DeployContract ¶
DeployContract deploys a contract with account 0 and returns the address TODO Finish it
func (*Server) HttpClient ¶
func (t *Server) HttpClient() *ethClient
func (*Server) ProcessBlock ¶
func (*Server) ProcessBlockRaw ¶
func (*Server) ProcessBlockWithReceipt ¶
ProcessBlockWithReceipt ProcessBlock processes a new block TODO Finish it
func (*Server) ProcessRawTxWithReceipt ¶
ProcessRawTxWithReceipt ProcessBlock processes a new block via sendrawTransaction
func (*Server) SendRawTxn ¶
func (*Server) TxnTo ¶
TxnTo sends a transaction to a given method without any arguments TODO Finish it
func (*Server) WaitForReceipt ¶
WaitForReceipt waits for the receipt
type ServerConfig ¶
type ServerConfig struct {
Period int
}
ServerConfig is the configuration of the server
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 NewTestServer ¶
func NewTestServer(t *testing.T, addrs ...string) *TestServer
func (*TestServer) Account ¶
func (t *TestServer) Account(i int) core.Address
Account returns a specific account
func (*TestServer) Call ¶
func (t *TestServer) Call(msg *core.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() (*core.Receipt, error)
ProcessBlockWithReceipt ProcessBlock processes a new block
func (*TestServer) ProcessRawTxWithReceipt ¶
func (t *TestServer) ProcessRawTxWithReceipt() (*core.Receipt, error)
ProcessRawTxWithReceipt ProcessBlock processes a new block via sendrawTransaction
func (*TestServer) SendRawTxn ¶
func (t *TestServer) SendRawTxn(txn *core.Transaction) (*core.Receipt, error)
func (*TestServer) SendTxn ¶
func (t *TestServer) SendTxn(txn *core.Transaction) (*core.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