/
apiBlockHandlerStub.go
55 lines (44 loc) · 1.73 KB
/
apiBlockHandlerStub.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 mock
import (
"github.com/ElrondNetwork/elrond-go-core/data/api"
"github.com/ElrondNetwork/elrond-go-core/data/outport"
)
// BlockAPIHandlerStub -
type BlockAPIHandlerStub struct {
GetBlockByNonceCalled func(nonce uint64, options api.BlockQueryOptions) (*api.Block, error)
GetBlockByHashCalled func(hash []byte, options api.BlockQueryOptions) (*api.Block, error)
GetBlockByRoundCalled func(round uint64, options api.BlockQueryOptions) (*api.Block, error)
GetAlteredAccountsForBlockCalled func(options api.GetAlteredAccountsForBlockOptions) ([]*outport.AlteredAccount, error)
}
// GetBlockByNonce -
func (bah *BlockAPIHandlerStub) GetBlockByNonce(nonce uint64, options api.BlockQueryOptions) (*api.Block, error) {
if bah.GetBlockByNonceCalled != nil {
return bah.GetBlockByNonceCalled(nonce, options)
}
return nil, nil
}
// GetBlockByHash -
func (bah *BlockAPIHandlerStub) GetBlockByHash(hash []byte, options api.BlockQueryOptions) (*api.Block, error) {
if bah.GetBlockByHashCalled != nil {
return bah.GetBlockByHashCalled(hash, options)
}
return nil, nil
}
// GetBlockByRound -
func (bah *BlockAPIHandlerStub) GetBlockByRound(round uint64, options api.BlockQueryOptions) (*api.Block, error) {
if bah.GetBlockByRoundCalled != nil {
return bah.GetBlockByRoundCalled(round, options)
}
return nil, nil
}
// GetAlteredAccountsForBlock -
func (bah *BlockAPIHandlerStub) GetAlteredAccountsForBlock(options api.GetAlteredAccountsForBlockOptions) ([]*outport.AlteredAccount, error) {
if bah.GetAlteredAccountsForBlockCalled != nil {
return bah.GetAlteredAccountsForBlockCalled(options)
}
return nil, nil
}
// IsInterfaceNil -
func (bah *BlockAPIHandlerStub) IsInterfaceNil() bool {
return bah == nil
}