-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
mock_whatsonchain_test.go
55 lines (42 loc) · 1.21 KB
/
mock_whatsonchain_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
package bsvrates
import (
"context"
"errors"
"time"
"github.com/mrz1836/go-whatsonchain"
)
// mockWOCBase is the base
type mockWOCBase struct{}
// GetChainInfo is a mock response
func (m *mockWOCBase) GetChainInfo(context.Context) (chainInfo *whatsonchain.ChainInfo, err error) {
return
}
// GetCirculatingSupply is a mock response
func (m *mockWOCBase) GetCirculatingSupply(context.Context) (supply float64, err error) {
return
}
// GetExchangeRate is a mock response
func (m *mockWOCBase) GetExchangeRate(context.Context) (rate *whatsonchain.ExchangeRate, err error) {
return
}
// mockWOCValid for mocking requests
type mockWOCValid struct {
mockWOCBase
}
// GetExchangeRate is a mock response
func (m *mockWOCValid) GetExchangeRate(_ context.Context) (rate *whatsonchain.ExchangeRate, err error) {
rate = &whatsonchain.ExchangeRate{
Rate: 159.01,
Time: time.Now().Unix(),
Currency: CurrencyToName(CurrencyDollars),
}
return
}
// mockWOCFailed for mocking requests
type mockWOCFailed struct {
mockWOCBase
}
// GetExchangeRate is a mock response
func (m *mockWOCFailed) GetExchangeRate(_ context.Context) (rate *whatsonchain.ExchangeRate, err error) {
return nil, errors.New("some error occurred")
}