testutils

package
v1.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// tss addresses
	TSSAddressEVMMainnet = "0x70e967acFcC17c3941E87562161406d41676FD83"
	TSSAddressBTCMainnet = "bc1qm24wp577nk8aacckv8np465z3dvmu7ry45el6y"
	TssPubkeyEVMMainnet  = "pellpub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc"

	TSSAddressEVMIgnite3 = "0x8531a5aB847ff5B22D855633C25ED1DA3255247e"
	TSSAddressBTCIgnite3 = "tb1qy9pqmk2pd9sv63g27jt8r657wy0d9ueeh0nqur"
	TssPubkeyEVMIgnite3  = "pellpub1addwnpepq28c57cvcs0a2htsem5zxr6qnlvq9mzhmm76z3jncsnzz32rclangr2g35p"

	// some other addresses
	OtherAddress1 = "0x21248Decd0B7EcB0F30186297766b8AB6496265b"
	OtherAddress2 = "0x33A351C90aF486AebC35042Bb0544123cAed26AB"
	OtherAddress3 = "0x86B77E4fBd07CFdCc486cAe4F2787fB5C5a62cd3"

	// evm event names for test data naming
	EventPellSent = "PellSent"
)
View Source
const (
	APIURLBlocks          = "https://mempool.space/api/v1/blocks"
	APIURLBlockTxs        = "https://mempool.space/api/block/%s/txs"
	APIURLBlocksTestnet   = "https://mempool.space/testnet/api/v1/blocks"
	APIURLBlockTxsTestnet = "https://mempool.space/testnet/api/block/%s/txs"
)
View Source
const (
	TestDataPathEVM          = "testdata/evm"
	TestDataPathBTC          = "testdata/btc"
	TestDataPathXmsg         = "testdata/xmsg"
	RestrictedEVMAddressTest = "0x8a81Ba8eCF2c418CAe624be726F505332DF119C6"
	RestrictedBtcAddressTest = "bcrt1qzp4gt6fc7zkds09kfzaf9ln9c5rvrzxmy6qmpp"
)

Variables

View Source
var ConnectorAddresses = map[int64]ethcommon.Address{

	1:  ethcommon.HexToAddress("0x000007Cf399229b2f5A4D043F20E90C9C98B7C6a"),
	56: ethcommon.HexToAddress("0x000063A6e758D9e2f438d430108377564cf4077D"),

	5:        ethcommon.HexToAddress("0x00005E3125aBA53C5652f9F0CE1a4Cf91D8B15eA"),
	97:       ethcommon.HexToAddress("0x0000ecb8cdd25a18F12DAA23f6422e07fBf8B9E1"),
	11155111: ethcommon.HexToAddress("0x3963341dad121c9CD33046089395D66eBF20Fb03"),

	1337: ethcommon.HexToAddress("0xD28D6A0b8189305551a0A8bd247a6ECa9CE781Ca"),
}

ConnectorManagerAddresses contains constants ERC20 connector addresses for testing

View Source
var DelegationManagerAddresses = map[int64]ethcommon.Address{

	1:  ethcommon.HexToAddress("0x0000030Ec64DF25301d8414eE5a29588C4B0dE10"),
	56: ethcommon.HexToAddress("0x00000fF8fA992424957F97688015814e707A0115"),

	5:        ethcommon.HexToAddress("0x000047f11C6E42293F433C82473532E869Ce4Ec5"),
	97:       ethcommon.HexToAddress("0x0000a7Db254145767262C6A81a7eE1650684258e"),
	11155111: ethcommon.HexToAddress("0x84725b70a239d3Faa7C6EF0C6C8E8b6c8e28338b"),
}

DelegationManagerAddresses contains constants ERC20 custody addresses for testing

View Source
var StrategyManagerAddresses = map[int64]ethcommon.Address{

	1:  ethcommon.HexToAddress("0x000007Cf399229b2f5A4D043F20E90C9C98B7C6a"),
	56: ethcommon.HexToAddress("0x000063A6e758D9e2f438d430108377564cf4077D"),

	5:        ethcommon.HexToAddress("0x00005E3125aBA53C5652f9F0CE1a4Cf91D8B15eA"),
	97:       ethcommon.HexToAddress("0x0000ecb8cdd25a18F12DAA23f6422e07fBf8B9E1"),
	11155111: ethcommon.HexToAddress("0x3963341dad121c9CD33046089395D66eBF20Fb03"),

	1337: ethcommon.HexToAddress("0xD28D6A0b8189305551a0A8bd247a6ECa9CE781Ca"),
}

