Skip to content

Commit

Permalink
Merge pull request #2 from sentioxyz/dev/pc/add_inputs
Browse files Browse the repository at this point in the history
add inputs to call trace
  • Loading branch information
Poytr1 authored Sep 16, 2023
2 parents e88f881 + 61b1c40 commit dae86e5
Show file tree
Hide file tree
Showing 6 changed files with 389 additions and 58 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 dae86e5

Please sign in to comment.