Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Bring move-stdlib/src/natives/unit_test.rs on par with sui version #418

Open
wants to merge 1 commit into
base: llvm-sys
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions language/move-stdlib/src/natives/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ impl GasParameters {
base_cost: 0.into(),
unit_cost: 0.into(),
},
poison: unit_test::PoisonGasParameters {
base_cost: 0.into(),
},
},
}
}
Expand Down
37 changes: 33 additions & 4 deletions language/move-stdlib/src/natives/unit_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,48 @@ pub fn make_native_create_signers_for_testing(
)
}

#[derive(Debug, Clone)]
pub struct PoisonGasParameters {
pub base_cost: InternalGas,
}

fn native_poison(
gas_params: &PoisonGasParameters,
_context: &mut NativeContext,
ty_args: Vec<Type>,
args: VecDeque<Value>,
) -> PartialVMResult<NativeResult> {
debug_assert!(ty_args.is_empty());
debug_assert!(args.is_empty());
let cost = gas_params.base_cost;
Ok(NativeResult::ok(cost, smallvec![]))
}

pub fn make_native_poison(gas_params: PoisonGasParameters) -> NativeFunction {
Arc::new(
move |context, ty_args, args| -> PartialVMResult<NativeResult> {
native_poison(&gas_params, context, ty_args, args)
},
)
}

/***************************************************************************************************
* module
**************************************************************************************************/
#[derive(Debug, Clone)]
pub struct GasParameters {
pub create_signers_for_testing: CreateSignersForTestingGasParameters,
pub poison: PoisonGasParameters,
}

pub fn make_all(gas_params: GasParameters) -> impl Iterator<Item = (String, NativeFunction)> {
let natives = [(
"create_signers_for_testing",
make_native_create_signers_for_testing(gas_params.create_signers_for_testing),
)];
let natives = [
(
"create_signers_for_testing",
make_native_create_signers_for_testing(gas_params.create_signers_for_testing),
),
("poison", make_native_poison(gas_params.poison)),
];

make_module_natives(natives)
}
Loading