go-livepeer icon indicating copy to clipboard operation
go-livepeer copied to clipboard

fix: selection algo filtering on max price fixed

Open ad-astra-video opened this issue 1 year ago • 2 comments

What does this pull request do? Explain your changes. (required)

Fixes behavior of gateway when no max price is set. 0 maxPrice will return to being no max price filter enabled.

The addition of maxPricePerCapability included initializing a zero max price by default so the map is fully initialized. This broke the filterByMaxPrice function that checked for an unset maxPrice of nil. Specific updates (required)

  • updates filterByMaxPrice function in selection_algorithm.go to check for 0 rather than checking for nil
  • added test to cover this so will fail in future if behavior of max price filtering changes
  • updated TestFilter test to set a maxPrice of 0 if none set

How did you test each of these updates (required)

Added new test and ran all tests in selection_algorithm_test.go

Does this pull request close any open issues?

Checklist:

  • [ ] Read the contribution guide
  • [X] make runs successfully
  • [ ] All tests in ./test.sh pass X selection_algorithm_test.go pass.
  • [ ] README and other documentation updated
  • [ ] Pending changelog updated

ad-astra-video avatar Sep 21 '24 14:09 ad-astra-video

I updated for suggested change. Learned something new, did not know Sign() did that!

ad-astra-video avatar Sep 23 '24 23:09 ad-astra-video

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 30.56667%. Comparing base (0cf87dc) to head (181d727).

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              master       #3179   +/-   ##
=============================================
  Coverage   30.56667%   30.56667%           
=============================================
  Files            152         152           
  Lines          45494       45494           
=============================================
  Hits           13906       13906           
  Misses         30770       30770           
  Partials         818         818           
Files with missing lines Coverage Δ
server/selection_algorithm.go 90.58824% <100.00000%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0cf87dc...181d727. Read the comment docs.

Files with missing lines Coverage Δ
server/selection_algorithm.go 90.58824% <100.00000%> (ø)
:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Jan 14 '25 15:01 codecov[bot]