diff --git a/autopilot/autopilot.go b/autopilot/autopilot.go index b546eada9..c6ce42884 100644 --- a/autopilot/autopilot.go +++ b/autopilot/autopilot.go @@ -815,30 +815,35 @@ func evaluateConfig(cfg api.AutopilotConfig, cs api.ConsensusState, fee types.Cu // MaxRPCPrice tmpGS := maxGS() + tmpGS.MaxRPCPrice = gs.MaxRPCPrice if optimiseGougingSetting(&tmpGS, &tmpGS.MaxRPCPrice, cfg, cs, fee, currentPeriod, rs, hosts) { optimisedGS.MaxRPCPrice = tmpGS.MaxRPCPrice success = true } // MaxContractPrice tmpGS = maxGS() + tmpGS.MaxContractPrice = gs.MaxContractPrice if optimiseGougingSetting(&tmpGS, &tmpGS.MaxContractPrice, cfg, cs, fee, currentPeriod, rs, hosts) { optimisedGS.MaxContractPrice = tmpGS.MaxContractPrice success = true } // MaxDownloadPrice tmpGS = maxGS() + tmpGS.MaxDownloadPrice = gs.MaxDownloadPrice if optimiseGougingSetting(&tmpGS, &tmpGS.MaxDownloadPrice, cfg, cs, fee, currentPeriod, rs, hosts) { optimisedGS.MaxDownloadPrice = tmpGS.MaxDownloadPrice success = true } // MaxUploadPrice tmpGS = maxGS() + tmpGS.MaxUploadPrice = gs.MaxUploadPrice if optimiseGougingSetting(&tmpGS, &tmpGS.MaxUploadPrice, cfg, cs, fee, currentPeriod, rs, hosts) { optimisedGS.MaxUploadPrice = tmpGS.MaxUploadPrice success = true } // MaxStoragePrice tmpGS = maxGS() + tmpGS.MaxStoragePrice = gs.MaxStoragePrice if optimiseGougingSetting(&tmpGS, &tmpGS.MaxStoragePrice, cfg, cs, fee, currentPeriod, rs, hosts) { optimisedGS.MaxStoragePrice = tmpGS.MaxStoragePrice success = true diff --git a/internal/test/e2e/gouging_test.go b/internal/test/e2e/gouging_test.go index 28bf51069..a08fadd3f 100644 --- a/internal/test/e2e/gouging_test.go +++ b/internal/test/e2e/gouging_test.go @@ -53,17 +53,21 @@ func TestGouging(t *testing.T) { t.Fatal("unexpected data") } + // update the gouging settings to limit the max storage price to 100H + gs := test.GougingSettings + gs.MaxStoragePrice = types.NewCurrency64(100) + if err := b.UpdateSetting(context.Background(), api.SettingGouging, gs); err != nil { + t.Fatal(err) + } // fetch current contract set contracts, err := b.Contracts(context.Background(), api.ContractsOpts{ContractSet: cfg.Set}) tt.OK(err) - // update the host settings so it's gouging + // update one host's settings so it's gouging hk := contracts[0].HostKey host := hostsMap[hk.String()] settings := host.settings.Settings() - settings.IngressPrice = types.Siacoins(1) - settings.EgressPrice = types.Siacoins(1) - settings.ContractPrice = types.Siacoins(11) + settings.StoragePrice = types.NewCurrency64(101) // gouging tt.OK(host.UpdateSettings(settings)) // make sure the price table expires so the worker is forced to fetch it @@ -76,7 +80,7 @@ func TestGouging(t *testing.T) { // update all host settings so they're gouging for _, h := range cluster.hosts { settings := h.settings.Settings() - settings.EgressPrice = types.Siacoins(1) + settings.StoragePrice = types.NewCurrency64(101) if err := h.UpdateSettings(settings); err != nil { t.Fatal(err) } @@ -93,7 +97,7 @@ func TestGouging(t *testing.T) { } // try optimising gouging settings - resp, err := cluster.Autopilot.EvaluateConfig(context.Background(), test.AutopilotConfig, test.GougingSettings, test.RedundancySettings) + resp, err := cluster.Autopilot.EvaluateConfig(context.Background(), test.AutopilotConfig, gs, test.RedundancySettings) tt.OK(err) if resp.Recommendation == nil { t.Fatal("expected recommendation")