-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_create_account.go
91 lines (69 loc) · 2.79 KB
/
test_create_account.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package currency
import (
"github.com/ProtoconNet/mitum-currency/v3/operation/test"
"github.com/ProtoconNet/mitum-currency/v3/types"
"github.com/ProtoconNet/mitum2/base"
"github.com/ProtoconNet/mitum2/util/encoder"
"github.com/stretchr/testify/mock"
)
type TestCreateAccountProcessor struct {
*test.BaseTestOperationProcessorWithItem[CreateAccount, CreateAccountItem]
}
func NewTestCreateAccountProcessor(
encs *encoder.Encoders,
) TestCreateAccountProcessor {
t := test.NewBaseTestOperationProcessorWithItem[CreateAccount, CreateAccountItem](encs)
return TestCreateAccountProcessor{&t}
}
func (t *TestCreateAccountProcessor) Create() *TestCreateAccountProcessor {
t.Opr, _ = NewCreateAccountProcessor()(
base.GenesisHeight,
t.GetStateFunc,
nil, nil,
)
return t
}
func (t *TestCreateAccountProcessor) SetCurrency(
cid string, am int64, addr base.Address, target []types.CurrencyID, instate bool) *TestCreateAccountProcessor {
t.BaseTestOperationProcessorWithItem.SetCurrency(cid, am, addr, target, instate)
return t
}
func (t *TestCreateAccountProcessor) SetAmount(am int64, cid types.CurrencyID, target []types.Amount) *TestCreateAccountProcessor {
t.BaseTestOperationProcessorWithItem.SetAmount(am, cid, target)
return t
}
func (t *TestCreateAccountProcessor) SetContractAccount(
owner base.Address, priv string, amount int64, cid types.CurrencyID, target []test.Account, inState bool,
) *TestCreateAccountProcessor {
t.BaseTestOperationProcessorWithItem.SetContractAccount(owner, priv, amount, cid, target, inState)
return t
}
func (t *TestCreateAccountProcessor) SetAccount(
priv string, amount int64, cid types.CurrencyID, target []test.Account, inState bool) *TestCreateAccountProcessor {
t.BaseTestOperationProcessorWithItem.SetAccount(priv, amount, cid, target, inState)
return t
}
func (t *TestCreateAccountProcessor) LoadOperation(fileName string) *TestCreateAccountProcessor {
t.BaseTestOperationProcessorWithItem.LoadOperation(fileName)
return t
}
func (t *TestCreateAccountProcessor) Print(fileName string) *TestCreateAccountProcessor {
t.BaseTestOperationProcessorWithItem.Print(fileName)
return t
}
func (t *TestCreateAccountProcessor) MakeItem(
target test.Account, amounts []types.Amount, targetItems []CreateAccountItem,
) *TestCreateAccountProcessor {
item := NewCreateAccountItemMultiAmounts(target.Keys(), amounts, types.AddressHint.Type())
test.UpdateSlice[CreateAccountItem](item, targetItems)
return t
}
func (t *TestCreateAccountProcessor) MakeOperation(
sender base.Address, privatekey base.Privatekey, items []CreateAccountItem,
) *TestCreateAccountProcessor {
t.MockGetter.On("Get", mock.Anything).Return(nil, false, nil)
op, _ := NewCreateAccount(NewCreateAccountFact([]byte("token"), sender, items))
_ = op.Sign(privatekey, t.NetworkID)
t.Op = op
return t
}