Add convenience methods in test.Transaction
@@ -58,6 +58,14 @@ func NewTransaction() *Transaction {
return tx
}
+func (t *Transaction) SetValidators(addrs ...module.Address) *Transaction {
+ t.json.Validators = make([]*common.Address, len(addrs))
+ for i, a := range addrs {
+ t.json.Validators[i] = common.ToAddress(a)
+ }
+ return t
+}
+
type addresser interface {
Address() module.Address
}
@@ -78,6 +86,20 @@ func (t *Transaction) SetValidatorsNode(addrs ...*Node) *Transaction {
return t
}
+func (t *Transaction) SetNextBlockVersion(v *int32) *Transaction {
+ if v != nil {
+ t.json.NextBlockVersion = &common.HexInt32{Value: *v}
+ } else {
+ t.json.NextBlockVersion = nil
+ }
+ return t
+}
+
+func (t *Transaction) SetVarTest(v *string) *Transaction {
+ t.json.VarTest = v
+ return t
+}
+
func (t *Transaction) Prepare(ctx contract.Context) (state.WorldContext, error) {
lq := []state.LockRequest{
{state.WorldIDStr, state.AccountWriteLock},
