Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: Fix t.Parallel() errors in data package #4981

Merged
merged 25 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
759127c
Fix paralleltest errors in `data/accountManager_test.go`
jdtzmn Dec 15, 2022
82fb00b
Fix paralleltest errors in `data/txHandler_test.go`
jdtzmn Dec 21, 2022
9df8d7f
Fix paralleltest errors in `data/basics/fields_test.go`
jdtzmn Jan 3, 2023
1a76b3e
Fix paralleltest errors in `data/basics/address_test.go`
jdtzmn Jan 3, 2023
c4512ba
Fix paralleltest errors in `data/basics/teal_test.go`
jdtzmn Jan 3, 2023
a34e527
Fix paralleltest errors in `data/basics/units_test.go`
jdtzmn Jan 3, 2023
c104f78
Fix paralleltest errors in `data/basics/userBalance_test.go`
jdtzmn Jan 3, 2023
a0dc496
Fix paralleltest errors in `data/committee`
jdtzmn Jan 3, 2023
34fde19
Fix paralleltest errors in `data/pools`
jdtzmn Jan 7, 2023
6a909bd
Fix paralleltest errors in `data/bookkeeping/block_test.go`
jdtzmn Jan 7, 2023
7cac988
Fix paralleltest errors in `data/bookkeeping/encoding_test.go`
jdtzmn Jan 7, 2023
426465e
Fix paralleltest errors in `data/bookkeeping/lightBlockHeader_test.go`
jdtzmn Jan 7, 2023
206a657
Fix paralleltest errors in `data/bookkeeping/txn_merkle_test.go`
jdtzmn Jan 7, 2023
26fe751
Fix paralleltest errors in `data/account/participationRegistry_test.go`
jdtzmn Jan 7, 2023
ce1292e
Fix paralleltest errors in `data/account/participation_test.go`
jdtzmn Jan 7, 2023
643b922
Fix paralleltest errors in `data/transactions/json_test.go`
jdtzmn Jan 7, 2023
d7b207c
Fix paralleltest errors in `data/transactions/application_test.go`
jdtzmn Jan 7, 2023
971af32
Fix paralleltest errors in `data/transactions/verify/txn_test.go`
jdtzmn Jan 8, 2023
0adde13
Fix paralleltest errors in `data/transactions/verify/verifiedTxnCache…
jdtzmn Jan 8, 2023
e8fc594
Fix paralleltest errors in `data/transactions/transaction_test.go`
jdtzmn Jan 8, 2023
ad07a6a
Fix paralleltest errors in `data/transactions/payment_test.go`
jdtzmn Jan 8, 2023
9b609c1
Fix paralleltest errors in `data/transactions/payset_test.go`
jdtzmn Jan 8, 2023
f18b2a4
Fix paralleltest errors in `data/transactions/signedtxn_test.go`
jdtzmn Jan 8, 2023
2463662
Fix paralleltest errors in `data/transactions/teal_test.go`
jdtzmn Jan 8, 2023
1243316
Remove `data` package from paralleltest exclude rules
jdtzmn Jan 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ issues:
- staticcheck
- typecheck
# Ignore missing parallel tests in existing packages
- path: (agreement|catchup|cmd|config|crypto|daemon|data|gen|ledger|logging|netdeploy|network|node|protocol|rpcs|shared|stateproof|test|tools|util).*_test\.go
- path: (agreement|catchup|cmd|config|crypto|daemon|gen|ledger|logging|netdeploy|network|node|protocol|rpcs|shared|stateproof|test|tools|util).*_test\.go
linters:
- paralleltest
# Add all linters here -- Comment this block out for testing linters
Expand Down
44 changes: 36 additions & 8 deletions data/account/participationRegistry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ func registryCloseTest(t testing.TB, registry *participationDB, dbfilePrefix str
// Insert participation records and make sure they can be fetched.
func TestParticipation_InsertGet(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)
Expand Down Expand Up @@ -198,6 +199,7 @@ func TestParticipation_InsertGet(t *testing.T) {
// Insert participation records and make sure they can be fetched.
func TestParticipation_InsertGetWithoutEmptyStateproof(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)
Expand Down Expand Up @@ -238,6 +240,7 @@ func TestParticipation_InsertGetWithoutEmptyStateproof(t *testing.T) {
// Make sure a record can be deleted by id.
func TestParticipation_Delete(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
registry, dbfile := getRegistryImpl(t, false, true) // inMem=false, erasable=true
defer registryCloseTest(t, registry, dbfile)
Expand Down Expand Up @@ -276,6 +279,7 @@ func (m testMessage) ToBeHashed() (protocol.HashID, []byte) {

func TestParticipation_DeleteExpired(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
registry, dbfile := getRegistryImpl(t, false, true) // inMem=false, erasable=true
defer registryCloseTest(t, registry, dbfile)
Expand Down Expand Up @@ -321,6 +325,7 @@ func TestParticipation_DeleteExpired(t *testing.T) {

func TestParticipation_CleanupTablesAfterDeleteExpired(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
registry, dbfile := getRegistryImpl(t, false, true) // inMem=false, erasable=true
defer registryCloseTest(t, registry, dbfile)
Expand Down Expand Up @@ -383,6 +388,7 @@ func TestParticipation_CleanupTablesAfterDeleteExpired(t *testing.T) {
// Make sure the register function properly sets effective first/last for all effected records.
func TestParticipation_Register(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)
Expand Down Expand Up @@ -421,6 +427,7 @@ func TestParticipation_Register(t *testing.T) {
// Test error when registering a non-existing participation ID.
func TestParticipation_RegisterInvalidID(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)
Expand All @@ -434,6 +441,7 @@ func TestParticipation_RegisterInvalidID(t *testing.T) {
// Test error attempting to register a key with an invalid range.
func TestParticipation_RegisterInvalidRange(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)
Expand All @@ -452,6 +460,7 @@ func TestParticipation_RegisterInvalidRange(t *testing.T) {
// Test the recording function.
func TestParticipation_Record(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)
Expand Down Expand Up @@ -506,6 +515,7 @@ func TestParticipation_Record(t *testing.T) {
// Test that attempting to record an invalid action generates an error.
func TestParticipation_RecordInvalidActionAndOutOfRange(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)
Expand All @@ -528,6 +538,7 @@ func TestParticipation_RecordInvalidActionAndOutOfRange(t *testing.T) {

func TestParticipation_RecordNoKey(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)
Expand All @@ -540,6 +551,7 @@ func TestParticipation_RecordNoKey(t *testing.T) {
// This would only happen if the DB was in an inconsistent state.
func TestParticipation_RecordMultipleUpdates(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)
Expand Down Expand Up @@ -590,6 +602,7 @@ func TestParticipation_RecordMultipleUpdates(t *testing.T) {

func TestParticipation_MultipleInsertError(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)
Expand All @@ -609,6 +622,7 @@ func TestParticipation_MultipleInsertError(t *testing.T) {
// it should be detected as quickly as possible.
func TestParticipation_RecordMultipleUpdates_DB(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
registry, _ := getRegistry(t)

Expand Down Expand Up @@ -711,6 +725,7 @@ func TestParticipation_RecordMultipleUpdates_DB(t *testing.T) {

func TestParticipation_NoKeyToUpdate(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := assert.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)
Expand All @@ -734,19 +749,20 @@ func TestParticipation_NoKeyToUpdate(t *testing.T) {
// TestParticipion_Blobs adds some secrets to the registry and makes sure the same ones are returned.
func TestParticipion_Blobs(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)

access, err := db.MakeAccessor("writetest_root", false, true)
access, err := db.MakeAccessor(t.Name()+"_writetest_root", false, true)
if err != nil {
panic(err)
}
root, err := GenerateRoot(access)
access.Close()
a.NoError(err)

access, err = db.MakeAccessor("writetest", false, true)
access, err = db.MakeAccessor(t.Name()+"_writetest", false, true)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -777,19 +793,20 @@ func TestParticipion_Blobs(t *testing.T) {
// TestParticipion_EmptyBlobs makes sure empty blobs are set to nil
func TestParticipion_EmptyBlobs(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := assert.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)

access, err := db.MakeAccessor("writetest_root", false, true)
access, err := db.MakeAccessor(t.Name()+"_writetest_root", false, true)
if err != nil {
panic(err)
}
root, err := GenerateRoot(access)
access.Close()
a.NoError(err)

access, err = db.MakeAccessor("writetest", false, true)
access, err = db.MakeAccessor(t.Name()+"_writetest", false, true)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -821,6 +838,7 @@ func TestParticipion_EmptyBlobs(t *testing.T) {

func TestRegisterUpdatedEvent(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)
Expand Down Expand Up @@ -879,6 +897,7 @@ func TestFlushDeadlock(t *testing.T) {
var wg sync.WaitGroup

partitiontest.PartitionTest(t)
t.Parallel()
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)

Expand Down Expand Up @@ -907,6 +926,7 @@ func TestFlushDeadlock(t *testing.T) {

func TestAddStateProofKeys(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)
Expand Down Expand Up @@ -959,11 +979,12 @@ func TestAddStateProofKeys(t *testing.T) {

func TestGetRoundSecretsWithNilStateProofVerifier(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := assert.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)

access, err := db.MakeAccessor("stateprooftest", false, true)
access, err := db.MakeAccessor(t.Name()+"_stateprooftest", false, true)
if err != nil {
panic(err)
}
Expand All @@ -989,6 +1010,7 @@ func TestGetRoundSecretsWithNilStateProofVerifier(t *testing.T) {

func TestSecretNotFound(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)
Expand All @@ -1008,11 +1030,12 @@ func TestSecretNotFound(t *testing.T) {

func TestAddingSecretTwice(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := assert.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)

access, err := db.MakeAccessor("stateprooftest", false, true)
access, err := db.MakeAccessor(t.Name()+"_stateprooftest", false, true)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -1046,11 +1069,12 @@ func TestAddingSecretTwice(t *testing.T) {

func TestGetRoundSecretsWithoutStateProof(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := assert.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)

access, err := db.MakeAccessor("stateprooftest", false, true)
access, err := db.MakeAccessor(t.Name()+"_stateprooftest", false, true)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -1104,6 +1128,7 @@ func (k keypairs) findPairForSpecificRound(round uint64) merklesignature.KeyRoun

func TestDeleteStateProofKeys(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)
Expand Down Expand Up @@ -1173,11 +1198,12 @@ func TestDeleteStateProofKeys(t *testing.T) {
// test that sets up an error that should come up while flushing, and ensures that flush resets the last error
func TestFlushResetsLastError(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := assert.New(t)
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)

access, err := db.MakeAccessor("stateprooftest", false, true)
access, err := db.MakeAccessor(t.Name()+"_stateprooftest", false, true)
a.NoError(err)

root, err := GenerateRoot(access)
Expand Down Expand Up @@ -1211,6 +1237,7 @@ func TestFlushResetsLastError(t *testing.T) {
// Makes sure the table is not locked for reading while a different one is locked for writing.
func TestParticipationDB_Locking(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)

dbName := strings.Replace(t.Name(), "/", "_", -1)
Expand Down Expand Up @@ -1281,6 +1308,7 @@ func TestParticipationDB_Locking(t *testing.T) {

func TestParticipationDBInstallWhileReading(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)

if testing.Short() {
Expand Down
12 changes: 11 additions & 1 deletion data/account/participation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var partableColumnNames = [...]string{"parent", "vrf", "voting", "stateProof", "

func TestParticipation_NewDB(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()

a := require.New(t)

Expand Down Expand Up @@ -115,6 +116,7 @@ func getSchemaVersions(db db.Accessor) (versions map[string]int, err error) {

func TestOverlapsInterval(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()

const before = basics.Round(95)
const start = basics.Round(100)
Expand Down Expand Up @@ -189,6 +191,7 @@ func BenchmarkOldKeysDeletion(b *testing.B) {

func TestRetrieveFromDB(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)
part, rootDB, partDB, err := setupParticipationKey(t, a)
a.NoError(err)
Expand All @@ -205,6 +208,7 @@ func TestRetrieveFromDB(t *testing.T) {

func TestRetrieveFromDBAtVersion1(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()

a := require.New(t)
ppart := setupkeyWithNoDBS(t, a)
Expand All @@ -227,6 +231,7 @@ func TestRetrieveFromDBAtVersion1(t *testing.T) {

func TestRetrieveFromDBAtVersion2(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()

a := require.New(t)

Expand Down Expand Up @@ -256,6 +261,7 @@ func TestRetrieveFromDBAtVersion2(t *testing.T) {

func TestKeyRegCreation(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()

a := require.New(t)

Expand Down Expand Up @@ -289,6 +295,7 @@ func assertionForRestoringFromDBAtLowVersion(a *require.Assertions, retrivedPart

func TestMigrateFromVersion1(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()

a := require.New(t)
part := setupkeyWithNoDBS(t, a).Participation
Expand All @@ -304,6 +311,7 @@ func TestMigrateFromVersion1(t *testing.T) {

func TestMigrationFromVersion2(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()

a := require.New(t)
part := setupkeyWithNoDBS(t, a).Participation
Expand Down Expand Up @@ -498,6 +506,7 @@ func createMerkleSignatureSchemeTestDB(a *require.Assertions) *db.Accessor {

func TestKeyregValidityOverLimit(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)

maxValidPeriod := config.Consensus[protocol.ConsensusCurrentVersion].MaxKeyregValidPeriod
Expand All @@ -516,6 +525,7 @@ func TestKeyregValidityOverLimit(t *testing.T) {

func TestFillDBWithParticipationKeys(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()
a := require.New(t)

dilution := config.Consensus[protocol.ConsensusCurrentVersion].DefaultKeyDilution
Expand All @@ -531,7 +541,7 @@ func TestFillDBWithParticipationKeys(t *testing.T) {
a.NoError(err)
}

func TestKeyregValidityPeriod(t *testing.T) {
func TestKeyregValidityPeriod(t *testing.T) { //nolint:paralleltest // Not parallel because it modifies config.Consensus
partitiontest.PartitionTest(t)
a := require.New(t)

Expand Down
Loading