Documentation
¶
Index ¶
- Constants
- Variables
- func MustGenerateKey() *ecdsa.PrivateKey
- func MustHexToECDSA(hexkey string) *ecdsa.PrivateKey
- func NewSimulatedClient(sim *backends.SimulatedBackend) ethhelpers.Client
- func PendingLogHandler(h log.Handler) (log.Handler, func())
- func PendingLogHandlerForTesting(t *testing.T, logger log.Logger) func()
- func SimulatedChainID() *big.Int
- type BlockGenerator
- type CanceledMockCallOption
- type ClientWithMock
- type GenesisAccountWithPrivateKey
- type PassthroughMockCallOption
- type SimpleBlockGenerator
- type SimulatedAccount
- type SimulatedBackendWithAccounts
- type TransactionWithHeight
Constants ¶
const (
DefaultBlockGeneratorOffsetTime = int64(5)
)
Variables ¶
var ( MockPrivateKey1 = MustHexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") MockPrivateKey2 = MustHexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a") MockPrivateKey3 = MustHexToECDSA("49a7b37aa6f6645917e7b807e9d1c00d4fa71f18343b0d4122a4d2df64dd6fee") MockPrivateKey4 = MustHexToECDSA("e238eb8e04fee6511ab04c6dd3c89ce097b11f25d584863ac2b6d5b35b1847e4") )
Functions ¶
func MustGenerateKey ¶
func MustGenerateKey() *ecdsa.PrivateKey
func MustHexToECDSA ¶
func MustHexToECDSA(hexkey string) *ecdsa.PrivateKey
MustHexToECDSA returns the result of HexToECDSA on hexkey, or panics if error.
func NewSimulatedClient ¶
func NewSimulatedClient(sim *backends.SimulatedBackend) ethhelpers.Client
func PendingLogHandler ¶
PendingLogHandler returns a new log.Handler that buffers records until the returned commit function is called.
func SimulatedChainID ¶
Types ¶
type BlockGenerator ¶
type CanceledMockCallOption ¶ added in v0.1.3
type CanceledMockCallOption struct{}
func CanceledMockCall ¶ added in v0.1.3
func CanceledMockCall() CanceledMockCallOption
type ClientWithMock ¶ added in v0.1.2
func NewClientWithMock ¶ added in v0.1.2
func NewClientWithMock() ClientWithMock
Newethhelpers.Client creates a new client with *testing.Mock.
func NewClientWithMockAndClient ¶ added in v0.1.2
func NewClientWithMockAndClient(client ethhelpers.Client) ClientWithMock
NewClientWithMockAndClient creates a new client with *testing.Mock and an underlying client.
Using PassthroughMockCall() as the assigned return value for mocked calls will pass the call to the underlying client.
type GenesisAccountWithPrivateKey ¶
type GenesisAccountWithPrivateKey struct { *ecdsa.PrivateKey core.GenesisAccount }
type PassthroughMockCallOption ¶ added in v0.1.3
type PassthroughMockCallOption struct{}
func PassthroughMockCall ¶ added in v0.1.3
func PassthroughMockCall() PassthroughMockCallOption
type SimpleBlockGenerator ¶
type SimpleBlockGenerator struct { // Expected block height of the chain if it contains a non-zero // value, otherwise the last block with a transaction is // used. // // Results in an error if set to a non-zero value that is less // than the last block number with a transaction. ExpectedHeight int // Offset time of the block in seconds. OffsetTime int64 // Generate a byte array for the extraData generator parameter field. ExtraGenerator func(int, *core.BlockGen) []byte Transactions []TransactionWithHeight }
type SimulatedAccount ¶
type SimulatedAccount struct { PrivateKey *ecdsa.PrivateKey Address common.Address Nonce uint64 }
func NewSimulatedAccount ¶
func NewSimulatedAccount(privateKey *ecdsa.PrivateKey) *SimulatedAccount
func NewSimulatedAccountWithNonce ¶
func NewSimulatedAccountWithNonce(privateKey *ecdsa.PrivateKey, nonce uint64) *SimulatedAccount
func (*SimulatedAccount) NonceAndIncrement ¶
func (a *SimulatedAccount) NonceAndIncrement() (n uint64)
NextNonce increments SimulatedAccount.Nonce and returns its old value.
func (*SimulatedAccount) SendNewTransaction ¶
func (a *SimulatedAccount) SendNewTransaction(ctx context.Context, client ethhelpers.ChainReaderAndTransactionSender, nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, data []byte) (*types.Transaction, error)
type SimulatedBackendWithAccounts ¶
type SimulatedBackendWithAccounts struct { Backend *backends.SimulatedBackend Accounts []*SimulatedAccount }
func NewSimulatedBackendWithAccounts ¶
func NewSimulatedBackendWithAccounts(genesisAccounts ...GenesisAccountWithPrivateKey) *SimulatedBackendWithAccounts
NewSimulatedBackendWithAccounts creates a new simulated backend with provided simulated accounts.
If GenesisAccount.Balance is nil then big.NewInt(0) is used.
func (*SimulatedBackendWithAccounts) GenerateCallableContract ¶
func (b *SimulatedBackendWithAccounts) GenerateCallableContract() (*bind.BoundContract, error)
GenerateCallableContract creates a callable contract on the simulated backend.
The transaction must be commited by the caller.
pragma solidity >=0.7.0 <0.9.0; contract Callable { event Called(); function Call() public { emit Called(); } }
type TransactionWithHeight ¶
type TransactionWithHeight struct { Height int Transaction *types.Transaction }