Merge pull request #6372 from filecoin-project/fix/nv11-tests

Fix nv13 1.11 tests
This commit is contained in:
Łukasz Magiera 2021-06-02 00:17:05 +02:00 committed by GitHub
commit 2a787dd4a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 163 additions and 157 deletions

View File

@ -63,7 +63,7 @@ func TestDeadlineToggling(t *testing.T, b APIBuilder, blocktime time.Duration) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
n, sn := b(t, []FullNodeOpts{FullNodeWithLatestActorsAt(upgradeH)}, OneMiner) n, sn := b(t, []FullNodeOpts{FullNodeWithNetworkUpgradeAt(network.Version12, upgradeH)}, OneMiner)
client := n[0].FullNode.(*impl.FullNodeAPI) client := n[0].FullNode.(*impl.FullNodeAPI)
minerA := sn[0] minerA := sn[0]

View File

@ -122,14 +122,12 @@ var OneFull = DefaultFullOpts(1)
var TwoFull = DefaultFullOpts(2) var TwoFull = DefaultFullOpts(2)
var FullNodeWithLatestActorsAt = func(upgradeHeight abi.ChainEpoch) FullNodeOpts { var FullNodeWithLatestActorsAt = func(upgradeHeight abi.ChainEpoch) FullNodeOpts {
if upgradeHeight == -1 {
// Attention: Update this when introducing new actor versions or your tests will be sad // Attention: Update this when introducing new actor versions or your tests will be sad
upgradeHeight = 4 return FullNodeWithNetworkUpgradeAt(network.Version13, upgradeHeight)
} }
return FullNodeOpts{ var FullNodeWithNetworkUpgradeAt = func(version network.Version, upgradeHeight abi.ChainEpoch) FullNodeOpts {
Opts: func(nodes []TestNode) node.Option { fullSchedule := stmgr.UpgradeSchedule{{
return node.Override(new(stmgr.UpgradeSchedule), stmgr.UpgradeSchedule{{
// prepare for upgrade. // prepare for upgrade.
Network: network.Version9, Network: network.Version9,
Height: 1, Height: 1,
@ -144,9 +142,26 @@ var FullNodeWithLatestActorsAt = func(upgradeHeight abi.ChainEpoch) FullNodeOpts
Migration: stmgr.UpgradeActorsV4, Migration: stmgr.UpgradeActorsV4,
}, { }, {
Network: network.Version13, Network: network.Version13,
Height: upgradeHeight, Height: 4,
Migration: stmgr.UpgradeActorsV5, Migration: stmgr.UpgradeActorsV5,
}}) }}
schedule := stmgr.UpgradeSchedule{}
for _, upgrade := range fullSchedule {
if upgrade.Network > version {
break
}
schedule = append(schedule, upgrade)
}
if upgradeHeight > 0 {
schedule[len(schedule)-1].Height = upgradeHeight
}
return FullNodeOpts{
Opts: func(nodes []TestNode) node.Option {
return node.Override(new(stmgr.UpgradeSchedule), schedule)
}, },
} }
} }
@ -170,31 +185,6 @@ var FullNodeWithSDRAt = func(calico, persian abi.ChainEpoch) FullNodeOpts {
} }
} }
var FullNodeWithV4ActorsAt = func(upgradeHeight abi.ChainEpoch) FullNodeOpts {
if upgradeHeight == -1 {
upgradeHeight = 3
}
return FullNodeOpts{
Opts: func(nodes []TestNode) node.Option {
return node.Override(new(stmgr.UpgradeSchedule), stmgr.UpgradeSchedule{{
// prepare for upgrade.
Network: network.Version9,
Height: 1,
Migration: stmgr.UpgradeActorsV2,
}, {
Network: network.Version10,
Height: 2,
Migration: stmgr.UpgradeActorsV3,
}, {
Network: network.Version12,
Height: upgradeHeight,
Migration: stmgr.UpgradeActorsV4,
}})
},
}
}
var MineNext = miner.MineReq{ var MineNext = miner.MineReq{
InjectNulls: 0, InjectNulls: 0,
Done: func(bool, abi.ChainEpoch, error) {}, Done: func(bool, abi.ChainEpoch, error) {},

View File

@ -4,6 +4,8 @@ import (
"context" "context"
"strings" "strings"
"github.com/filecoin-project/go-state-types/network"
lapi "github.com/filecoin-project/lotus/api" lapi "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors"
@ -19,8 +21,10 @@ import (
) )
func AddVerifiedClient(t *testing.T, b APIBuilder) { func AddVerifiedClient(t *testing.T, b APIBuilder) {
test := func(nv network.Version, shouldWork bool) func(*testing.T) {
return func(t *testing.T) {
nodes, miners := b(t, []FullNodeOpts{FullNodeWithLatestActorsAt(-1)}, OneMiner) nodes, miners := b(t, []FullNodeOpts{FullNodeWithNetworkUpgradeAt(nv, -1)}, OneMiner)
api := nodes[0].FullNode.(*impl.FullNodeAPI) api := nodes[0].FullNode.(*impl.FullNodeAPI)
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
@ -120,7 +124,17 @@ func AddVerifiedClient(t *testing.T, b APIBuilder) {
Value: big.Zero(), Value: big.Zero(),
} }
if _, err = api.MpoolPushMessage(ctx, msg, nil); !strings.Contains(err.Error(), "verified client already exists") { _, err = api.MpoolPushMessage(ctx, msg, nil)
t.Fatal("Add datacap to an exist verified client should fail") if shouldWork && err != nil {
t.Fatal("expected nil err", err)
}
if !shouldWork && (err == nil || !strings.Contains(err.Error(), "verified client already exists")) {
t.Fatal("Add datacap to an existing verified client should fail")
} }
} }
}
t.Run("nv12", test(network.Version12, false))
t.Run("nv13", test(network.Version13, true))
}

View File

@ -152,6 +152,8 @@ func VersionForNetwork(ver network.Version) (types.StateTreeVersion, error) {
return types.StateTreeVersion2, nil return types.StateTreeVersion2, nil
case network.Version12: case network.Version12:
return types.StateTreeVersion3, nil return types.StateTreeVersion3, nil
case network.Version13:
return types.StateTreeVersion4, nil
default: default:
panic(fmt.Sprintf("unsupported network version %d", ver)) panic(fmt.Sprintf("unsupported network version %d", ver))
} }
@ -162,7 +164,7 @@ func NewStateTree(cst cbor.IpldStore, ver types.StateTreeVersion) (*StateTree, e
switch ver { switch ver {
case types.StateTreeVersion0: case types.StateTreeVersion0:
// info is undefined // info is undefined
case types.StateTreeVersion1, types.StateTreeVersion2, types.StateTreeVersion3: case types.StateTreeVersion1, types.StateTreeVersion2, types.StateTreeVersion3, types.StateTreeVersion4:
var err error var err error
info, err = cst.Put(context.TODO(), new(types.StateInfo0)) info, err = cst.Put(context.TODO(), new(types.StateInfo0))
if err != nil { if err != nil {

View File

@ -1533,8 +1533,8 @@ USAGE:
lotus-miner sectors batching command [command options] [arguments...] lotus-miner sectors batching command [command options] [arguments...]
COMMANDS: COMMANDS:
pending-commit list sectors waiting in commit batch queue commit list sectors waiting in commit batch queue
pending-precommit list sectors waiting in precommit batch queue precommit list sectors waiting in precommit batch queue
help, h Shows a list of commands or help for one command help, h Shows a list of commands or help for one command
OPTIONS: OPTIONS:
@ -1543,13 +1543,13 @@ OPTIONS:
``` ```
#### lotus-miner sectors batching pending-commit #### lotus-miner sectors batching commit
``` ```
NAME: NAME:
lotus-miner sectors batching pending-commit - list sectors waiting in commit batch queue lotus-miner sectors batching commit - list sectors waiting in commit batch queue
USAGE: USAGE:
lotus-miner sectors batching pending-commit [command options] [arguments...] lotus-miner sectors batching commit [command options] [arguments...]
OPTIONS: OPTIONS:
--publish-now send a batch now (default: false) --publish-now send a batch now (default: false)
@ -1557,13 +1557,13 @@ OPTIONS:
``` ```
#### lotus-miner sectors batching pending-precommit #### lotus-miner sectors batching precommit
``` ```
NAME: NAME:
lotus-miner sectors batching pending-precommit - list sectors waiting in precommit batch queue lotus-miner sectors batching precommit - list sectors waiting in precommit batch queue
USAGE: USAGE:
lotus-miner sectors batching pending-precommit [command options] [arguments...] lotus-miner sectors batching precommit [command options] [arguments...]
OPTIONS: OPTIONS:
--publish-now send a batch now (default: false) --publish-now send a batch now (default: false)