2022-08-29 14:25:30 +00:00
|
|
|
// stm: #unit
|
2020-11-26 16:58:03 +00:00
|
|
|
package splitstore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2022-06-15 10:06:22 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
2020-11-26 16:58:03 +00:00
|
|
|
"github.com/multiformats/go-multihash"
|
|
|
|
)
|
|
|
|
|
2021-07-07 13:39:37 +00:00
|
|
|
func TestMapMarkSet(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: @SPLITSTORE_MARKSET_CREATE_001, @SPLITSTORE_MARKSET_HAS_001, @@SPLITSTORE_MARKSET_MARK_001
|
|
|
|
//stm: @SPLITSTORE_MARKSET_CLOSE_001, @SPLITSTORE_MARKSET_CREATE_VISITOR_001
|
2021-07-07 13:39:37 +00:00
|
|
|
testMarkSet(t, "map")
|
2022-01-30 09:45:12 +00:00
|
|
|
testMarkSetRecovery(t, "map")
|
|
|
|
testMarkSetMarkMany(t, "map")
|
2021-07-30 06:42:20 +00:00
|
|
|
testMarkSetVisitor(t, "map")
|
2022-01-30 09:45:12 +00:00
|
|
|
testMarkSetVisitorRecovery(t, "map")
|
2021-02-27 10:50:48 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 09:16:44 +00:00
|
|
|
func TestBadgerMarkSet(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: @SPLITSTORE_MARKSET_CREATE_001, @SPLITSTORE_MARKSET_HAS_001, @@SPLITSTORE_MARKSET_MARK_001
|
|
|
|
//stm: @SPLITSTORE_MARKSET_CLOSE_001, @SPLITSTORE_MARKSET_CREATE_VISITOR_001
|
2021-07-22 09:16:44 +00:00
|
|
|
bs := badgerMarkSetBatchSize
|
|
|
|
badgerMarkSetBatchSize = 1
|
|
|
|
t.Cleanup(func() {
|
|
|
|
badgerMarkSetBatchSize = bs
|
|
|
|
})
|
|
|
|
testMarkSet(t, "badger")
|
2022-01-30 09:45:12 +00:00
|
|
|
testMarkSetRecovery(t, "badger")
|
|
|
|
testMarkSetMarkMany(t, "badger")
|
2021-07-30 06:42:20 +00:00
|
|
|
testMarkSetVisitor(t, "badger")
|
2022-01-30 09:45:12 +00:00
|
|
|
testMarkSetVisitorRecovery(t, "badger")
|
2021-07-22 09:16:44 +00:00
|
|
|
}
|
|
|
|
|
2021-03-02 00:47:21 +00:00
|
|
|
func testMarkSet(t *testing.T, lsType string) {
|
2022-03-11 06:27:36 +00:00
|
|
|
path := t.TempDir()
|
2021-07-30 06:42:20 +00:00
|
|
|
|
2021-03-02 00:47:21 +00:00
|
|
|
env, err := OpenMarkSetEnv(path, lsType)
|
2020-11-26 16:58:03 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2021-02-27 10:50:48 +00:00
|
|
|
defer env.Close() //nolint:errcheck
|
2020-11-26 16:58:03 +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: @SPLITSTORE_MARKSET_CREATE_001
|
2022-01-28 13:41:33 +00:00
|
|
|
hotSet, err := env.New("hot", 0)
|
2020-11-26 16:58:03 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-01-28 13:41:33 +00:00
|
|
|
coldSet, err := env.New("cold", 0)
|
2020-11-26 16:58:03 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
makeCid := func(key string) cid.Cid {
|
|
|
|
h, err := multihash.Sum([]byte(key), multihash.SHA2_256, -1)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return cid.NewCidV1(cid.Raw, h)
|
|
|
|
}
|
|
|
|
|
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: @SPLITSTORE_MARKSET_HAS_001
|
2021-03-02 00:47:21 +00:00
|
|
|
mustHave := func(s MarkSet, cid cid.Cid) {
|
2022-01-30 09:45:12 +00:00
|
|
|
t.Helper()
|
2020-11-26 16:58:03 +00:00
|
|
|
has, err := s.Has(cid)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !has {
|
|
|
|
t.Fatal("mark not found")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-02 00:47:21 +00:00
|
|
|
mustNotHave := func(s MarkSet, cid cid.Cid) {
|
2022-01-30 09:45:12 +00:00
|
|
|
t.Helper()
|
2020-11-26 16:58:03 +00:00
|
|
|
has, err := s.Has(cid)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if has {
|
|
|
|
t.Fatal("unexpected mark")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
k1 := makeCid("a")
|
|
|
|
k2 := makeCid("b")
|
|
|
|
k3 := makeCid("c")
|
|
|
|
k4 := makeCid("d")
|
|
|
|
|
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: @SPLITSTORE_MARKSET_MARK_001
|
2020-11-26 17:47:54 +00:00
|
|
|
hotSet.Mark(k1) //nolint
|
|
|
|
hotSet.Mark(k2) //nolint
|
|
|
|
coldSet.Mark(k3) //nolint
|
2020-11-26 16:58:03 +00:00
|
|
|
|
|
|
|
mustHave(hotSet, k1)
|
|
|
|
mustHave(hotSet, k2)
|
|
|
|
mustNotHave(hotSet, k3)
|
|
|
|
mustNotHave(hotSet, k4)
|
|
|
|
|
|
|
|
mustNotHave(coldSet, k1)
|
|
|
|
mustNotHave(coldSet, k2)
|
|
|
|
mustHave(coldSet, k3)
|
|
|
|
mustNotHave(coldSet, k4)
|
|
|
|
|
|
|
|
// close them and reopen to redo the dance
|
|
|
|
|
|
|
|
err = hotSet.Close()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = coldSet.Close()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-01-28 13:41:33 +00:00
|
|
|
hotSet, err = env.New("hot", 0)
|
2020-11-26 16:58:03 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-01-28 13:41:33 +00:00
|
|
|
coldSet, err = env.New("cold", 0)
|
2020-11-26 16:58:03 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-11-26 17:47:54 +00:00
|
|
|
hotSet.Mark(k3) //nolint
|
|
|
|
hotSet.Mark(k4) //nolint
|
|
|
|
coldSet.Mark(k1) //nolint
|
2020-11-26 16:58:03 +00:00
|
|
|
|
|
|
|
mustNotHave(hotSet, k1)
|
|
|
|
mustNotHave(hotSet, k2)
|
|
|
|
mustHave(hotSet, k3)
|
|
|
|
mustHave(hotSet, k4)
|
|
|
|
|
|
|
|
mustHave(coldSet, k1)
|
|
|
|
mustNotHave(coldSet, k2)
|
|
|
|
mustNotHave(coldSet, k3)
|
|
|
|
mustNotHave(coldSet, k4)
|
|
|
|
|
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: @SPLITSTORE_MARKSET_CLOSE_001
|
2020-11-26 16:58:03 +00:00
|
|
|
err = hotSet.Close()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = coldSet.Close()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
2021-07-30 06:42:20 +00:00
|
|
|
|
|
|
|
func testMarkSetVisitor(t *testing.T, lsType string) {
|
2022-03-11 06:27:36 +00:00
|
|
|
path := t.TempDir()
|
2021-07-30 06:42:20 +00:00
|
|
|
|
|
|
|
env, err := OpenMarkSetEnv(path, lsType)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
defer env.Close() //nolint:errcheck
|
|
|
|
|
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: @SPLITSTORE_MARKSET_CREATE_VISITOR_001
|
2022-01-28 13:41:33 +00:00
|
|
|
visitor, err := env.New("test", 0)
|
2021-07-30 06:42:20 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
defer visitor.Close() //nolint:errcheck
|
|
|
|
|
|
|
|
makeCid := func(key string) cid.Cid {
|
|
|
|
h, err := multihash.Sum([]byte(key), multihash.SHA2_256, -1)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return cid.NewCidV1(cid.Raw, h)
|
|
|
|
}
|
|
|
|
|
|
|
|
mustVisit := func(v ObjectVisitor, cid cid.Cid) {
|
|
|
|
visit, err := v.Visit(cid)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !visit {
|
|
|
|
t.Fatal("object should be visited")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mustNotVisit := func(v ObjectVisitor, cid cid.Cid) {
|
|
|
|
visit, err := v.Visit(cid)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if visit {
|
|
|
|
t.Fatal("unexpected visit")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
k1 := makeCid("a")
|
|
|
|
k2 := makeCid("b")
|
|
|
|
k3 := makeCid("c")
|
|
|
|
k4 := makeCid("d")
|
|
|
|
|
|
|
|
mustVisit(visitor, k1)
|
|
|
|
mustVisit(visitor, k2)
|
|
|
|
mustVisit(visitor, k3)
|
|
|
|
mustVisit(visitor, k4)
|
|
|
|
|
|
|
|
mustNotVisit(visitor, k1)
|
|
|
|
mustNotVisit(visitor, k2)
|
|
|
|
mustNotVisit(visitor, k3)
|
|
|
|
mustNotVisit(visitor, k4)
|
|
|
|
}
|
2022-01-28 13:49:41 +00:00
|
|
|
|
2022-01-30 09:45:12 +00:00
|
|
|
func testMarkSetVisitorRecovery(t *testing.T, lsType string) {
|
2022-03-11 06:27:36 +00:00
|
|
|
path := t.TempDir()
|
2022-01-28 13:49:41 +00:00
|
|
|
|
|
|
|
env, err := OpenMarkSetEnv(path, lsType)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
defer env.Close() //nolint:errcheck
|
|
|
|
|
|
|
|
visitor, err := env.New("test", 0)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
defer visitor.Close() //nolint:errcheck
|
|
|
|
|
|
|
|
makeCid := func(key string) cid.Cid {
|
|
|
|
h, err := multihash.Sum([]byte(key), multihash.SHA2_256, -1)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return cid.NewCidV1(cid.Raw, h)
|
|
|
|
}
|
|
|
|
|
|
|
|
mustVisit := func(v ObjectVisitor, cid cid.Cid) {
|
|
|
|
visit, err := v.Visit(cid)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !visit {
|
|
|
|
t.Fatal("object should be visited")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mustNotVisit := func(v ObjectVisitor, cid cid.Cid) {
|
|
|
|
visit, err := v.Visit(cid)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if visit {
|
|
|
|
t.Fatal("unexpected visit")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
k1 := makeCid("a")
|
|
|
|
k2 := makeCid("b")
|
|
|
|
k3 := makeCid("c")
|
|
|
|
k4 := makeCid("d")
|
|
|
|
|
2022-01-28 13:55:34 +00:00
|
|
|
mustVisit(visitor, k1)
|
|
|
|
mustVisit(visitor, k2)
|
|
|
|
|
2022-01-28 13:49:41 +00:00
|
|
|
if err := visitor.BeginCriticalSection(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
mustVisit(visitor, k3)
|
|
|
|
mustVisit(visitor, k4)
|
|
|
|
|
|
|
|
mustNotVisit(visitor, k1)
|
|
|
|
mustNotVisit(visitor, k2)
|
|
|
|
mustNotVisit(visitor, k3)
|
|
|
|
mustNotVisit(visitor, k4)
|
|
|
|
|
|
|
|
if err := visitor.Close(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
visitor, err = env.Recover("test")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
mustNotVisit(visitor, k1)
|
|
|
|
mustNotVisit(visitor, k2)
|
|
|
|
mustNotVisit(visitor, k3)
|
|
|
|
mustNotVisit(visitor, k4)
|
|
|
|
|
|
|
|
visitor.EndCriticalSection()
|
2022-01-30 09:45:12 +00:00
|
|
|
|
|
|
|
if err := visitor.Close(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-01-30 13:43:52 +00:00
|
|
|
_, err = env.Recover("test")
|
2022-01-30 09:45:12 +00:00
|
|
|
if err == nil {
|
|
|
|
t.Fatal("expected recovery to fail")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func testMarkSetRecovery(t *testing.T, lsType string) {
|
2022-03-11 06:27:36 +00:00
|
|
|
path := t.TempDir()
|
2022-01-30 09:45:12 +00:00
|
|
|
|
|
|
|
env, err := OpenMarkSetEnv(path, lsType)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
defer env.Close() //nolint:errcheck
|
|
|
|
|
|
|
|
markSet, err := env.New("test", 0)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
makeCid := func(key string) cid.Cid {
|
|
|
|
h, err := multihash.Sum([]byte(key), multihash.SHA2_256, -1)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return cid.NewCidV1(cid.Raw, h)
|
|
|
|
}
|
|
|
|
|
|
|
|
mustHave := func(s MarkSet, cid cid.Cid) {
|
|
|
|
t.Helper()
|
|
|
|
has, err := s.Has(cid)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !has {
|
|
|
|
t.Fatal("mark not found")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mustNotHave := func(s MarkSet, cid cid.Cid) {
|
|
|
|
t.Helper()
|
|
|
|
has, err := s.Has(cid)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if has {
|
|
|
|
t.Fatal("unexpected mark")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
k1 := makeCid("a")
|
|
|
|
k2 := makeCid("b")
|
|
|
|
k3 := makeCid("c")
|
|
|
|
k4 := makeCid("d")
|
|
|
|
|
|
|
|
if err := markSet.Mark(k1); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if err := markSet.Mark(k2); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
mustHave(markSet, k1)
|
|
|
|
mustHave(markSet, k2)
|
|
|
|
mustNotHave(markSet, k3)
|
|
|
|
mustNotHave(markSet, k4)
|
|
|
|
|
|
|
|
if err := markSet.BeginCriticalSection(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := markSet.Mark(k3); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if err := markSet.Mark(k4); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
mustHave(markSet, k1)
|
|
|
|
mustHave(markSet, k2)
|
|
|
|
mustHave(markSet, k3)
|
|
|
|
mustHave(markSet, k4)
|
|
|
|
|
|
|
|
if err := markSet.Close(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
markSet, err = env.Recover("test")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
mustHave(markSet, k1)
|
|
|
|
mustHave(markSet, k2)
|
|
|
|
mustHave(markSet, k3)
|
|
|
|
mustHave(markSet, k4)
|
|
|
|
|
|
|
|
markSet.EndCriticalSection()
|
|
|
|
|
|
|
|
if err := markSet.Close(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-01-30 13:43:52 +00:00
|
|
|
_, err = env.Recover("test")
|
2022-01-30 09:45:12 +00:00
|
|
|
if err == nil {
|
|
|
|
t.Fatal("expected recovery to fail")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func testMarkSetMarkMany(t *testing.T, lsType string) {
|
2022-03-11 06:27:36 +00:00
|
|
|
path := t.TempDir()
|
2022-01-30 09:45:12 +00:00
|
|
|
|
|
|
|
env, err := OpenMarkSetEnv(path, lsType)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
defer env.Close() //nolint:errcheck
|
|
|
|
|
|
|
|
markSet, err := env.New("test", 0)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
makeCid := func(key string) cid.Cid {
|
|
|
|
h, err := multihash.Sum([]byte(key), multihash.SHA2_256, -1)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return cid.NewCidV1(cid.Raw, h)
|
|
|
|
}
|
|
|
|
|
|
|
|
mustHave := func(s MarkSet, cid cid.Cid) {
|
|
|
|
t.Helper()
|
|
|
|
has, err := s.Has(cid)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !has {
|
|
|
|
t.Fatal("mark not found")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mustNotHave := func(s MarkSet, cid cid.Cid) {
|
|
|
|
t.Helper()
|
|
|
|
has, err := s.Has(cid)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if has {
|
|
|
|
t.Fatal("unexpected mark")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
k1 := makeCid("a")
|
|
|
|
k2 := makeCid("b")
|
|
|
|
k3 := makeCid("c")
|
|
|
|
k4 := makeCid("d")
|
|
|
|
|
|
|
|
if err := markSet.MarkMany([]cid.Cid{k1, k2}); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
mustHave(markSet, k1)
|
|
|
|
mustHave(markSet, k2)
|
|
|
|
mustNotHave(markSet, k3)
|
|
|
|
mustNotHave(markSet, k4)
|
|
|
|
|
|
|
|
if err := markSet.BeginCriticalSection(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := markSet.MarkMany([]cid.Cid{k3, k4}); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
mustHave(markSet, k1)
|
|
|
|
mustHave(markSet, k2)
|
|
|
|
mustHave(markSet, k3)
|
|
|
|
mustHave(markSet, k4)
|
|
|
|
|
|
|
|
if err := markSet.Close(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
markSet, err = env.Recover("test")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
mustHave(markSet, k1)
|
|
|
|
mustHave(markSet, k2)
|
|
|
|
mustHave(markSet, k3)
|
|
|
|
mustHave(markSet, k4)
|
|
|
|
|
|
|
|
markSet.EndCriticalSection()
|
|
|
|
|
|
|
|
if err := markSet.Close(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-01-30 13:43:52 +00:00
|
|
|
_, err = env.Recover("test")
|
2022-01-30 09:45:12 +00:00
|
|
|
if err == nil {
|
|
|
|
t.Fatal("expected recovery to fail")
|
|
|
|
}
|
2022-01-28 13:49:41 +00:00
|
|
|
}
|