StrategyManagerAddresses contains constants ERC20 connector addresses for testing

Functions

func ComplianceConfigTest

func ComplianceConfigTest() config.ComplianceConfig

func FileNameBTCIntx

func FileNameBTCIntx(chainID int64, intxHash string, donation bool) string

FileNameBTCIntx returns unified archive file name for inbound tx

func FileNameBTCMsgTx

func FileNameBTCMsgTx(chainID int64, txHash string) string

FileNameBTCMsgTx returns unified archive file name for btc MsgTx

func FileNameBTCOuttx

func FileNameBTCOuttx(chainID int64, nonce uint64) string

FileNameBTCOuttx returns unified archive file name for outbound tx

func FileNameBTCTxByType

func FileNameBTCTxByType(chainID int64, txType string, txHash string) string

FileNameBTCTxByType returns unified archive file name for tx by type txType: "P2TR", "P2WPKH", "P2WSH", "P2PKH", "P2SH

func FileNameEVMBlock

func FileNameEVMBlock(chainID int64, blockNumber uint64, trimmed bool) string

FileNameEVMBlock returns unified archive file name for block

func FileNameEVMIntx

func FileNameEVMIntx(chainID int64, intxHash string, coinType coin.CoinType, donation bool) string

FileNameEVMIntx returns unified archive file name for inbound tx

func FileNameEVMIntxReceipt

func FileNameEVMIntxReceipt(chainID int64, intxHash string, coinType coin.CoinType, donation bool) string

FileNameEVMIntxReceipt returns unified archive file name for inbound tx receipt

func FileNameEVMOuttx

func FileNameEVMOuttx(chainID int64, txHash string, coinType coin.CoinType) string

FileNameEVMOuttx returns unified archive file name for outbound tx

func FileNameEVMOuttxReceipt

func FileNameEVMOuttxReceipt(chainID int64, txHash string, coinType coin.CoinType, eventName string) string

FileNameEVMOuttxReceipt returns unified archive file name for outbound tx receipt

func FileNameXmsgByIntx

func FileNameXmsgByIntx(chainID int64, intxHash string, coinType coin.CoinType) string

FileNameXmsgByIntx returns unified archive xmsg file name by intx

func FileNameXmsgByNonce

func FileNameXmsgByNonce(chainID int64, nonce uint64) string

FileNameXmsgByNonce returns unified archive xmsg file name by nonce

func Get

func Get(ctx context.Context, path string, v interface{}) error

func LoadBTCIntxRawResult

func LoadBTCIntxRawResult(t *testing.T, dir string, chainID int64, txHash string, donation bool) *btcjson.TxRawResult

LoadBTCIntxRawResult loads archived Bitcoin intx raw result from file

func LoadBTCTxRawResultNXmsg

func LoadBTCTxRawResultNXmsg(t *testing.T, dir string, chainID int64, nonce uint64) (*btcjson.TxRawResult, *xmsgtypes.Xmsg)

LoadBTCTxRawResultNXmsg loads archived Bitcoin outtx raw result and corresponding xmsg

func LoadEVMBlock

func LoadEVMBlock(t *testing.T, dir string, chainID int64, blockNumber uint64, trimmed bool) *ethrpc.Block

LoadEVMBlock loads archived evm block from file

func LoadEVMIntx

func LoadEVMIntx(
	t *testing.T,
	dir string,
	chainID int64,
	intxHash string,
	coinType coin.CoinType) *ethrpc.Transaction

LoadEVMIntx loads archived intx from file

func LoadEVMIntxDonation

func LoadEVMIntxDonation(
	t *testing.T,
	dir string,
	chainID int64,
	intxHash string,
	coinType coin.CoinType) *ethrpc.Transaction

LoadEVMIntxDonation loads archived donation intx from file

func LoadEVMIntxNReceipt

func LoadEVMIntxNReceipt(
	t *testing.T,
	dir string,
	chainID int64,
	intxHash string,
	coinType coin.CoinType) (*ethrpc.Transaction, *ethtypes.Receipt)

LoadEVMIntxNReceipt loads archived intx and receipt from file

func LoadEVMIntxNReceiptDonation

