Documentation ¶
Overview ¶
Package firehosetest provides test doubles for the StreamingFast Firehose service, coupled to EVM code running on a simulated blockchain.
See the tests of the github.com/proofxyz firehose package for example usage.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Arg ¶
Arg acts similarly to ethpb.NewArgument(), but allows for concrete types that can be unambiguously mapped to ethpb.Value_Payload types. If unmabiguous mapping isn't possible, tb.Fatal() will be called.
func CmpOpts ¶
CmpOpts returns options for performing diffs between Hydrant.BlockResponse test results and expected values.
func CollectAll ¶
func CollectAll(tb testing.TB, client HydrantClient) []*svcpb.BlockResponse
CollectAll calls client.Recv() until an error occurs. If the error is io.EOF then all received BlockResponses are returned, otherwise the error is reported on tb.Fatal. io.EOF is the standard end-of-stream indicator for gRPC stream methods, so indicates a clean close.
Types ¶
type Config ¶
type Config struct { // UseETHServer instructs NewFake to call firehose.ETHServer() instead of // firehose.ETHClient(). This typically makes no difference, but SHOULD // ideally match whichever is to be used in production in case there are // edge-case differences. If true, the returned server will be connected to // with the grpctest package. UseETHServer bool }
A Config configures new Fakes.
type Fake ¶
type Fake struct { Client svcpb.HydrantServiceClient RawClient hosepb.StreamClient // contains filtered or unexported fields }
A Fake couples a bind.ContractBackend() running a real EVM implementation, with a fake Firehose Stream server. Solidity bindings generated by abigen can be used to trigger real EVM events that are propagated to the Firehose fake.
The Firehose fake can be accessed directly with the RawClient, or abstracted with ETH-specific "Hydrant" APIs via the Client. Filtering other than Start- and StopBlockNum is not currently supported by the Firehose fake so all transactions, in all blocks, are propagated. This MUST NOT be depended upon, and is open to breaking changes as the fake's behaviour approaches the real Firehose.
func (*Fake) Backend ¶
func (f *Fake) Backend() bind.ContractBackend
Backend returns the ContractBackend running the Fake's EVM.
func (*Fake) MineBlock ¶
MineBlock "mines" all transactions sent to f.Backend(). This moves the transactions out of the pending state, and queues the block for being returned by the Fake's Firehose/Hydrant clients.
This is NOT thread-safe so all blocks MUST be mined before calls to either of the gRPC clients.
func (*Fake) RPCClient ¶
RPCClient returns an ethclient.Client connected to the Fake's underlying EVM backend.
func (*Fake) TxOpts ¶
func (f *Fake) TxOpts() *bind.TransactOpts
TxOpts returns TransactOpts for sending transactions to f.Backend().
type HydrantClient ¶
type HydrantClient interface {
Recv() (*svcpb.BlockResponse, error)
}
A HydrantClient can receive BlockResponse protos. It is implemented by both of the HydrantService_{EventsClient,ERC721TransferEventsClient} types.