lotus/itests/kit/control.go
Andrew Jackson (Ajax) 3c4e22ff0c gen fix
2023-11-13 17:59:34 -06:00

42 lines
1.0 KiB
Go

package kit
import (
"context"
"github.com/stretchr/testify/require"
addr "github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/types"
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
)
func (tm *TestMiner) SetControlAddresses(addrs ...addr.Address) {
ctx := context.TODO()
mi, err := tm.FullNode.StateMinerInfo(ctx, tm.ActorAddr, types.EmptyTSK)
require.NoError(tm.t, err)
cwp := &miner2.ChangeWorkerAddressParams{
NewWorker: mi.Worker,
NewControlAddrs: addrs,
}
sp, err := actors.SerializeParams(cwp)
require.NoError(tm.t, err)
smsg, err := tm.FullNode.MpoolPushMessage(ctx, &types.Message{
From: mi.Owner,
To: tm.ActorAddr,
Method: builtin.MethodsMiner.ChangeWorkerAddress,
Value: big.Zero(),
Params: sp,
}, nil)
require.NoError(tm.t, err)
tm.FullNode.WaitMsg(ctx, smsg.Cid())
}