Skip to content

Commit

Permalink
[tests] Fix expected failure type random selector (#20652)
Browse files Browse the repository at this point in the history
## Description 

The change of this code block from `Ok(rand::random())` to a custom
selector logic overlooked the fact that we must avoid re-selecting
variant `0`, as variant `0` is the random variant, causing the code to
hit an `unreachable` block meant to avoid infinte recursion.

## Test plan 

Re-run test

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
williampsmith authored Dec 17, 2024
1 parent e1eb239 commit a1c79df
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/sui-benchmark/src/workloads/workload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl TryFrom<u32> for ExpectedFailureType {
match value {
0 => {
let mut rng = rand::thread_rng();
let n = rng.gen_range(0..ExpectedFailureType::COUNT - 1);
let n = rng.gen_range(1..ExpectedFailureType::COUNT - 1);
Ok(ExpectedFailureType::iter().nth(n).unwrap())
}
_ => ExpectedFailureType::iter()
Expand Down

0 comments on commit a1c79df

Please sign in to comment.