forked from stellar/go
/
mocks.go
157 lines (137 loc) · 3.94 KB
/
mocks.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
package horizon
import (
"context"
"github.com/lomocoin/stellar-go/xdr"
"github.com/stretchr/testify/mock"
)
// MockClient is a mockable horizon client.
type MockClient struct {
mock.Mock
}
// Root is a mocking a method
func (m *MockClient) Root() (Root, error) {
a := m.Called()
return a.Get(0).(Root), a.Error(1)
}
// HomeDomainForAccount is a mocking a method
func (m *MockClient) HomeDomainForAccount(aid string) (string, error) {
a := m.Called(aid)
return a.Get(0).(string), a.Error(1)
}
// LoadAccount is a mocking a method
func (m *MockClient) LoadAccount(accountID string) (Account, error) {
a := m.Called(accountID)
return a.Get(0).(Account), a.Error(1)
}
// LoadAccountOffers is a mocking a method
func (m *MockClient) LoadAccountOffers(
accountID string,
params ...interface{},
) (offers OffersPage, err error) {
// There is no way to simply call:
//
// a := m.Called(accountID, params...)
//
// Go errors with: "too many arguments in call to m.Mock.Called"
args := []interface{}{accountID}
for _, param := range params {
args = append(args, param)
}
a := m.Called(args...)
return a.Get(0).(OffersPage), a.Error(1)
}
// LoadTradeAggregations is a mocking a method
func (m *MockClient) LoadTradeAggregations(
baseAsset Asset,
counterAsset Asset,
resolution int64,
params ...interface{},
) (tradeAggrs TradeAggregationsPage, err error) {
a := m.Called(baseAsset, counterAsset, resolution, params)
return a.Get(0).(TradeAggregationsPage), a.Error(1)
}
// LoadTrades is a mocking a method
func (m *MockClient) LoadTrades(
baseAsset Asset,
counterAsset Asset,
offerID int64,
resolution int64,
params ...interface{},
) (tradesPage TradesPage, err error) {
args := []interface{}{baseAsset, counterAsset, offerID, resolution}
args = append(args, params...)
a := m.Called(args...)
return a.Get(0).(TradesPage), a.Error(1)
}
// LoadAccountMergeAmount is a mocking a method
func (m *MockClient) LoadAccountMergeAmount(p *Payment) error {
a := m.Called(p)
return a.Error(0)
}
// LoadMemo is a mocking a method
func (m *MockClient) LoadMemo(p *Payment) error {
a := m.Called(p)
return a.Error(0)
}
// LoadMemo is a mocking a method
func (m *MockClient) LoadOperation(operationID string) (payment Payment, err error) {
a := m.Called(operationID)
return a.Get(0).(Payment), a.Error(1)
}
// LoadOrderBook is a mocking a method
func (m *MockClient) LoadOrderBook(
selling Asset,
buying Asset,
params ...interface{},
) (orderBook OrderBookSummary, err error) {
a := m.Called(selling, buying, params)
return a.Get(0).(OrderBookSummary), a.Error(1)
}
// LoadTransaction is a mocking a method
func (m *MockClient) LoadTransaction(transactionID string) (transaction Transaction, err error) {
a := m.Called(transactionID)
return a.Get(0).(Transaction), a.Error(1)
}
// SequenceForAccount is a mocking a method
func (m *MockClient) SequenceForAccount(accountID string) (xdr.SequenceNumber, error) {
a := m.Called(accountID)
return a.Get(0).(xdr.SequenceNumber), a.Error(1)
}
// StreamLedgers is a mocking a method
func (m *MockClient) StreamLedgers(
ctx context.Context,
cursor *Cursor,
handler LedgerHandler,
) error {
a := m.Called(ctx, cursor, handler)
return a.Error(0)
}
// StreamPayments is a mocking a method
func (m *MockClient) StreamPayments(
ctx context.Context,
accountID string,
cursor *Cursor,
handler PaymentHandler,
) error {
a := m.Called(ctx, accountID, cursor, handler)
return a.Error(0)
}
// StreamTransactions is a mocking a method
func (m *MockClient) StreamTransactions(
ctx context.Context,
accountID string,
cursor *Cursor,
handler TransactionHandler,
) error {
a := m.Called(ctx, accountID, cursor, handler)
return a.Error(0)
}
// SubmitTransaction is a mocking a method
func (m *MockClient) SubmitTransaction(
txeBase64 string,
) (TransactionSuccess, error) {
a := m.Called(txeBase64)
return a.Get(0).(TransactionSuccess), a.Error(1)
}
// ensure that the MockClient implements ClientInterface
var _ ClientInterface = &MockClient{}