Skip to content

Commit

Permalink
stores: fix NDFs
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjan committed Apr 21, 2024
1 parent c941997 commit 50ed0a3
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions stores/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
"lukechampine.com/frand"
)

var errDatabaseLocked = errors.New("database is locked")

func randomMultisigUC() types.UnlockConditions {
uc := types.UnlockConditions{
PublicKeys: make([]types.UnlockKey, 2),
Expand Down Expand Up @@ -2036,16 +2034,11 @@ func TestContractSectors(t *testing.T) {
}

// Delete the sector.
if err := ss.db.Delete(&dbSector{Model: Model{ID: 1}}).Error; err != nil {
if strings.Contains(err.Error(), errDatabaseLocked.Error()) {
time.Sleep(time.Second) // wait for slabs to be pruned in the background
err = ss.db.Delete(&dbSector{Model: Model{ID: 1}}).Error
}
if err != nil {
t.Fatal(err)
}
if err := ss.retryTransaction(context.Background(), func(tx *gorm.DB) error {
return ss.db.Delete(&dbSector{Model: Model{ID: 1}}).Error
}); err != nil {
t.Fatal(err)
}
} // retry b/c database might be locked by slab deletion in RemoveObject
if err := ss.db.Find(&css).Error; err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -4135,15 +4128,11 @@ func TestSlabCleanup(t *testing.T) {
Key: ek,
HealthValidUntil: 100,
}
if err := ss.db.Create(&bufferedSlab).Error; err != nil {
if strings.Contains(err.Error(), errDatabaseLocked.Error()) {
time.Sleep(time.Second) // wait for slabs to be pruned in the background
err = ss.db.Create(&bufferedSlab).Error
}
if err != nil {
t.Fatal(err)
}
}
if err := ss.retryTransaction(context.Background(), func(tx *gorm.DB) error {
return ss.db.Create(&bufferedSlab).Error
}); err != nil {
t.Fatal(err)
} // retry b/c database might be locked by slab deletion in RemoveObject
obj3 := dbObject{
ObjectID: "3",
DBBucketID: ss.DefaultBucketID(),
Expand Down

0 comments on commit 50ed0a3

Please sign in to comment.