func LoadEVMIntxNReceiptDonation(
	t *testing.T,
	dir string,
	chainID int64,
	intxHash string,
	coinType coin.CoinType) (*ethrpc.Transaction, *ethtypes.Receipt)

LoadEVMIntxNReceiptDonation loads archived donation intx and receipt from file

func LoadEVMIntxNReceiptNXmsg

func LoadEVMIntxNReceiptNXmsg(
	t *testing.T,
	dir string,
	chainID int64,
	intxHash string,
	coinType coin.CoinType) (*ethrpc.Transaction, *ethtypes.Receipt, *xmsgtypes.Xmsg)

LoadTxNReceiptNXmsg loads archived intx, receipt and corresponding xmsg from file

func LoadEVMIntxReceipt

func LoadEVMIntxReceipt(
	t *testing.T,
	dir string,
	chainID int64,
	intxHash string,
	coinType coin.CoinType) *ethtypes.Receipt

LoadEVMIntxReceipt loads archived intx receipt from file

func LoadEVMIntxReceiptDonation

func LoadEVMIntxReceiptDonation(
	t *testing.T,
	dir string,
	chainID int64,
	intxHash string,
	coinType coin.CoinType) *ethtypes.Receipt

LoadEVMIntxReceiptDonation loads archived donation intx receipt from file

func LoadEVMOuttx

func LoadEVMOuttx(
	t *testing.T,
	dir string,
	chainID int64,
	txHash string,
	coinType coin.CoinType) *ethtypes.Transaction

LoadEVMOuttx loads archived evm outtx from file

func LoadEVMOuttxNReceipt

func LoadEVMOuttxNReceipt(
	t *testing.T,
	dir string,
	chainID int64,
	txHash string,
	coinType coin.CoinType) (*ethtypes.Transaction, *ethtypes.Receipt)

LoadEVMOuttxNReceipt loads archived evm outtx and receipt from file

func LoadEVMOuttxReceipt

func LoadEVMOuttxReceipt(
	t *testing.T,
	dir string,
	chainID int64,
	txHash string,
	coinType coin.CoinType,
	eventName string) *ethtypes.Receipt

LoadEVMOuttxReceipt loads archived evm outtx receipt from file

func LoadEVMXmsgNOuttxNReceipt

func LoadEVMXmsgNOuttxNReceipt(
	t *testing.T,
	dir string,
	chainID int64,
	nonce uint64,
	eventName string) (*xmsgtypes.Xmsg, *ethtypes.Transaction, *ethtypes.Receipt)

LoadEVMOuttxNReceiptNEvent loads archived xmsg, outtx and receipt from file

func LoadObjectFromJSONFile

func LoadObjectFromJSONFile(t *testing.T, obj interface{}, filename string)

LoadObjectFromJSONFile loads an object from a file in JSON format

func LoadXmsgByIntx

func LoadXmsgByIntx(
	t *testing.T,
	chainID int64,
	coinType coin.CoinType,
	intxHash string,
) *xmsgtypes.Xmsg

LoadXmsgByIntx loads archived xmsg by intx

func LoadXmsgByNonce

func LoadXmsgByNonce(
	t *testing.T,
	chainID int64,
	nonce uint64,
) *xmsgtypes.Xmsg

LoadXmsgByNonce loads archived xmsg by nonce

func ParseReceiptERC20Deposited

func ParseReceiptERC20Deposited(receipt *ethtypes.Receipt, delegationManager *delegationmanager.DelegationManager) *delegationmanager.DelegationManagerStakerDelegated

ParseReceipt parses an Delegate event from a receipt

func ParseReceiptStakerDeposited

func ParseReceiptStakerDeposited(receipt *ethtypes.Receipt, strategyManager *strategymanager.StrategyManager) *strategymanager.StrategyManagerDeposit

ParseReceipt parses a Deposit event from a receipt

func SaveBTCBlockTrimTx

func SaveBTCBlockTrimTx(blockVb *btcjson.GetBlockVerboseTxResult, filename string) error

SaveTrimedBTCBlockTrimTx trims tx data from a block and saves it to a file

func SaveEVMBlockTrimTxInput

func SaveEVMBlockTrimTxInput(block *ethrpc.Block, filename string) error

SaveTrimedEVMBlockTrimTxInput trims tx input data from a block and saves it to a file

func SaveObjectToJSONFile

func SaveObjectToJSONFile(obj interface{}, filename string) error

SaveObjectToJSONFile saves an object to a file in JSON format

Types

type BlockExtra

