Documentation
¶
Overview ¶
Package testutil provides test data factories for explorer tests. Go test data factory for explorer tests.
Index ¶
- Constants
- func EnvironmentDBPath() string
- func RandomAddress() []byte
- func RandomHash() []byte
- func RandomHexAddress() string
- func RandomHexHash() string
- type Address
- type Block
- type DB
- func (db *DB) InsertAddress(t *testing.T, a Address) Address
- func (db *DB) InsertBlock(t *testing.T, b Block) Block
- func (db *DB) InsertInternalTx(t *testing.T, itx InternalTx) InternalTx
- func (db *DB) InsertLog(t *testing.T, l Log) Log
- func (db *DB) InsertSmartContract(t *testing.T, sc SmartContract) SmartContract
- func (db *DB) InsertToken(t *testing.T, tk Token) Token
- func (db *DB) InsertTokenBalance(t *testing.T, tb TokenBalance) TokenBalance
- func (db *DB) InsertTokenTransfer(t *testing.T, tt TokenTransfer) TokenTransfer
- func (db *DB) InsertTransaction(t *testing.T, tx Transaction) Transaction
- func (db *DB) SeedChainData(t *testing.T, numBlocks int) ([]Block, []Transaction, []Address)
- type InternalTx
- type Log
- type SmartContract
- type Token
- type TokenBalance
- type TokenTransfer
- type Transaction
Constants ¶
const DefaultChainID int64 = 96369
Variables ¶
This section is empty.
Functions ¶
func EnvironmentDBPath ¶
func EnvironmentDBPath() string
EnvironmentDBPath returns EXPLORER_TEST_DB if set (for integration with a real indexer DB).
func RandomAddress ¶
func RandomAddress() []byte
func RandomHash ¶
func RandomHash() []byte
func RandomHexAddress ¶
func RandomHexAddress() string
func RandomHexHash ¶
func RandomHexHash() string
Types ¶
type Address ¶
type Address struct {
ChainID int64
Hash []byte
FetchedCoinBalance string
FetchedBalanceBlock int64
ContractCode []byte
TransactionsCount int
TokenTransfersCount int
GasUsed string
Nonce int64
Verified bool
}
Address mirrors the indexer's address row.
func DefaultAddress ¶
func DefaultAddress() Address
func DefaultContractAddress ¶
func DefaultContractAddress() Address
type Block ¶
type Block struct {
ChainID int64
Number int64
Hash []byte
ParentHash []byte
Nonce []byte
Miner []byte
Difficulty string
TotalDifficulty string
Size int
GasLimit int64
GasUsed int64
BaseFee string
Timestamp int64
TransactionCount int
ConsensusState string
}
Block mirrors the indexer's block row.
func DefaultBlock ¶
func DefaultBlock() Block
type DB ¶
DB wraps a test SQLite database with the indexer schema.
func (*DB) InsertInternalTx ¶
func (db *DB) InsertInternalTx(t *testing.T, itx InternalTx) InternalTx
func (*DB) InsertSmartContract ¶
func (db *DB) InsertSmartContract(t *testing.T, sc SmartContract) SmartContract
func (*DB) InsertTokenBalance ¶
func (db *DB) InsertTokenBalance(t *testing.T, tb TokenBalance) TokenBalance
func (*DB) InsertTokenTransfer ¶
func (db *DB) InsertTokenTransfer(t *testing.T, tt TokenTransfer) TokenTransfer
func (*DB) InsertTransaction ¶
func (db *DB) InsertTransaction(t *testing.T, tx Transaction) Transaction
func (*DB) SeedChainData ¶
SeedChainData inserts a realistic set of chain data for testing. Returns the blocks, transactions, and addresses created.
type InternalTx ¶
type InternalTx struct {
ChainID int64
TransactionHash []byte
BlockNumber int64
BlockHash []byte
Index int
TraceAddress string
Type string
CallType string
FromAddress []byte
ToAddress []byte
Value string
Gas int64
GasUsed int64
Input []byte
Output []byte
Error string
BlockTimestamp int64
}
InternalTransaction mirrors the indexer's internal_transaction row.
func DefaultInternalTx ¶
func DefaultInternalTx(tx Transaction) InternalTx
type Log ¶
type Log struct {
ChainID int64
BlockNumber int64
BlockHash []byte
TransactionHash []byte
TransactionIndex int
Index int
Address []byte
Data []byte
FirstTopic []byte
SecondTopic []byte
ThirdTopic []byte
FourthTopic []byte
BlockTimestamp int64
}
Log mirrors the indexer's log row.
func DefaultLog ¶
func DefaultLog(tx Transaction) Log
type SmartContract ¶
type SmartContract struct {
ChainID int64
AddressHash []byte
Name string
CompilerVersion string
Optimization bool
OptRuns int
SourceCode string
ABI string
EVMVersion string
VerifiedVia string
IsVyper bool
LicenseType string
}
SmartContract mirrors the indexer's smart_contract row.
func DefaultSmartContract ¶
func DefaultSmartContract() SmartContract
type Token ¶
type Token struct {
ChainID int64
ContractAddress []byte
Name string
Symbol string
TotalSupply string
Decimals int
Type string
HolderCount int
IconURL string
}
Token mirrors the indexer's token row.
func DefaultERC721Token ¶
func DefaultERC721Token() Token
func DefaultToken ¶
func DefaultToken() Token
type TokenBalance ¶
type TokenBalance struct {
ChainID int64
AddressHash []byte
TokenContractAddress []byte
Value string
BlockNumber int64
TokenType string
}
TokenBalance mirrors a row in address_current_token_balances.
type TokenTransfer ¶
type TokenTransfer struct {
ChainID int64
TransactionHash []byte
LogIndex int
BlockNumber int64
BlockHash []byte
FromAddress []byte
ToAddress []byte
TokenContractAddress []byte
Amount string
TokenID string
TokenType string
BlockTimestamp int64
}
TokenTransfer mirrors the indexer's token_transfer row.
func DefaultTokenTransfer ¶
func DefaultTokenTransfer(tx Transaction, token Token) TokenTransfer
type Transaction ¶
type Transaction struct {
ChainID int64
Hash []byte
BlockNumber int64
BlockHash []byte
TransactionIndex int
FromAddress []byte
ToAddress []byte
Value string
Gas int64
GasPrice string
GasUsed int64
MaxFeePerGas string
MaxPriorityFeePerGas string
Input []byte
Nonce int64
Type int
Status *int // nil = pending
Error string
RevertReason string
CreatedContract []byte
CumulativeGasUsed int64
BlockTimestamp int64
}
Transaction mirrors the indexer's transaction row.
func DefaultContractCreation ¶
func DefaultContractCreation(block Block) Transaction
func DefaultEIP1559Transaction ¶
func DefaultEIP1559Transaction(block Block) Transaction
func DefaultFailedTransaction ¶
func DefaultFailedTransaction(block Block) Transaction
func DefaultPendingTransaction ¶
func DefaultPendingTransaction(block Block) Transaction
func DefaultTransaction ¶
func DefaultTransaction(block Block) Transaction