-
Notifications
You must be signed in to change notification settings - Fork 198
/
balanceComputationStub.go
70 lines (57 loc) · 1.79 KB
/
balanceComputationStub.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
package testscommon
import (
"math/big"
)
// BalanceComputationStub -
type BalanceComputationStub struct {
InitCalled func()
SetBalanceToAddressCalled func(address []byte, value *big.Int)
AddBalanceToAddressCalled func(address []byte, value *big.Int) bool
SubBalanceFromAddressCalled func(address []byte, value *big.Int) bool
IsAddressSetCalled func(address []byte) bool
AddressHasEnoughBalanceCalled func(address []byte, value *big.Int) bool
}
// Init -
func (bcs *BalanceComputationStub) Init() {
if bcs.InitCalled != nil {
bcs.InitCalled()
}
}
// SetBalanceToAddress -
func (bcs *BalanceComputationStub) SetBalanceToAddress(address []byte, value *big.Int) {
if bcs.SetBalanceToAddressCalled != nil {
bcs.SetBalanceToAddressCalled(address, value)
}
}
// AddBalanceToAddress -
func (bcs *BalanceComputationStub) AddBalanceToAddress(address []byte, value *big.Int) bool {
if bcs.AddBalanceToAddressCalled != nil {
return bcs.AddBalanceToAddressCalled(address, value)
}
return true
}
// SubBalanceFromAddress -
func (bcs *BalanceComputationStub) SubBalanceFromAddress(address []byte, value *big.Int) bool {
if bcs.SubBalanceFromAddressCalled != nil {
return bcs.SubBalanceFromAddressCalled(address, value)
}
return true
}
// IsAddressSet -
func (bcs *BalanceComputationStub) IsAddressSet(address []byte) bool {
if bcs.IsAddressSetCalled != nil {
return bcs.IsAddressSetCalled(address)
}
return false
}
// AddressHasEnoughBalance -
func (bcs *BalanceComputationStub) AddressHasEnoughBalance(address []byte, value *big.Int) bool {
if bcs.AddressHasEnoughBalanceCalled != nil {
return bcs.AddressHasEnoughBalanceCalled(address, value)
}
return true
}
// IsInterfaceNil -
func (bcs *BalanceComputationStub) IsInterfaceNil() bool {
return bcs == nil
}