sui_move_natives_latest/
random.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::legacy_test_cost;
5use move_binary_format::errors::PartialVMResult;
6use move_vm_runtime::execution::{Type, values::Value};
7use move_vm_runtime::natives::functions::{NativeContext, NativeResult};
8use rand::Rng;
9use smallvec::smallvec;
10use std::collections::VecDeque;
11
12pub fn generate_rand_seed_for_testing(
13    _context: &mut NativeContext,
14    _ty_args: Vec<Type>,
15    _args: VecDeque<Value>,
16) -> PartialVMResult<NativeResult> {
17    let mut seed = [0u8; 32];
18    rand::thread_rng()
19        .try_fill(&mut seed)
20        .expect("should never fail");
21    Ok(NativeResult::ok(
22        legacy_test_cost(),
23        smallvec![Value::vector_u8(seed)],
24    ))
25}