iota_move_natives_latest/
random.rs1use std::collections::VecDeque;
6
7use move_binary_format::errors::PartialVMResult;
8use move_vm_runtime::native_functions::NativeContext;
9use move_vm_types::{
10 loaded_data::runtime_types::Type, natives::function::NativeResult, values::Value,
11};
12use rand::Rng;
13use smallvec::smallvec;
14
15use crate::legacy_test_cost;
16
17pub fn generate_rand_seed_for_testing(
18 _context: &mut NativeContext,
19 _ty_args: Vec<Type>,
20 _args: VecDeque<Value>,
21) -> PartialVMResult<NativeResult> {
22 let mut seed = [0u8; 32];
23 rand::thread_rng()
24 .try_fill(&mut seed)
25 .expect("should never fail");
26 Ok(NativeResult::ok(
27 legacy_test_cost(),
28 smallvec![Value::vector_u8(seed)],
29 ))
30}