-
Notifications
You must be signed in to change notification settings - Fork 202
/
txProcessorMock.go
56 lines (46 loc) · 1.77 KB
/
txProcessorMock.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
package testscommon
import (
"math/big"
"github.com/ElrondNetwork/elrond-go-core/data/smartContractResult"
"github.com/ElrondNetwork/elrond-go-core/data/transaction"
vmcommon "github.com/ElrondNetwork/elrond-vm-common"
)
// TxProcessorMock -
type TxProcessorMock struct {
ProcessTransactionCalled func(transaction *transaction.Transaction) (vmcommon.ReturnCode, error)
VerifyTransactionCalled func(tx *transaction.Transaction) error
SetBalancesToTrieCalled func(accBalance map[string]*big.Int) (rootHash []byte, err error)
ProcessSmartContractResultCalled func(scr *smartContractResult.SmartContractResult) (vmcommon.ReturnCode, error)
}
// ProcessTransaction -
func (etm *TxProcessorMock) ProcessTransaction(transaction *transaction.Transaction) (vmcommon.ReturnCode, error) {
if etm.ProcessTransactionCalled != nil {
return etm.ProcessTransactionCalled(transaction)
}
return 0, nil
}
// VerifyTransaction -
func (etm *TxProcessorMock) VerifyTransaction(tx *transaction.Transaction) error {
if etm.VerifyTransactionCalled != nil {
return etm.VerifyTransactionCalled(tx)
}
return nil
}
// SetBalancesToTrie -
func (etm *TxProcessorMock) SetBalancesToTrie(accBalance map[string]*big.Int) (rootHash []byte, err error) {
if etm.SetBalancesToTrieCalled != nil {
return etm.SetBalancesToTrieCalled(accBalance)
}
return nil, nil
}
// ProcessSmartContractResult -
func (etm *TxProcessorMock) ProcessSmartContractResult(scr *smartContractResult.SmartContractResult) (vmcommon.ReturnCode, error) {
if etm.ProcessSmartContractResultCalled != nil {
return etm.ProcessSmartContractResultCalled(scr)
}
return 0, nil
}
// IsInterfaceNil returns true if there is no value under the interface
func (etm *TxProcessorMock) IsInterfaceNil() bool {
return etm == nil
}