I am using backends.SimulatedBackend in unit testing.
however, backends.SimulatedBackend
is not compatible with ethclient.Client.
Any one can advise how to create a ethclient.Client
in unit testing? Thank you
I am using backends.SimulatedBackend in unit testing.
however, backends.SimulatedBackend
is not compatible with ethclient.Client.
Any one can advise how to create a ethclient.Client
in unit testing? Thank you
check this out..
Use backends.SimulatedBackend and ethclient.Client synonymously
Probably the following package helps with what you try to achieve...
https://github.com/bonedaddy/go-defi/blob/main/utils/blockchain.go
At line 12 at the comments it says:
// Blockchain is a generalized interface for interacting with the ethereum blockchain
// it satisfies all functions required by the ethclient, and simulated backend types.
// This allows you to use ethclient and the simulated backend interchangeably which is
// particularly useful for testing
You could try to use exactly this "Blockchain" interface or treat the backends.SimulatedBackend
and the ethclient.Client
sperately (as it should be).