2022-08-29 14:25:30 +00:00
|
|
|
// stm: #integration
|
2021-05-17 12:28:09 +00:00
|
|
|
package itests
|
2020-07-01 14:49:17 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2021-12-08 17:11:19 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
2021-06-18 18:45:29 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2022-03-16 19:28:15 +00:00
|
|
|
|
2022-06-14 15:00:51 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
|
|
|
"github.com/filecoin-project/go-state-types/network"
|
|
|
|
|
2022-03-16 19:28:15 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
|
|
"github.com/filecoin-project/lotus/itests/kit"
|
2020-07-01 14:49:17 +00:00
|
|
|
)
|
|
|
|
|
2021-05-18 20:32:10 +00:00
|
|
|
func TestCCUpgrade(t *testing.T) {
|
2021-12-13 12:41:04 +00:00
|
|
|
//stm: @CHAIN_SYNCER_LOAD_GENESIS_001, @CHAIN_SYNCER_FETCH_TIPSET_001,
|
|
|
|
//stm: @CHAIN_SYNCER_START_001, @CHAIN_SYNCER_SYNC_001, @BLOCKCHAIN_BEACON_VALIDATE_BLOCK_VALUES_01
|
|
|
|
//stm: @CHAIN_SYNCER_COLLECT_CHAIN_001, @CHAIN_SYNCER_COLLECT_HEADERS_001, @CHAIN_SYNCER_VALIDATE_TIPSET_001
|
|
|
|
//stm: @CHAIN_SYNCER_NEW_PEER_HEAD_001, @CHAIN_SYNCER_VALIDATE_MESSAGE_META_001, @CHAIN_SYNCER_STOP_001
|
2021-12-10 15:08:25 +00:00
|
|
|
|
|
|
|
//stm: @CHAIN_STATE_MINER_GET_INFO_001
|
2021-12-14 10:33:33 +00:00
|
|
|
//stm: @CHAIN_INCOMING_HANDLE_INCOMING_BLOCKS_001, @CHAIN_INCOMING_VALIDATE_BLOCK_PUBSUB_001, @CHAIN_INCOMING_VALIDATE_MESSAGE_PUBSUB_001
|
2021-12-15 14:30:42 +00:00
|
|
|
|
|
|
|
//stm: @MINER_SECTOR_LIST_001
|
2021-06-18 18:45:29 +00:00
|
|
|
kit.QuietMiningLogs()
|
2021-05-18 20:32:10 +00:00
|
|
|
|
2022-03-18 09:36:26 +00:00
|
|
|
n := runTestCCUpgrade(t)
|
|
|
|
|
|
|
|
t.Run("post", func(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
|
|
|
ts, err := n.ChainHead(ctx)
|
|
|
|
require.NoError(t, err)
|
|
|
|
start := ts.Height()
|
|
|
|
// wait for a full proving period
|
|
|
|
t.Log("waiting for chain")
|
|
|
|
|
|
|
|
n.WaitTillChain(ctx, func(ts *types.TipSet) bool {
|
|
|
|
if ts.Height() > start+abi.ChainEpoch(2880) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
})
|
|
|
|
})
|
2020-10-05 17:56:00 +00:00
|
|
|
}
|
|
|
|
|
2022-02-03 12:51:59 +00:00
|
|
|
func runTestCCUpgrade(t *testing.T) *kit.TestFullNode {
|
2020-07-01 14:49:17 +00:00
|
|
|
ctx := context.Background()
|
2022-01-09 03:23:22 +00:00
|
|
|
blockTime := 1 * time.Millisecond
|
2021-06-14 09:50:40 +00:00
|
|
|
|
2022-02-08 13:28:13 +00:00
|
|
|
client, miner, ens := kit.EnsembleMinimal(t, kit.GenesisNetworkVersion(network.Version15), kit.ThroughRPC())
|
2021-12-08 17:11:19 +00:00
|
|
|
ens.InterconnectAll().BeginMiningMustPost(blockTime)
|
2021-06-14 09:50:40 +00:00
|
|
|
|
2020-07-01 14:49:17 +00:00
|
|
|
maddr, err := miner.ActorAddress(ctx)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-08-02 14:05:29 +00:00
|
|
|
CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner)
|
2021-12-08 17:11:19 +00:00
|
|
|
fmt.Printf("CCUpgrade: %d\n", CCUpgrade)
|
2020-07-01 14:49:17 +00:00
|
|
|
|
2021-06-14 09:50:40 +00:00
|
|
|
miner.PledgeSectors(ctx, 1, 0, nil)
|
2022-08-02 13:29:38 +00:00
|
|
|
sl, err := miner.SectorsListNonGenesis(ctx)
|
2021-06-15 06:27:02 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Len(t, sl, 1, "expected 1 sector")
|
2021-12-08 17:11:19 +00:00
|
|
|
require.Equal(t, CCUpgrade, sl[0], "unexpected sector number")
|
2020-07-01 14:49:17 +00:00
|
|
|
{
|
2021-12-08 17:11:19 +00:00
|
|
|
si, err := client.StateSectorGetInfo(ctx, maddr, CCUpgrade, types.EmptyTSK)
|
2020-07-01 14:49:17 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Less(t, 50000, int(si.Expiration))
|
|
|
|
}
|
2022-03-17 20:39:52 +00:00
|
|
|
client.WaitForSectorActive(ctx, t, CCUpgrade, maddr)
|
2020-07-01 14:49:17 +00:00
|
|
|
|
feat: Add additional test annotations (#8272)
* Annotate api,proxy_util,blockstore_badger, policy tests
* Annotate splitstore: bsbadger / markset
* Annotate splitstore feature
* Annotate union/timed blockstore tests
* Annotate openrpc, diff_adt tests
* Annotate error,drand,events tests
* Annotate predicates_test
* Fix annotations
* Annotate tscache, gen tests
* Annotate fundmanager test
* Annotate repub and selection tests
* Annotate statetree_test
* Annotate forks_test
* Annotate searchwait_test.go
* Fix duplicated @@ symbols
* Annotate chain stmgr/store tests
* Annotate more (types) tests
* More tests annotated
* Annotate conformance chaos actor tests
* Annotate more integration tests
* Annotate journal system tests
* Annotate more tests.
* Annotate gas,head buffer behaviors
* Fix markset annotations
* doc: test annotations for the markets dagstore wrapper
* Annotate miner_api test in dagstore
* Annotate more test files
* Remove bad annotations from fsrepo
* Annotate wdpost system
* Remove bad annotations
* Renamce "conformance" to "chaos_actor" tests
* doc: stm annotations for blockheader & election proof tests
* Annotate remaining "A" tests
* annotate: stm for error_test
* memrepo_test.go
* Annotate "b" file tests
* message_test.go
* doc: stm annotate for fsrepo_test
* Annotate "c" file tests
* Annotate "D" test files
* message_test.go
* doc: stm annotate for chain, node/config & client
* docs: stm annotate node_test
* Annotate u,v,wl tests
* doc: stm annotations for various test files
* Annotate "T" test files
* doc: stm annotate for proxy_util_test & policy_test
* doc: stm annotate for various tests
* doc: final few stm annotations
* Add mempool unit tests
* Add two more memPool Add tests
* Update submodules
* Add check function tests
* Add stm annotations, refactor test helper
* Annotate api,proxy_util,blockstore_badger, policy tests
* Annotate splitstore: bsbadger / markset
solving merge conflicts
* Annotate splitstore feature
* Annotate union/timed blockstore tests
* Annotate openrpc, diff_adt tests
* Annotate error,drand,events tests
* Annotate predicates_test
* Fix annotations
* Annotate tscache, gen tests
* Annotate fundmanager test
* Annotate statetree_test
* Annotate forks_test
* Annotate searchwait_test.go
* Fix duplicated @@ symbols
* Annotate chain stmgr/store tests
* Annotate more (types) tests
* More tests annotated
* Annotate conformance chaos actor tests
* Annotate more integration tests
* Annotate journal system tests
* Annotate more tests.
* Annotate gas,head buffer behaviors
solve merge conflict
* Fix markset annotations
* Annotate miner_api test in dagstore
* Annotate more test files
* doc: test annotations for the markets dagstore wrapper
* Annotate wdpost system
* Renamce "conformance" to "chaos_actor" tests
* Annotate remaining "A" tests
* doc: stm annotations for blockheader & election proof tests
* annotate: stm for error_test
* Annotate "b" file tests
* memrepo_test.go
* Annotate "c" file tests
* message_test.go
* Annotate "D" test files
* doc: stm annotate for fsrepo_test
* Annotate u,v,wl tests
* message_test.go
* doc: stm annotate for chain, node/config & client
* docs: stm annotate node_test
* Annotate "T" test files
* doc: stm annotations for various test files
* Add mempool unit tests
solve merge conflict
* doc: stm annotate for proxy_util_test & policy_test
* doc: stm annotate for various tests
* doc: final few stm annotations
* Add two more memPool Add tests
* Update submodules
* Add check function tests
solve conflict
* Add stm annotations, refactor test helper
solve merge conflict
* Change CLI test kinds to "unit"
* Fix double merged test
* Fix ccupgrade_test merge
* Fix lint issues
* Add stm annotation to types_Test
* Test vectors submodule
* Add file annotation to burn_test
Co-authored-by: Nikola Divic <divicnikola@gmail.com>
Co-authored-by: TheMenko <themenkoprojects@gmail.com>
2022-03-16 17:37:34 +00:00
|
|
|
//stm: @SECTOR_CC_UPGRADE_001
|
2021-12-08 17:11:19 +00:00
|
|
|
err = miner.SectorMarkForUpgrade(ctx, sl[0], true)
|
2021-06-15 06:27:02 +00:00
|
|
|
require.NoError(t, err)
|
2020-07-01 14:49:17 +00:00
|
|
|
|
2022-08-02 13:29:38 +00:00
|
|
|
sl, err = miner.SectorsListNonGenesis(ctx)
|
2021-12-08 17:11:19 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Len(t, sl, 1, "expected 1 sector")
|
|
|
|
|
2021-06-23 09:24:55 +00:00
|
|
|
dh := kit.NewDealHarness(t, client, miner, miner)
|
2021-06-23 18:14:27 +00:00
|
|
|
deal, res, inPath := dh.MakeOnlineDeal(ctx, kit.MakeFullDealParams{
|
|
|
|
Rseed: 6,
|
|
|
|
SuspendUntilCryptoeconStable: true,
|
|
|
|
})
|
2021-06-21 17:19:26 +00:00
|
|
|
outPath := dh.PerformRetrieval(context.Background(), deal, res.Root, false)
|
|
|
|
kit.AssertFilesEqual(t, inPath, outPath)
|
2020-07-01 14:49:17 +00:00
|
|
|
|
2021-12-08 17:11:19 +00:00
|
|
|
status, err := miner.SectorsStatus(ctx, CCUpgrade, true)
|
|
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, 1, len(status.Deals))
|
2022-02-08 14:29:30 +00:00
|
|
|
|
|
|
|
miner.WaitSectorsProving(ctx, map[abi.SectorNumber]struct{}{
|
|
|
|
CCUpgrade: {},
|
|
|
|
})
|
|
|
|
|
2021-12-08 17:11:19 +00:00
|
|
|
return client
|
|
|
|
}
|
2020-07-01 14:49:17 +00:00
|
|
|
|
2021-12-08 17:11:19 +00:00
|
|
|
func TestCCUpgradeAndPoSt(t *testing.T) {
|
|
|
|
kit.QuietMiningLogs()
|
|
|
|
t.Run("upgrade and then post", func(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
2022-02-03 12:51:59 +00:00
|
|
|
n := runTestCCUpgrade(t)
|
2021-12-08 17:11:19 +00:00
|
|
|
ts, err := n.ChainHead(ctx)
|
|
|
|
require.NoError(t, err)
|
|
|
|
start := ts.Height()
|
|
|
|
// wait for a full proving period
|
2022-01-09 03:23:22 +00:00
|
|
|
t.Log("waiting for chain")
|
|
|
|
|
2021-12-08 17:11:19 +00:00
|
|
|
n.WaitTillChain(ctx, func(ts *types.TipSet) bool {
|
|
|
|
if ts.Height() > start+abi.ChainEpoch(2880) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|