Skip to content

Commit d3c4d4b

Browse files
committed
Resizing Cache to 0 in tests 🚨
1 parent 63027f1 commit d3c4d4b

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

‎host/contracts/integrity_test.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,8 @@ func TestCheckIntegrity(t *testing.T) {
8686
}
8787
defer s.Close()
8888

89-
// Disable cache for this test
90-
if err := s.ResizeCache(0); err != nil {
91-
t.Fatal(err)
92-
}
89+
// Resize cache to 0 sectors
90+
s.ResizeCache(0)
9391

9492
result := make(chan error, 1)
9593
if _, err := s.AddVolume(filepath.Join(dir, "data.dat"), 10, result); err != nil {

‎host/storage/storage.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func (vm *VolumeManager) loadVolumes() error {
192192
vm.a.Register(alerts.Alert{
193193
ID: frand.Entropy256(),
194194
Severity: alerts.SeverityError,
195-
Message: fmt.Sprintf("Failed to open volume %q", vol.LocalPath),
195+
Message: "Failed to open volume",
196196
Data: map[string]any{
197197
"volume": vol.LocalPath,
198198
"error": err.Error(),
@@ -633,6 +633,7 @@ func (vm *VolumeManager) AddVolume(localPath string, maxSectors uint64, result c
633633
log.Error("failed to initialize volume", zap.Error(err))
634634
alert.Message = "Failed to initialize volume"
635635
alert.Severity = alerts.SeverityError
636+
alert.Data["error"] = err.Error()
636637
} else {
637638
alert.Message = "Volume initialized"
638639
alert.Severity = alerts.SeverityInfo
@@ -977,9 +978,9 @@ func (vm *VolumeManager) PruneSectors() (int, error) {
977978
}
978979

979980
// ResizeCache resizes the cache to the given size.
980-
func (vm *VolumeManager) ResizeCache(size int) error {
981+
func (vm *VolumeManager) ResizeCache(size int) {
982+
// Resize the underlying cache data structure
981983
vm.cache.Resize(size)
982-
return nil
983984
}
984985

985986
// NewVolumeManager creates a new VolumeManager.

‎host/storage/storage_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,9 @@ func TestRemoveCorrupt(t *testing.T) {
327327
}
328328
defer vm.Close()
329329

330+
// Resize cache to 0 sectors
331+
vm.ResizeCache(0)
332+
330333
result := make(chan error, 1)
331334
volumePath := filepath.Join(t.TempDir(), "hostdata.dat")
332335
volume, err := vm.AddVolume(volumePath, expectedSectors, result)

‎rhp/v3/rpc_test.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,8 @@ func TestStoreSector(t *testing.T) {
152152
defer renter.Close()
153153
defer host.Close()
154154

155-
// Get storage manager and disable cache
156-
s := host.Storage()
157-
if err := s.ResizeCache(0); err != nil {
158-
t.Fatal(err)
159-
}
155+
// Resize cache to 0 sectors
156+
host.Storage().ResizeCache(0)
160157

161158
session, err := renter.NewRHP3Session(context.Background(), host.RHPv3Addr(), host.PublicKey())
162159
if err != nil {

0 commit comments

Comments
 (0)