type BlockExtra struct {
	TotalFees int       `json:"totalFees"`
	MedianFee float64   `json:"medianFee"`
	FeeRange  []float64 `json:"feeRange"`
	Reward    int       `json:"reward"`
	Pool      struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
		Slug string `json:"slug"`
	} `json:"pool"`
	AvgFee                 int     `json:"avgFee"`
	AvgFeeRate             int     `json:"avgFeeRate"`
	CoinbaseRaw            string  `json:"coinbaseRaw"`
	CoinbaseAddress        string  `json:"coinbaseAddress"`
	CoinbaseSignature      string  `json:"coinbaseSignature"`
	CoinbaseSignatureASCII string  `json:"coinbaseSignatureAscii"`
	AvgTxSize              float64 `json:"avgTxSize"`
	TotalInputs            int     `json:"totalInputs"`
	TotalOutputs           int     `json:"totalOutputs"`
	TotalOutputAmt         int     `json:"totalOutputAmt"`
	MedianFeeAmt           int     `json:"medianFeeAmt"`
	FeePercentiles         []int   `json:"feePercentiles"`
	SegwitTotalTxs         int     `json:"segwitTotalTxs"`
	SegwitTotalSize        int     `json:"segwitTotalSize"`
	SegwitTotalWeight      int     `json:"segwitTotalWeight"`
	Header                 string  `json:"header"`
	UTXOSetChange          int     `json:"utxoSetChange"`
	UTXOSetSize            int     `json:"utxoSetSize"`
	TotalInputAmt          int     `json:"totalInputAmt"`
	VirtualSize            float64 `json:"virtualSize"`
	Orphans                []struct {
		Height int    `json:"height"`
		Hash   string `json:"hash"`
		Status string `json:"status"`
	} `json:"orphans"`
	MatchRate      float64 `json:"matchRate"`
	EXpectedFees   big.Int `json:"expectedFees"`
	ExpectedWeight int     `json:"expectedWeight"`
}

type MempoolBlock

type MempoolBlock struct {
	ID                string     `json:"id"`
	Height            int        `json:"height"`
	Version           int        `json:"version"`
	Time              int        `json:"timestamp"`
	Bits              int        `json:"bits"`
	Nonce             int        `json:"nonce"`
	Difficulty        float64    `json:"difficulty"`
	MerkleRoot        string     `json:"merkle_root"`
	TxCount           int        `json:"tx_count"`
	Size              int        `json:"size"`
	Weight            int        `json:"weight"`
	PreviousBlockHash string     `json:"previousblockhash"`
	MedianTime        int        `json:"mediantime"`
	Extras            BlockExtra `json:"extras"`
}

func GetBlocks

func GetBlocks(ctx context.Context, n int, testnet bool) ([]MempoolBlock, error)

GetBlocks returns return 15 mempool.space blocks [n-14, n] per request

type MempoolTx

type MempoolTx struct {
	TxID     string `json:"txid"`
	Version  int    `json:"version"`
	LockTime int    `json:"locktime"`
	Vin      []Vin  `json:"vin"`
	Vout     []Vout `json:"vout"`
	Size     int    `json:"size"`
	Weight   int    `json:"weight"`
	Fee      int    `json:"fee"`
}

func GetBlockTxs

func GetBlockTxs(ctx context.Context, blockHash string, testnet bool) ([]MempoolTx, error)

GetBlockTxs a list of transactions in the block (up to 25 transactions beginning at index 0)

type Vin

type Vin struct {
	TxID    string `json:"txid"`
	Vout    uint32 `json:"vout"`
	Prevout struct {
		Scriptpubkey        string `json:"scriptpubkey"`
		ScriptpubkeyAsm     string `json:"scriptpubkey_asm"`
		ScriptpubkeyType    string `json:"scriptpubkey_type"`
		ScriptpubkeyAddress string `json:"scriptpubkey_address"`
		Value               int64  `json:"value"`
	} `json:"prevout"`
	Scriptsig  string `json:"scriptsig"`
	IsCoinbase bool   `json:"is_coinbase"`
	Sequence   uint32 `json:"sequence"`
}

type Vout

type Vout struct {
	Scriptpubkey     string `json:"scriptpubkey"`
	ScriptpubkeyAsm  string `json:"scriptpubkey_asm"`
	ScriptpubkeyType string `json:"scriptpubkey_type"`
	Value            int64  `json:"value"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL