Merge branch 'raulk/itests-refactor-kit' into nonsense/split-market-miner-processes
This commit is contained in:
commit
d98eca7260
@ -19,7 +19,6 @@ import (
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/api/client"
|
||||
"github.com/filecoin-project/lotus/chain/actors/policy"
|
||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/cli"
|
||||
@ -35,12 +34,6 @@ const (
|
||||
maxStateWaitLookbackLimit = stmgr.LookbackNoLimit
|
||||
)
|
||||
|
||||
func init() {
|
||||
policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)
|
||||
policy.SetConsensusMinerMinPower(abi.NewStoragePower(2048))
|
||||
policy.SetMinVerifiedDealSize(abi.NewStoragePower(256))
|
||||
}
|
||||
|
||||
// TestGatewayWalletMsig tests that API calls to wallet and msig can be made on a lite
|
||||
// node that is connected through a gateway to a full API node
|
||||
func TestGatewayWalletMsig(t *testing.T) {
|
||||
@ -49,7 +42,6 @@ func TestGatewayWalletMsig(t *testing.T) {
|
||||
blocktime := 5 * time.Millisecond
|
||||
ctx := context.Background()
|
||||
nodes := startNodes(ctx, t, blocktime, maxLookbackCap, maxStateWaitLookbackLimit)
|
||||
defer nodes.closer()
|
||||
|
||||
lite := nodes.lite
|
||||
full := nodes.full
|
||||
@ -181,7 +173,6 @@ func TestGatewayMsigCLI(t *testing.T) {
|
||||
blocktime := 5 * time.Millisecond
|
||||
ctx := context.Background()
|
||||
nodes := startNodesWithFunds(ctx, t, blocktime, maxLookbackCap, maxStateWaitLookbackLimit)
|
||||
defer nodes.closer()
|
||||
|
||||
lite := nodes.lite
|
||||
runMultisigTests(t, lite)
|
||||
@ -193,7 +184,6 @@ func TestGatewayDealFlow(t *testing.T) {
|
||||
blocktime := 5 * time.Millisecond
|
||||
ctx := context.Background()
|
||||
nodes := startNodesWithFunds(ctx, t, blocktime, maxLookbackCap, maxStateWaitLookbackLimit)
|
||||
defer nodes.closer()
|
||||
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
@ -216,16 +206,14 @@ func TestGatewayCLIDealFlow(t *testing.T) {
|
||||
blocktime := 5 * time.Millisecond
|
||||
ctx := context.Background()
|
||||
nodes := startNodesWithFunds(ctx, t, blocktime, maxLookbackCap, maxStateWaitLookbackLimit)
|
||||
defer nodes.closer()
|
||||
|
||||
kit.RunClientTest(t, cli.Commands, nodes.lite)
|
||||
}
|
||||
|
||||
type testNodes struct {
|
||||
lite *kit.TestFullNode
|
||||
full *kit.TestFullNode
|
||||
miner *kit.TestMiner
|
||||
closer jsonrpc.ClientCloser
|
||||
lite *kit.TestFullNode
|
||||
full *kit.TestFullNode
|
||||
miner *kit.TestMiner
|
||||
}
|
||||
|
||||
func startNodesWithFunds(
|
||||
@ -298,7 +286,7 @@ func startNodes(
|
||||
),
|
||||
).Start().InterconnectAll()
|
||||
|
||||
return &testNodes{lite: &lite, full: full, miner: miner, closer: closer}
|
||||
return &testNodes{lite: &lite, full: full, miner: miner}
|
||||
}
|
||||
|
||||
func sendFunds(ctx context.Context, fromNode *kit.TestFullNode, fromAddr address.Address, toAddr address.Address, amt types.BigInt) error {
|
||||
|
@ -111,6 +111,7 @@ type Ensemble struct {
|
||||
active struct {
|
||||
fullnodes []*TestFullNode
|
||||
miners []*TestMiner
|
||||
bms map[*TestMiner]*BlockMiner
|
||||
}
|
||||
genesis struct {
|
||||
miners []genesis.Miner
|
||||
@ -127,6 +128,7 @@ func NewEnsemble(t *testing.T, opts ...EnsembleOpt) *Ensemble {
|
||||
}
|
||||
|
||||
n := &Ensemble{t: t, options: &options}
|
||||
n.active.bms = make(map[*TestMiner]*BlockMiner)
|
||||
|
||||
// add accounts from ensemble options to genesis.
|
||||
for _, acc := range options.accounts {
|
||||
@ -656,7 +658,14 @@ func (n *Ensemble) BeginMining(blocktime time.Duration, miners ...*TestMiner) []
|
||||
|
||||
var bms []*BlockMiner
|
||||
if len(miners) == 0 {
|
||||
miners = n.active.miners
|
||||
// no miners have been provided explicitly, instantiate block miners
|
||||
// for all active miners that aren't still mining.
|
||||
for _, m := range n.active.miners {
|
||||
if _, ok := n.active.bms[m]; ok {
|
||||
continue // skip, already have a block miner
|
||||
}
|
||||
miners = append(miners, m)
|
||||
}
|
||||
}
|
||||
|
||||
for _, m := range miners {
|
||||
@ -665,6 +674,8 @@ func (n *Ensemble) BeginMining(blocktime time.Duration, miners ...*TestMiner) []
|
||||
n.t.Cleanup(bm.Stop)
|
||||
|
||||
bms = append(bms, bm)
|
||||
|
||||
n.active.bms[m] = bm
|
||||
}
|
||||
|
||||
return bms
|
||||
|
@ -50,26 +50,11 @@ func TestWindowPostDispute(t *testing.T) {
|
||||
Miner(&evilMiner, &client, append(opts, kit.PresealSectors(0))...).
|
||||
Start()
|
||||
|
||||
{
|
||||
addrinfo, err := client.NetAddrsListen(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := chainMiner.NetConnect(ctx, addrinfo); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := evilMiner.NetConnect(ctx, addrinfo); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
defaultFrom, err := client.WalletDefaultAddress(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Mine with the _second_ node (the good one).
|
||||
ens.BeginMining(blocktime, &chainMiner)
|
||||
ens.InterconnectAll().BeginMining(blocktime, &chainMiner)
|
||||
|
||||
// Give the chain miner enough sectors to win every block.
|
||||
chainMiner.PledgeSectors(ctx, 10, 0, nil)
|
||||
@ -85,7 +70,7 @@ func TestWindowPostDispute(t *testing.T) {
|
||||
|
||||
t.Logf("Running one proving period\n")
|
||||
|
||||
waitUntil := di.PeriodStart + di.WPoStProvingPeriod*2
|
||||
waitUntil := di.PeriodStart + di.WPoStProvingPeriod*2 + 1
|
||||
t.Logf("End for head.Height > %d", waitUntil)
|
||||
|
||||
ts := client.WaitTillChain(ctx, kit.HeightAtLeast(waitUntil))
|
||||
@ -258,7 +243,7 @@ func TestWindowPostDisputeFails(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Log("Running one proving period")
|
||||
waitUntil := di.PeriodStart + di.WPoStProvingPeriod*2
|
||||
waitUntil := di.PeriodStart + di.WPoStProvingPeriod*2 + 1
|
||||
t.Logf("End for head.Height > %d", waitUntil)
|
||||
|
||||
ts := client.WaitTillChain(ctx, kit.HeightAtLeast(waitUntil))
|
||||
|
Loading…
Reference in New Issue
Block a user