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

Add mock speedtest constructor #828

Merged
merged 2 commits into from
Jun 14, 2024
Merged

Add mock speedtest constructor #828

merged 2 commits into from
Jun 14, 2024

Conversation

maplant
Copy link
Contributor

@maplant maplant commented Jun 13, 2024

Add a mock speedtest constructor. This is so that the mobile rewards estimator can easily construct a collection of speedtests that are guaranteed to be assigned SpeedtestTier::Good when averaged.

I'm open to better ways of doing this, this just seemed like the easiest way

Copy link
Contributor

@michaeldjeffrey michaeldjeffrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My alternative to creating speedtests was this.

fn speedtests(tier: SpeedtestTier) -> Vec<Speedtest> {
// SpeedtestTier is determined solely by upload_speed.
// Other values are far surpassing ::Good.
let upload_speed = BytesPs::mbps(match tier {
SpeedtestTier::Good => 10,
SpeedtestTier::Acceptable => 8,
SpeedtestTier::Degraded => 5,
SpeedtestTier::Poor => 2,
SpeedtestTier::Fail => 0,
});
vec![
Speedtest {
upload_speed,
download_speed: BytesPs::mbps(150),
latency_millis: 0,
timestamp: Utc::now(),
},
Speedtest {
upload_speed,
download_speed: BytesPs::mbps(150),
latency_millis: 0,
timestamp: Utc::now(),
},
]
}

@maplant maplant merged commit 365655f into main Jun 14, 2024
15 checks passed
@maplant maplant deleted the map/mock-speedtest branch June 14, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants