Skip to content

Latest commit

 

History

History

ethergo

Ethergo

Go Reference Go Report Card

Overview

Ethergo is a comprehensive embedded test suite for Synapse, built using the Go programming language. It provides the functionality to deploy contracts to various backends, streamlining the testing process for different types of blockchain networks. The module is organized into several subdirectories, each dedicated to specific aspects of the testing process, such as backends, chain interaction, contract management, and signing utilities.

Some key components of Ethergo include:

  • Backends: Ethergo supports different test backends for testing against various types of chains, including Anvil, Ganache, Geth, Preset, and Simulated backends.
  • Chain: This subdirectory provides tools for chain interaction, such as a chain client, a chain watcher, a deterministic gas estimator, and a client interface for the chain watcher.
  • Contracts: This section contains interfaces for working with contracts, including deployer and manager functionalities.
  • Manager: The manager is responsible for handling contract deployments.
  • Signer: Ethergo offers signing and transaction submission utilities, with various adapters for signing transactions and handling race conditions with nonces. It also includes a wallet interface capable of importing keys from seed phrases, private keys, and mnemonics.

To see a working example of Ethergo in action, refer to the example folder, which provides a complete demonstration of how to use the deployer and manager components. Please note that the APIs are subject to change.

Directory Structure

root
├── backends: Contains different test backends for testing against different types of chains
│   ├── anvil: Contains the anvil backend. This is useful for fork testing and requires docker. It aloso contains cheatcodes for testing detailed [here](https://book.getfoundry.sh/anvil/)
│   ├── ganache: Contains the ganache backend. This is useful for fork testing and requires docker. This is currently using an older version of ganache, but will be updated to use the latest version. See [here](https://github.com/trufflesuite/ganache) for details.
│   ├── geth: Contains an embedded geth backend. This is useful for testing against a local geth instance without forking capabilities. This does not require docker and runs fully embedded in the go application, as such it is faster than the docker-based backends, but less versatile. Used when an rpc address is needed for a localnet.
│   ├── preset: Contains a number of preset backends for testing.
│   ├── simulated: The fastest backend, this does not expose an rpc endpoint and uses geth's [simulated backend](https://goethereumbook.org/en/client-simulated/)
├── chain: Contains a client for interacting with the chain. This will be removed in a future version. Please use [client](./client) going forward.
│   ├── chainwatcher: Watches the chain for events, blocks and logs
│   ├── client: Contains eth clients w/ rate limiting, workarounds for bugs in some chains, etc.
│   ├── gas: Contains a deterministic gas estimator
│   ├── watcher: Client interface for chain watcher.
├── contracts: Contains interfaces for using contracts with the deployer + manager
├── client: Contains an open tracing compatible ethclient with batching.
├── examples: Contains a full featured example of how to use deployer + manager & a signer.
├── forker: Allows the use of fork tests in live chains without docker using an anvil binary.
├── listener: Drop-in contract listener
├── manager: Manages contract deployments.
├── mocks: Contains mocks for testing various data types (transactions, addresses, logs, etc)
├── parser: Parse hardhat deployments
│   ├── hardhat: Parses hardhat deployments
│   ├── abi: Parses abi function input
│   ├── rpc: Parses rpc requests/responses
├── signer: Signing + tx submission utilities
│   ├── nonce: Automatically handles race conditions with nonces, used in backends.
│   ├── signer: Various adapters for signing transactions
│     ├── awssigner: Use AWS KMS to sign transactions
│     ├── gcpsigner: Use GCP Cloud KMS to sign transactions
│     ├── localsigner: Use a local signer to sign transactions
│   ├── wallet: Wallet contains a wallet interface. It is capable of importing keys from seed phrases, private keys, and mnemonics.
├── submitter: Generic tx submitter, currently not stable enough for general use.
├── util: various utilities used throughout the library