Skip to content

Commit

Permalink
Rename 2 testing only functions in random.move (MystenLabs#17225)
Browse files Browse the repository at this point in the history
## Description 

Rename 2 testing only functions in random.move 

## Test plan 

How did you test the new or updated feature?

---

## 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:
  • Loading branch information
benr-ml authored Apr 18, 2024
1 parent 5e95699 commit 2b0e4cc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,16 @@ module sui::random {
/// Random generator from a non-deterministic seed.
/// To be used when non-deterministic randomness is needed in tests (e.g., fuzzing).
public fun new_generator_for_testing(): RandomGenerator {
let seed = generate_rand_seed();
new_generator_from_seed(seed)
let seed = generate_rand_seed_for_testing();
new_generator_from_seed_for_testing(seed)
}

#[test_only]
/// Random generator from a given seed.
public fun new_generator_from_seed(seed: vector<u8>): RandomGenerator {
public fun new_generator_from_seed_for_testing(seed: vector<u8>): RandomGenerator {
RandomGenerator { seed, counter: 0, buffer: vector[] }
}

#[test_only]
native fun generate_rand_seed(): vector<u8>;
native fun generate_rand_seed_for_testing(): vector<u8>;
}
4 changes: 2 additions & 2 deletions sui-execution/latest/sui-move-natives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,8 +859,8 @@ pub fn all_natives(silent: bool) -> NativeFunctionTable {
),
(
"random",
"generate_rand_seed",
make_native!(random::generate_rand_seed),
"generate_rand_seed_for_testing",
make_native!(random::generate_rand_seed_for_testing),
),
(
"zklogin_verified_id",
Expand Down
2 changes: 1 addition & 1 deletion sui-execution/latest/sui-move-natives/src/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rand::Rng;
use smallvec::smallvec;
use std::collections::VecDeque;

pub fn generate_rand_seed(
pub fn generate_rand_seed_for_testing(
_context: &mut NativeContext,
_ty_args: Vec<Type>,
_args: VecDeque<Value>,
Expand Down

0 comments on commit 2b0e4cc

Please sign in to comment.