-
Notifications
You must be signed in to change notification settings - Fork 202
/
accountsRepositoryStub.go
57 lines (46 loc) · 1.77 KB
/
accountsRepositoryStub.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
package state
import (
"github.com/ElrondNetwork/elrond-go-core/data/api"
"github.com/ElrondNetwork/elrond-go/common"
"github.com/ElrondNetwork/elrond-go/state"
vmcommon "github.com/ElrondNetwork/elrond-vm-common"
)
// AccountsRepositoryStub -
type AccountsRepositoryStub struct {
GetAccountWithBlockInfoCalled func(address []byte, options api.AccountQueryOptions) (vmcommon.AccountHandler, common.BlockInfo, error)
GetCodeWithBlockInfoCalled func(codeHash []byte, options api.AccountQueryOptions) ([]byte, common.BlockInfo, error)
GetCurrentStateAccountsWrapperCalled func() state.AccountsAdapterAPI
CloseCalled func() error
}
// GetAccountWithBlockInfo -
func (stub *AccountsRepositoryStub) GetAccountWithBlockInfo(address []byte, options api.AccountQueryOptions) (vmcommon.AccountHandler, common.BlockInfo, error) {
if stub.GetAccountWithBlockInfoCalled != nil {
return stub.GetAccountWithBlockInfoCalled(address, options)
}
return nil, nil, nil
}
// GetCodeWithBlockInfo -
func (stub *AccountsRepositoryStub) GetCodeWithBlockInfo(codeHash []byte, options api.AccountQueryOptions) ([]byte, common.BlockInfo, error) {
if stub.GetCodeWithBlockInfoCalled != nil {
return stub.GetCodeWithBlockInfoCalled(codeHash, options)
}
return nil, nil, nil
}
// GetCurrentStateAccountsWrapper -
func (stub *AccountsRepositoryStub) GetCurrentStateAccountsWrapper() state.AccountsAdapterAPI {
if stub.GetCurrentStateAccountsWrapperCalled != nil {
return stub.GetCurrentStateAccountsWrapperCalled()
}
return nil
}
// Close -
func (stub *AccountsRepositoryStub) Close() error {
if stub.CloseCalled != nil {
return stub.CloseCalled()
}
return nil
}
// IsInterfaceNil -
func (stub *AccountsRepositoryStub) IsInterfaceNil() bool {
return stub == nil
}