-
Notifications
You must be signed in to change notification settings - Fork 32
/
export_test.go
126 lines (108 loc) · 4.74 KB
/
export_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package submitter
import (
"context"
"math/big"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/synapsecns/sanguine/core/metrics"
"github.com/synapsecns/sanguine/ethergo/client"
"github.com/synapsecns/sanguine/ethergo/signer/signer"
"github.com/synapsecns/sanguine/ethergo/submitter/config"
"github.com/synapsecns/sanguine/ethergo/submitter/db"
"go.opentelemetry.io/otel/attribute"
)
// CopyTransactOpts exports copyTransactOpts for testing.
func CopyTransactOpts(opts *bind.TransactOpts) *bind.TransactOpts {
return copyTransactOpts(opts)
}
// NullFieldAttribute is a constant used to test the null field attribute.
// it exports the underlying constant for testing.
const NullFieldAttribute = nullFieldAttribute
func AddressPtrToString(address *common.Address) string {
return addressPtrToString(address)
}
// BigPtrToString converts a big.Int pointer to a string.
func BigPtrToString(num *big.Int) string {
return bigPtrToString(num)
}
// TxToAttributes exports txToAttributes for testing.
func TxToAttributes(transaction *types.Transaction, UUID string) []attribute.KeyValue {
return txToAttributes(transaction, UUID)
}
// SortTxes exports sortTxesByChainID for testing.
func SortTxes(txs []db.TX, maxPerChain int) map[uint64][]db.TX {
return sortTxesByChainID(txs, maxPerChain)
}
// GroupTxesByNonce exports groupTxesByNonce for testing.
func GroupTxesByNonce(txs []db.TX) map[uint64][]db.TX {
return groupTxesByNonce(txs)
}
const (
// HashAttr exports hashAttr for testing.
HashAttr = hashAttr
// FromAttr exports fromAttr for testing.
FromAttr = fromAttr
// ToAttr exports toAttr for testing.
ToAttr = toAttr
// DataAttr exports dataAttr for testing.
DataAttr = dataAttr
// ValueAttr exports valueAttr for testing.
ValueAttr = valueAttr
// NonceAttr exports nonceAttr for testing.
NonceAttr = nonceAttr
// GasLimitAttr exports gasLimitAttr for testing.
GasLimitAttr = gasLimitAttr
// ChainIDAttr exports chainIDAttr for testing.
ChainIDAttr = chainIDAttr
// GasPriceAttr exports gasPriceAttr for testing.
GasPriceAttr = gasPriceAttr
// GasFeeCapAttr exports gasFeeCapAttr for testing.
GasFeeCapAttr = gasFeeCapAttr
// GasTipCapAttr exports gasTipCapAttr for testing.
GasTipCapAttr = gasTipCapAttr
)
// NewTestTransactionSubmitter wraps TestTransactionSubmitter in a TransactionSubmitter interface.
func NewTestTransactionSubmitter(metrics metrics.Handler, signer signer.Signer, fetcher ClientFetcher, db db.Service, config *config.Config) TestTransactionSubmitter {
txSubmitter := NewTransactionSubmitter(metrics, signer, fetcher, db, config)
//nolint: forcetypeassert
return txSubmitter.(TestTransactionSubmitter)
}
// TestTransactionSubmitter is a TransactionSubmitter interface for testing.
type TestTransactionSubmitter interface {
TransactionSubmitter
// SetGasPrice exports setGasPrice for testing.
SetGasPrice(ctx context.Context, client client.EVM,
transactor *bind.TransactOpts, bigChainID *big.Int, prevTx *types.Transaction) (err error)
// GetGasBlock exports getGasBlock for testing.
GetGasBlock(ctx context.Context, client client.EVM, chainID int) (gasBlock *types.Header, err error)
// GetNonce exports getNonce for testing.
GetNonce(parentCtx context.Context, chainID *big.Int, address common.Address) (_ uint64, err error)
// CheckAndSetConfirmation exports checkAndSetConfirmation for testing.
CheckAndSetConfirmation(ctx context.Context, chainClient client.EVM, txes []db.TX) error
}
// SetGasPrice exports setGasPrice for testing.
func (t *txSubmitterImpl) SetGasPrice(ctx context.Context, client client.EVM,
transactor *bind.TransactOpts, bigChainID *big.Int, prevTx *types.Transaction) (err error) {
return t.setGasPrice(ctx, client, transactor, bigChainID, prevTx)
}
// GetGasBlock exports getGasBlock for testing.
func (t *txSubmitterImpl) GetGasBlock(ctx context.Context, client client.EVM, chainID int) (gasBlock *types.Header, err error) {
return t.getGasBlock(ctx, client, chainID)
}
// GetNonce exports getNonce for testing.
func (t *txSubmitterImpl) GetNonce(parentCtx context.Context, chainID *big.Int, address common.Address) (_ uint64, err error) {
return t.getNonce(parentCtx, chainID, address)
}
// CheckAndSetConfirmation exports checkAndSetConfirmation for testing.
func (t *txSubmitterImpl) CheckAndSetConfirmation(ctx context.Context, chainClient client.EVM, txes []db.TX) error {
return t.checkAndSetConfirmation(ctx, chainClient, txes)
}
// Outersection exports outersection for testing.
func Outersection(set, superset []*big.Int) []*big.Int {
return outersection(set, superset)
}
// MapToBigIntSlice exports mapToBigIntSlice for testing.
func MapToBigIntSlice[T any](m map[uint64]T) []*big.Int {
return mapToBigIntSlice(m)
}