apollo_consensus_orchestrator: add SNIP-35 module tests#13815
Conversation
f24886f to
f42b483
Compare
6902537 to
6068d78
Compare
28a4ee7 to
ae638b6
Compare
d28c88a to
47c092a
Compare
ae638b6 to
bf2a6d7
Compare
d259d42 to
67f8dd0
Compare
bf2a6d7 to
09938eb
Compare
67f8dd0 to
c73832d
Compare
3549582 to
c665a80
Compare
c73832d to
4209e5f
Compare
ShahakShama
left a comment
There was a problem hiding this comment.
@ShahakShama reviewed 2 files and all commit messages, and made 6 comments.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on sirandreww-starkware).
crates/apollo_consensus_orchestrator/src/snip35/test.rs line 6 at r1 (raw file):
#[test] fn test_compute_fee_actual_with_10_identical_values() {
This is way too many test cases. IMO you can have a test case with a random list of size 12 you've generated on ipython and pasted here and precompute the result, another 3 cases for when you return None and that's it
crates/apollo_consensus_orchestrator/src/snip35/test.rs line 72 at r1 (raw file):
// Target: $3e-9/gas = 3_000_000_000 atto-USD. STRK at $0.50 = 500_000_000_000_000_000. // floor = 3_000_000_000 * 10^18 / 500_000_000_000_000_000 = 6_000_000_000. let target = compute_fee_target(3_000_000_000, 500_000_000_000_000_000, 0, u128::MAX);
The meaning of each parameter here is unclear. See https://github.com/starkware-industries/code-quality/blob/main/style_guide/rust_style_guide.md#unnamed-function-parameters
Same for other tests
crates/apollo_consensus_orchestrator/src/snip35/test.rs line 78 at r1 (raw file):
#[test] fn test_compute_fee_target_clamp_min() { let target = compute_fee_target(1, 10u128.pow(18), 100, u128::MAX);
Set a constant for MIN and use it here and in the assert_eq below. Same for the max test and the zero rate test
crates/apollo_consensus_orchestrator/src/snip35/test.rs line 91 at r1 (raw file):
#[test] fn test_compute_fee_target_zero_rate() {
Append to the test name the expected result: ..._returns_max
crates/apollo_consensus_orchestrator/src/snip35/test.rs line 117 at r1 (raw file):
#[test] fn test_compute_fee_proposal_target_within_bounds() {
Test for both directions (can be done in the same test)
crates/apollo_consensus_orchestrator/src/snip35/test.rs line 131 at r1 (raw file):
#[test] fn test_compute_fee_actual_window_size_below_minimum_returns_none() {
Move this to the other actual fee tests
4209e5f to
f6b6e1b
Compare
f6b6e1b to
50f8d9e
Compare
7234dce to
1848f04
Compare
50f8d9e to
bd54653
Compare
sirandreww-starkware
left a comment
There was a problem hiding this comment.
@sirandreww-starkware made 6 comments.
Reviewable status: 0 of 2 files reviewed, 6 unresolved discussions (waiting on ShahakShama).
crates/apollo_consensus_orchestrator/src/snip35/test.rs line 6 at r1 (raw file):
Previously, ShahakShama wrote…
This is way too many test cases. IMO you can have a test case with a random list of size 12 you've generated on ipython and pasted here and precompute the result, another 3 cases for when you return None and that's it
Done
crates/apollo_consensus_orchestrator/src/snip35/test.rs line 72 at r1 (raw file):
Previously, ShahakShama wrote…
The meaning of each parameter here is unclear. See https://github.com/starkware-industries/code-quality/blob/main/style_guide/rust_style_guide.md#unnamed-function-parameters
Same for other tests
Done
crates/apollo_consensus_orchestrator/src/snip35/test.rs line 78 at r1 (raw file):
Previously, ShahakShama wrote…
Set a constant for MIN and use it here and in the assert_eq below. Same for the max test and the zero rate test
Done
Added FLOOR_MIN_FRI and FLOOR_MAX_FRI constants at the top of the test module and reused them in the clamp_min, clamp_max, and zero_rate_returns_max rstest cases (both as the input bound and the expected GasPrice)
crates/apollo_consensus_orchestrator/src/snip35/test.rs line 91 at r1 (raw file):
Previously, ShahakShama wrote…
Append to the test name the expected result: ..._returns_max
Done
the case is now case::zero_rate_returns_max in the test_compute_fee_target rstest
crates/apollo_consensus_orchestrator/src/snip35/test.rs line 117 at r1 (raw file):
Previously, ShahakShama wrote…
Test for both directions (can be done in the same test)
Done.
crates/apollo_consensus_orchestrator/src/snip35/test.rs line 131 at r1 (raw file):
Previously, ShahakShama wrote…
Move this to the other actual fee tests
Done.
ShahakShama
left a comment
There was a problem hiding this comment.
@ShahakShama reviewed 2 files and all commit messages, made 2 comments, and resolved 6 discussions.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on sirandreww-starkware).
crates/apollo_consensus_orchestrator/src/snip35/test.rs line 11 at r3 (raw file):
#[test] fn test_compute_fee_actual_random_window() {
What I meant was 12 with window size 10. You can do that in a new test if you prefer. Make sure that one of the first numbers outside of the window would've affected the median if it were in the window (And state it in comments)
crates/apollo_consensus_orchestrator/src/snip35/test.rs line 51 at r3 (raw file):
// Very low STRK price → very high floor, clamped down to FLOOR_MAX_FRI. #[case::clamp_max(FRI_DECIMALS_SCALE, 1, 0, FLOOR_MAX_FRI, GasPrice(FLOOR_MAX_FRI))] #[case::zero_rate_returns_max(100, 0, 0, FLOOR_MAX_FRI, GasPrice(FLOOR_MAX_FRI))]
Why 100 and not FRI_DECIMALS_SCALE? It should be a constant anyway
sirandreww-starkware
left a comment
There was a problem hiding this comment.
@sirandreww-starkware made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on ShahakShama).
crates/apollo_consensus_orchestrator/src/snip35/test.rs line 11 at r3 (raw file):
Previously, ShahakShama wrote…
What I meant was 12 with window size 10. You can do that in a new test if you prefer. Make sure that one of the first numbers outside of the window would've affected the median if it were in the window (And state it in comments)
Done
crates/apollo_consensus_orchestrator/src/snip35/test.rs line 51 at r3 (raw file):
Previously, ShahakShama wrote…
Why 100 and not FRI_DECIMALS_SCALE? It should be a constant anyway
Done
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ff91417. Configure here.
ShahakShama
left a comment
There was a problem hiding this comment.
@ShahakShama reviewed 2 files and all commit messages, made 1 comment, and resolved 2 discussions.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on sirandreww-starkware).


No description provided.