Improve AddVerifiedClient test
This commit is contained in:
parent
ee21351aa0
commit
2f0a9f6c40
@ -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 FullNodeWithActorsUpgradeAt(network.Version13, upgradeHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
return FullNodeOpts{
|
var FullNodeWithActorsUpgradeAt = 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,25 @@ 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), fullSchedule)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
lapi "github.com/filecoin-project/lotus/api"
|
lapi "github.com/filecoin-project/lotus/api"
|
||||||
@ -19,8 +20,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{FullNodeWithActorsUpgradeAt(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 +123,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))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user