2021-07-07 17:12:03 +00:00
|
|
|
package kit
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
|
|
|
addr "github.com/filecoin-project/go-address"
|
|
|
|
"github.com/filecoin-project/go-state-types/big"
|
2022-06-14 15:00:51 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/builtin"
|
2021-07-07 17:12:03 +00:00
|
|
|
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/lotus/chain/actors"
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
|
|
)
|
|
|
|
|
2021-07-07 19:37:32 +00:00
|
|
|
func (tm *TestMiner) SetControlAddresses(addrs ...addr.Address) {
|
2021-07-07 17:12:03 +00:00
|
|
|
ctx := context.TODO()
|
|
|
|
|
2021-07-07 19:37:32 +00:00
|
|
|
mi, err := tm.FullNode.StateMinerInfo(ctx, tm.ActorAddr, types.EmptyTSK)
|
|
|
|
require.NoError(tm.t, err)
|
2021-07-07 17:12:03 +00:00
|
|
|
|
|
|
|
cwp := &miner2.ChangeWorkerAddressParams{
|
|
|
|
NewWorker: mi.Worker,
|
|
|
|
NewControlAddrs: addrs,
|
|
|
|
}
|
|
|
|
|
|
|
|
sp, err := actors.SerializeParams(cwp)
|
2021-07-07 19:37:32 +00:00
|
|
|
require.NoError(tm.t, err)
|
2021-07-07 17:12:03 +00:00
|
|
|
|
2021-07-07 19:37:32 +00:00
|
|
|
smsg, err := tm.FullNode.MpoolPushMessage(ctx, &types.Message{
|
2021-07-07 17:12:03 +00:00
|
|
|
From: mi.Owner,
|
2021-07-07 19:37:32 +00:00
|
|
|
To: tm.ActorAddr,
|
2022-04-20 21:34:28 +00:00
|
|
|
Method: builtin.MethodsMiner.ChangeWorkerAddress,
|
2021-07-07 17:12:03 +00:00
|
|
|
|
|
|
|
Value: big.Zero(),
|
|
|
|
Params: sp,
|
|
|
|
}, nil)
|
2021-07-07 19:37:32 +00:00
|
|
|
require.NoError(tm.t, err)
|
2021-07-07 17:12:03 +00:00
|
|
|
|
2021-07-07 19:37:32 +00:00
|
|
|
tm.FullNode.WaitMsg(ctx, smsg.Cid())
|
2021-07-07 17:12:03 +00:00
|
|
|
}
|