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: #unit
|
2020-09-09 13:01:37 +00:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
2021-11-04 15:59:29 +00:00
|
|
|
proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof"
|
|
|
|
|
2021-05-31 23:28:49 +00:00
|
|
|
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
|
|
|
|
miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner"
|
|
|
|
|
2020-09-09 13:01:37 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2021-01-22 21:02:54 +00:00
|
|
|
"golang.org/x/xerrors"
|
2020-09-09 13:01:37 +00:00
|
|
|
|
|
|
|
"github.com/ipfs/go-cid"
|
|
|
|
|
2020-09-21 07:52:57 +00:00
|
|
|
"github.com/filecoin-project/go-address"
|
|
|
|
"github.com/filecoin-project/go-bitfield"
|
2020-11-05 05:52:51 +00:00
|
|
|
"github.com/filecoin-project/specs-storage/storage"
|
2020-09-18 16:03:59 +00:00
|
|
|
|
2020-09-09 13:01:37 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
2020-09-21 07:52:57 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/big"
|
2020-09-09 13:01:37 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/crypto"
|
2020-09-21 07:52:57 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/dline"
|
2020-10-28 14:10:43 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/network"
|
2020-09-21 07:52:57 +00:00
|
|
|
"github.com/filecoin-project/lotus/api"
|
2020-10-28 14:10:43 +00:00
|
|
|
"github.com/filecoin-project/lotus/build"
|
2020-09-18 18:34:23 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
2021-06-16 23:39:23 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/actors/policy"
|
2020-09-21 07:52:57 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
2020-12-01 23:35:55 +00:00
|
|
|
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
2020-10-09 19:52:04 +00:00
|
|
|
"github.com/filecoin-project/lotus/journal"
|
2021-11-04 15:59:29 +00:00
|
|
|
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
|
|
|
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
|
|
|
proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof"
|
|
|
|
tutils "github.com/filecoin-project/specs-actors/v2/support/testing"
|
2020-09-09 13:01:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type mockStorageMinerAPI struct {
|
2020-09-18 18:34:23 +00:00
|
|
|
partitions []api.Partition
|
2020-09-09 13:01:37 +00:00
|
|
|
pushedMessages chan *types.Message
|
2021-05-13 13:36:16 +00:00
|
|
|
fullNodeFilteredAPI
|
2020-09-09 13:01:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func newMockStorageMinerAPI() *mockStorageMinerAPI {
|
|
|
|
return &mockStorageMinerAPI{
|
|
|
|
pushedMessages: make(chan *types.Message),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-18 18:34:23 +00:00
|
|
|
func (m *mockStorageMinerAPI) StateMinerInfo(ctx context.Context, a address.Address, key types.TipSetKey) (miner.MinerInfo, error) {
|
2020-09-21 07:52:57 +00:00
|
|
|
return miner.MinerInfo{
|
|
|
|
Worker: tutils.NewIDAddr(nil, 101),
|
|
|
|
Owner: tutils.NewIDAddr(nil, 101),
|
|
|
|
}, nil
|
2020-09-18 18:34:23 +00:00
|
|
|
}
|
|
|
|
|
2020-10-07 17:41:07 +00:00
|
|
|
func (m *mockStorageMinerAPI) StateNetworkVersion(ctx context.Context, key types.TipSetKey) (network.Version, error) {
|
|
|
|
return build.NewestNetworkVersion, nil
|
|
|
|
}
|
|
|
|
|
2021-09-12 02:24:53 +00:00
|
|
|
func (m *mockStorageMinerAPI) StateGetRandomnessFromTickets(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error) {
|
2020-09-09 13:01:37 +00:00
|
|
|
return abi.Randomness("ticket rand"), nil
|
|
|
|
}
|
|
|
|
|
2021-09-12 02:24:53 +00:00
|
|
|
func (m *mockStorageMinerAPI) StateGetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error) {
|
2020-09-09 13:01:37 +00:00
|
|
|
return abi.Randomness("beacon rand"), nil
|
|
|
|
}
|
|
|
|
|
2020-09-18 18:34:23 +00:00
|
|
|
func (m *mockStorageMinerAPI) setPartitions(ps []api.Partition) {
|
2020-09-09 13:01:37 +00:00
|
|
|
m.partitions = append(m.partitions, ps...)
|
|
|
|
}
|
|
|
|
|
2020-09-18 18:34:23 +00:00
|
|
|
func (m *mockStorageMinerAPI) StateMinerPartitions(ctx context.Context, a address.Address, dlIdx uint64, tsk types.TipSetKey) ([]api.Partition, error) {
|
2020-09-09 13:01:37 +00:00
|
|
|
return m.partitions, nil
|
|
|
|
}
|
|
|
|
|
2020-09-21 19:05:01 +00:00
|
|
|
func (m *mockStorageMinerAPI) StateMinerSectors(ctx context.Context, address address.Address, snos *bitfield.BitField, key types.TipSetKey) ([]*miner.SectorOnChainInfo, error) {
|
|
|
|
var sis []*miner.SectorOnChainInfo
|
|
|
|
if snos == nil {
|
|
|
|
panic("unsupported")
|
|
|
|
}
|
|
|
|
_ = snos.ForEach(func(i uint64) error {
|
|
|
|
sis = append(sis, &miner.SectorOnChainInfo{
|
|
|
|
SectorNumber: abi.SectorNumber(i),
|
2020-09-09 13:01:37 +00:00
|
|
|
})
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
return sis, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) MpoolPushMessage(ctx context.Context, message *types.Message, spec *api.MessageSendSpec) (*types.SignedMessage, error) {
|
|
|
|
m.pushedMessages <- message
|
|
|
|
return &types.SignedMessage{
|
|
|
|
Message: *message,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2021-04-05 19:34:03 +00:00
|
|
|
func (m *mockStorageMinerAPI) StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error) {
|
2020-09-09 13:01:37 +00:00
|
|
|
return &api.MsgLookup{
|
|
|
|
Receipt: types.MessageReceipt{
|
|
|
|
ExitCode: 0,
|
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2020-11-19 17:57:43 +00:00
|
|
|
func (m *mockStorageMinerAPI) GasEstimateGasPremium(_ context.Context, nblocksincl uint64, sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error) {
|
|
|
|
return big.Zero(), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) GasEstimateFeeCap(context.Context, *types.Message, int64, types.TipSetKey) (types.BigInt, error) {
|
|
|
|
return big.Zero(), nil
|
|
|
|
}
|
|
|
|
|
2020-09-09 13:01:37 +00:00
|
|
|
type mockProver struct {
|
|
|
|
}
|
|
|
|
|
2021-12-08 17:11:19 +00:00
|
|
|
func (m *mockProver) GenerateWinningPoSt(context.Context, abi.ActorID, []proof7.ExtendedSectorInfo, abi.PoStRandomness) ([]proof2.PoStProof, error) {
|
2020-09-09 13:01:37 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2021-12-08 17:11:19 +00:00
|
|
|
func (m *mockProver) GenerateWindowPoSt(ctx context.Context, aid abi.ActorID, sis []proof7.ExtendedSectorInfo, pr abi.PoStRandomness) ([]proof2.PoStProof, []abi.SectorID, error) {
|
2020-10-08 01:09:33 +00:00
|
|
|
return []proof2.PoStProof{
|
2020-09-09 13:01:37 +00:00
|
|
|
{
|
|
|
|
PoStProof: abi.RegisteredPoStProof_StackedDrgWindow2KiBV1,
|
|
|
|
ProofBytes: []byte("post-proof"),
|
|
|
|
},
|
|
|
|
}, nil, nil
|
|
|
|
}
|
|
|
|
|
2021-01-22 21:02:54 +00:00
|
|
|
type mockVerif struct {
|
|
|
|
}
|
|
|
|
|
2022-01-11 16:53:14 +00:00
|
|
|
func (m mockVerif) VerifyWinningPoSt(ctx context.Context, info proof7.WinningPoStVerifyInfo) (bool, error) {
|
2021-01-22 21:02:54 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m mockVerif) VerifyWindowPoSt(ctx context.Context, info proof2.WindowPoStVerifyInfo) (bool, error) {
|
|
|
|
if len(info.Proofs) != 1 {
|
|
|
|
return false, xerrors.Errorf("expected 1 proof entry")
|
|
|
|
}
|
|
|
|
|
|
|
|
proof := info.Proofs[0]
|
|
|
|
|
|
|
|
if !bytes.Equal(proof.ProofBytes, []byte("post-proof")) {
|
|
|
|
return false, xerrors.Errorf("bad proof")
|
|
|
|
}
|
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
|
2021-11-04 15:59:29 +00:00
|
|
|
func (m mockVerif) VerifyAggregateSeals(aggregate proof7.AggregateSealVerifyProofAndInfos) (bool, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m mockVerif) VerifyReplicaUpdate(update proof7.ReplicaUpdateInfo) (bool, error) {
|
2021-05-17 18:47:41 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2021-01-22 21:02:54 +00:00
|
|
|
func (m mockVerif) VerifySeal(proof2.SealVerifyInfo) (bool, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m mockVerif) GenerateWinningPoStSectorChallenge(context.Context, abi.RegisteredPoStProof, abi.ActorID, abi.PoStRandomness, uint64) ([]uint64, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2020-09-09 13:01:37 +00:00
|
|
|
type mockFaultTracker struct {
|
|
|
|
}
|
|
|
|
|
2022-02-23 16:56:47 +00:00
|
|
|
func (m mockFaultTracker) CheckProvable(ctx context.Context, pp abi.RegisteredPoStProof, sectors []storage.SectorRef, update []bool, rg storiface.RGetter) (map[abi.SectorID]string, error) {
|
2020-12-01 13:50:51 +00:00
|
|
|
// Returns "bad" sectors so just return empty map meaning all sectors are good
|
2020-11-27 15:34:41 +00:00
|
|
|
return map[abi.SectorID]string{}, nil
|
2020-09-09 13:01:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TestWDPostDoPost verifies that doPost will send the correct number of window
|
|
|
|
// PoST messages for a given number of partitions
|
|
|
|
func TestWDPostDoPost(t *testing.T) {
|
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: @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
|
2020-09-09 13:01:37 +00:00
|
|
|
ctx := context.Background()
|
|
|
|
expectedMsgCount := 5
|
|
|
|
|
|
|
|
proofType := abi.RegisteredPoStProof_StackedDrgWindow2KiBV1
|
|
|
|
postAct := tutils.NewIDAddr(t, 100)
|
|
|
|
|
|
|
|
mockStgMinerAPI := newMockStorageMinerAPI()
|
|
|
|
|
|
|
|
// Get the number of sectors allowed in a partition for this proof type
|
2021-05-31 23:28:49 +00:00
|
|
|
sectorsPerPartition, err := builtin5.PoStProofWindowPoStPartitionSectors(proofType)
|
2020-09-09 13:01:37 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
// Work out the number of partitions that can be included in a message
|
|
|
|
// without exceeding the message sector limit
|
2020-09-18 18:34:23 +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: @BLOCKCHAIN_POLICY_GET_MAX_POST_PARTITIONS_001
|
2021-06-16 23:39:23 +00:00
|
|
|
partitionsPerMsg, err := policy.GetMaxPoStPartitions(network.Version13, proofType)
|
2020-09-18 18:34:23 +00:00
|
|
|
require.NoError(t, err)
|
2021-05-31 23:28:49 +00:00
|
|
|
if partitionsPerMsg > miner5.AddressedPartitionsMax {
|
|
|
|
partitionsPerMsg = miner5.AddressedPartitionsMax
|
|
|
|
}
|
2020-09-09 13:01:37 +00:00
|
|
|
|
|
|
|
// Enough partitions to fill expectedMsgCount-1 messages
|
|
|
|
partitionCount := (expectedMsgCount - 1) * partitionsPerMsg
|
|
|
|
// Add an extra partition that should be included in the last message
|
|
|
|
partitionCount++
|
|
|
|
|
2020-09-18 18:34:23 +00:00
|
|
|
var partitions []api.Partition
|
2020-09-09 13:01:37 +00:00
|
|
|
for p := 0; p < partitionCount; p++ {
|
|
|
|
sectors := bitfield.New()
|
|
|
|
for s := uint64(0); s < sectorsPerPartition; s++ {
|
|
|
|
sectors.Set(s)
|
|
|
|
}
|
2020-09-18 18:34:23 +00:00
|
|
|
partitions = append(partitions, api.Partition{
|
|
|
|
AllSectors: sectors,
|
|
|
|
FaultySectors: bitfield.New(),
|
|
|
|
RecoveringSectors: bitfield.New(),
|
|
|
|
LiveSectors: sectors,
|
|
|
|
ActiveSectors: sectors,
|
2020-09-09 13:01:37 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
mockStgMinerAPI.setPartitions(partitions)
|
|
|
|
|
|
|
|
// Run window PoST
|
|
|
|
scheduler := &WindowPoStScheduler{
|
|
|
|
api: mockStgMinerAPI,
|
|
|
|
prover: &mockProver{},
|
2021-01-22 21:02:54 +00:00
|
|
|
verifier: &mockVerif{},
|
2020-09-09 13:01:37 +00:00
|
|
|
faultTracker: &mockFaultTracker{},
|
|
|
|
proofType: proofType,
|
|
|
|
actor: postAct,
|
2020-10-09 19:52:04 +00:00
|
|
|
journal: journal.NilJournal(),
|
2020-12-03 11:37:11 +00:00
|
|
|
addrSel: &AddressSelector{},
|
2020-09-09 13:01:37 +00:00
|
|
|
}
|
|
|
|
|
2020-09-21 07:52:57 +00:00
|
|
|
di := &dline.Info{
|
2021-05-31 23:28:49 +00:00
|
|
|
WPoStPeriodDeadlines: miner5.WPoStPeriodDeadlines,
|
|
|
|
WPoStProvingPeriod: miner5.WPoStProvingPeriod,
|
|
|
|
WPoStChallengeWindow: miner5.WPoStChallengeWindow,
|
|
|
|
WPoStChallengeLookback: miner5.WPoStChallengeLookback,
|
|
|
|
FaultDeclarationCutoff: miner5.FaultDeclarationCutoff,
|
2020-09-21 07:52:57 +00:00
|
|
|
}
|
2020-09-09 13:01:37 +00:00
|
|
|
ts := mockTipSet(t)
|
2020-09-18 16:03:59 +00:00
|
|
|
|
|
|
|
scheduler.startGeneratePoST(ctx, ts, di, func(posts []miner.SubmitWindowedPoStParams, err error) {
|
|
|
|
scheduler.startSubmitPoST(ctx, ts, di, posts, func(err error) {})
|
|
|
|
})
|
2020-09-09 13:01:37 +00:00
|
|
|
|
|
|
|
// Read the window PoST messages
|
|
|
|
for i := 0; i < expectedMsgCount; i++ {
|
|
|
|
msg := <-mockStgMinerAPI.pushedMessages
|
2020-10-08 20:32:54 +00:00
|
|
|
require.Equal(t, miner.Methods.SubmitWindowedPoSt, msg.Method)
|
2020-09-09 13:01:37 +00:00
|
|
|
var params miner.SubmitWindowedPoStParams
|
|
|
|
err := params.UnmarshalCBOR(bytes.NewReader(msg.Params))
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
if i == expectedMsgCount-1 {
|
|
|
|
// In the last message we only included a single partition (see above)
|
|
|
|
require.Len(t, params.Partitions, 1)
|
|
|
|
} else {
|
|
|
|
// All previous messages should include the full number of partitions
|
|
|
|
require.Len(t, params.Partitions, partitionsPerMsg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func mockTipSet(t *testing.T) *types.TipSet {
|
|
|
|
minerAct := tutils.NewActorAddr(t, "miner")
|
|
|
|
c, err := cid.Decode("QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH")
|
|
|
|
require.NoError(t, err)
|
|
|
|
blks := []*types.BlockHeader{
|
|
|
|
{
|
|
|
|
Miner: minerAct,
|
|
|
|
Height: abi.ChainEpoch(1),
|
|
|
|
ParentStateRoot: c,
|
|
|
|
ParentMessageReceipts: c,
|
|
|
|
Messages: c,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
ts, err := types.NewTipSet(blks)
|
|
|
|
require.NoError(t, err)
|
|
|
|
return ts
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// All the mock methods below here are unused
|
|
|
|
//
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) StateCall(ctx context.Context, message *types.Message, key types.TipSetKey) (*api.InvocResult, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2020-09-18 18:34:23 +00:00
|
|
|
func (m *mockStorageMinerAPI) StateMinerDeadlines(ctx context.Context, maddr address.Address, tok types.TipSetKey) ([]api.Deadline, error) {
|
2020-09-09 13:01:37 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) StateSectorPreCommitInfo(ctx context.Context, address address.Address, number abi.SectorNumber, key types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) StateSectorGetInfo(ctx context.Context, address address.Address, number abi.SectorNumber, key types.TipSetKey) (*miner.SectorOnChainInfo, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2020-09-18 18:34:23 +00:00
|
|
|
func (m *mockStorageMinerAPI) StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorLocation, error) {
|
2020-09-09 13:01:37 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) StateMinerProvingDeadline(ctx context.Context, address address.Address, key types.TipSetKey) (*dline.Info, error) {
|
2020-09-21 07:52:57 +00:00
|
|
|
return &dline.Info{
|
|
|
|
CurrentEpoch: 0,
|
|
|
|
PeriodStart: 0,
|
|
|
|
Index: 0,
|
|
|
|
Open: 0,
|
|
|
|
Close: 0,
|
|
|
|
Challenge: 0,
|
|
|
|
FaultCutoff: 0,
|
2020-10-08 01:09:33 +00:00
|
|
|
WPoStPeriodDeadlines: miner2.WPoStPeriodDeadlines,
|
|
|
|
WPoStProvingPeriod: miner2.WPoStProvingPeriod,
|
|
|
|
WPoStChallengeWindow: miner2.WPoStChallengeWindow,
|
|
|
|
WPoStChallengeLookback: miner2.WPoStChallengeLookback,
|
|
|
|
FaultDeclarationCutoff: miner2.FaultDeclarationCutoff,
|
2020-09-21 07:52:57 +00:00
|
|
|
}, nil
|
2020-09-09 13:01:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) StateMinerPreCommitDepositForPower(ctx context.Context, address address.Address, info miner.SectorPreCommitInfo, key types.TipSetKey) (types.BigInt, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) StateMinerInitialPledgeCollateral(ctx context.Context, address address.Address, info miner.SectorPreCommitInfo, key types.TipSetKey) (types.BigInt, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2021-04-05 19:34:03 +00:00
|
|
|
func (m *mockStorageMinerAPI) StateSearchMsg(ctx context.Context, from types.TipSetKey, msg cid.Cid, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error) {
|
2020-09-09 13:01:37 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) StateGetActor(ctx context.Context, actor address.Address, ts types.TipSetKey) (*types.Actor, error) {
|
2020-09-18 18:34:23 +00:00
|
|
|
return &types.Actor{
|
2020-10-08 01:09:33 +00:00
|
|
|
Code: builtin2.StorageMinerActorCodeID,
|
2020-09-18 18:34:23 +00:00
|
|
|
}, nil
|
2020-09-09 13:01:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) StateGetReceipt(ctx context.Context, cid cid.Cid, key types.TipSetKey) (*types.MessageReceipt, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) StateMarketStorageDeal(ctx context.Context, id abi.DealID, key types.TipSetKey) (*api.MarketDeal, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) StateMinerFaults(ctx context.Context, address address.Address, key types.TipSetKey) (bitfield.BitField, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) StateMinerRecoveries(ctx context.Context, address address.Address, key types.TipSetKey) (bitfield.BitField, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) StateAccountKey(ctx context.Context, address address.Address, key types.TipSetKey) (address.Address, error) {
|
2020-09-21 07:52:57 +00:00
|
|
|
return address, nil
|
2020-09-09 13:01:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) GasEstimateMessageGas(ctx context.Context, message *types.Message, spec *api.MessageSendSpec, key types.TipSetKey) (*types.Message, error) {
|
2020-09-21 07:52:57 +00:00
|
|
|
msg := *message
|
|
|
|
msg.GasFeeCap = big.NewInt(1)
|
|
|
|
msg.GasPremium = big.NewInt(1)
|
|
|
|
msg.GasLimit = 2
|
|
|
|
return &msg, nil
|
2020-09-09 13:01:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) ChainHead(ctx context.Context) (*types.TipSet, error) {
|
2021-03-10 12:13:03 +00:00
|
|
|
return nil, nil
|
2020-09-09 13:01:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) ChainNotify(ctx context.Context) (<-chan []*api.HeadChange, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) ChainGetTipSetByHeight(ctx context.Context, epoch abi.ChainEpoch, key types.TipSetKey) (*types.TipSet, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) ChainGetBlockMessages(ctx context.Context, cid cid.Cid) (*api.BlockMessages, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) ChainReadObj(ctx context.Context, cid cid.Cid) ([]byte, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) ChainHasObj(ctx context.Context, cid cid.Cid) (bool, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) ChainGetTipSet(ctx context.Context, key types.TipSetKey) (*types.TipSet, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) WalletSign(ctx context.Context, address address.Address, bytes []byte) (*crypto.Signature, error) {
|
2020-09-21 07:52:57 +00:00
|
|
|
return nil, nil
|
2020-09-09 13:01:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) WalletBalance(ctx context.Context, address address.Address) (types.BigInt, error) {
|
2020-09-21 07:52:57 +00:00
|
|
|
return big.NewInt(333), nil
|
2020-09-09 13:01:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockStorageMinerAPI) WalletHas(ctx context.Context, address address.Address) (bool, error) {
|
2020-09-21 07:52:57 +00:00
|
|
|
return true, nil
|
2020-09-09 13:01:37 +00:00
|
|
|
}
|
2020-09-18 18:34:23 +00:00
|
|
|
|
2021-05-13 13:36:16 +00:00
|
|
|
var _ fullNodeFilteredAPI = &mockStorageMinerAPI{}
|