Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Poytr1 committed Sep 16, 2023
1 parent 17a7dfe commit 61b1c40
Show file tree
Hide file tree
Showing 6 changed files with 374 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ use move_core_types::{
};
use move_vm_runtime::{move_vm::MoveVM, session::SerializedReturnValues};
use move_vm_test_utils::InMemoryStorage;
use move_vm_types::call_trace::CallTraces;
use move_vm_types::gas::UnmeteredGasMeter;

const TEST_ADDR: AccountAddress = AccountAddress::new([42; AccountAddress::LENGTH]);

fn run(
ty_args: Vec<TypeTag>,
args: Vec<MoveValue>,
) -> VMResult<Vec<Vec<u8>>> {
) -> VMResult<CallTraces> {
let code = r#"
module {{ADDR}}::M {
public fun foo(v1: u64): u64 {
bar(v1)
bar(v1) + 1
}
public fun bar(v1: u64): u64 {
Expand Down Expand Up @@ -52,21 +53,29 @@ fn run(
.map(|val| val.simple_serialize().unwrap())
.collect();

let SerializedReturnValues {
return_values,
mutable_reference_outputs: _,
} = sess.execute_function_bypass_visibility(
// let SerializedReturnValues {
// return_values,
// mutable_reference_outputs: _,
// } = sess.execute_function_bypass_visibility(
// &module_id,
// &fun_name,
// ty_args,
// args,
// &mut UnmeteredGasMeter,
// )?;

sess.call_trace(
&module_id,
&fun_name,
ty_args,
args,
&mut UnmeteredGasMeter,
)?;
)

Ok(return_values
.into_iter()
.map(|(bytes, _layout)| bytes)
.collect())
// Ok(return_values
// .into_iter()
// .map(|(bytes, _layout)| bytes)
// .collect())
}

fn expect_success(
Expand All @@ -75,11 +84,7 @@ fn expect_success(
expected_layouts: &[MoveTypeLayout],
) {
let return_vals = run(ty_args, args).unwrap();
assert!(return_vals.len() == expected_layouts.len());

for (blob, layout) in return_vals.iter().zip(expected_layouts.iter()) {
MoveValue::simple_deserialize(blob, layout).unwrap();
}
assert_eq!(return_vals.len(), 1);
}

#[test]
Expand Down
Loading

0 comments on commit 61b1c40

Please sign in to comment.