From b7c061ae4b9aa6b7740f747f5fd0738e72fde9c6 Mon Sep 17 00:00:00 2001 From: steelgeek091 <130330379+steelgeek091@users.noreply.github.com> Date: Tue, 27 Jun 2023 18:05:35 +0800 Subject: [PATCH] Remove the TxContext in the move test file. (#362) cargo fmt Add negative tests for TxContext. --- .../entry_function_invalid_struct.exp | 19 +++++++++----- .../entry_function_invalid_struct.move | 6 +++++ .../entry_function_valid_reference.exp | 26 +++++-------------- .../entry_function_valid_reference.move | 11 -------- .../entry_function_valid_struct.exp | 11 ++------ .../entry_function_valid_struct.move | 7 ----- .../move_cli/commands/integration_test.rs | 5 +--- 7 files changed, 28 insertions(+), 57 deletions(-) diff --git a/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_invalid_struct.exp b/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_invalid_struct.exp index 8086a1fda1..fbf3c0bb14 100644 --- a/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_invalid_struct.exp +++ b/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_invalid_struct.exp @@ -1,11 +1,18 @@ processed 2 tasks -task 1 'publish'. lines 3-12: +task 1 'publish'. lines 3-18: Error: error: type `test::Foo` is not supported as a parameter type - ┌─ /tmp/tempfile:8:5 - │ -8 │ ╭ entry public fun test_entry_function_invalid_struct( _foo: Foo ){ -9 │ │ } - │ ╰─────^ + ┌─ /tmp/tempfile:9:5 + │ + 9 │ ╭ entry public fun test_entry_function_invalid_struct( _foo: Foo ){ +10 │ │ } + │ ╰─────^ + +error: type `&tx_context::TxContext` is not supported as a parameter type + ┌─ /tmp/tempfile:11:5 + │ +11 │ ╭ entry public fun test_entry_function_invalid_struct_txcontext( _: &tx_context::TxContext ){ +12 │ │ } + │ ╰─────^ diff --git a/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_invalid_struct.move b/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_invalid_struct.move index ebebc81adb..4e76021360 100644 --- a/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_invalid_struct.move +++ b/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_invalid_struct.move @@ -2,6 +2,8 @@ //# publish module creator::test { + use moveos_std::tx_context; + struct Foo has copy, drop { x: u64, } @@ -9,4 +11,8 @@ module creator::test { entry public fun test_entry_function_invalid_struct( _foo: Foo ){ } + + entry public fun test_entry_function_invalid_struct_txcontext( _: &tx_context::TxContext ){ + + } } diff --git a/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_valid_reference.exp b/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_valid_reference.exp index 2cd27bf2db..d512b2ce21 100644 --- a/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_valid_reference.exp +++ b/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_valid_reference.exp @@ -1,25 +1,11 @@ processed 2 tasks -task 1 'publish'. lines 3-33: +task 1 'publish'. lines 3-22: Error: error: type `&mut signer` is not supported as a parameter type - ┌─ /tmp/tempfile:9:5 - │ - 9 │ ╭ entry public fun test_entry_function_valid_reference_mut_signer( _: &mut signer ){ -10 │ │ } - │ ╰─────^ - -error: type `&mut tx_context::TxContext` is not supported as a parameter type - ┌─ /tmp/tempfile:17:5 - │ -17 │ ╭ entry public fun test_entry_function_valid_reference_mut_tx_context( _: &mut tx_context::TxContext ){ -18 │ │ } - │ ╰─────^ - -error: type `&tx_context::TxContext` is not supported as a parameter type - ┌─ /tmp/tempfile:15:5 - │ -15 │ ╭ entry public fun test_entry_function_valid_reference_tx_context( _: & tx_context::TxContext ){ -16 │ │ } - │ ╰─────^ + ┌─ /tmp/tempfile:8:5 + │ +8 │ ╭ entry public fun test_entry_function_valid_reference_mut_signer( _: &mut signer ){ +9 │ │ } + │ ╰─────^ diff --git a/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_valid_reference.move b/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_valid_reference.move index 72e53d05a8..af458273a0 100644 --- a/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_valid_reference.move +++ b/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_valid_reference.move @@ -3,8 +3,6 @@ //# publish module creator::test { use moveos_std::storage_context; - use moveos_std::tx_context; - entry public fun test_entry_function_valid_reference_signer( _: & signer ){ @@ -21,13 +19,4 @@ module creator::test { entry public fun test_entry_function_valid_reference_mut_storage_context( _: &mut storage_context::StorageContext ){ } - - entry public fun test_entry_function_valid_reference_tx_context( _: & tx_context::TxContext ){ - - } - - entry public fun test_entry_function_valid_reference_mut_tx_context( _: &mut tx_context::TxContext ){ - - } - } diff --git a/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_valid_struct.exp b/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_valid_struct.exp index 66ecd23f73..7ff7c2b0fa 100644 --- a/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_valid_struct.exp +++ b/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_valid_struct.exp @@ -1,11 +1,4 @@ processed 2 tasks -task 1 'publish'. lines 3-32: -Error: error: type `&mut tx_context::TxContext` is not supported as a parameter type - ┌─ /tmp/tempfile:18:5 - │ -18 │ ╭ entry public fun test_entry_function_valid_struct_tx_context( _ctx: &mut tx_context::TxContext ){ -19 │ │ } - │ ╰─────^ - - +task 1 'publish'. lines 3-25: +status EXECUTED diff --git a/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_valid_struct.move b/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_valid_struct.move index b6ff8fe98b..abe80d9529 100644 --- a/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_valid_struct.move +++ b/crates/rooch-framework-tests/tests/cases/entry_function/entry_function_valid_struct.move @@ -6,8 +6,6 @@ module creator::test { use std::ascii; use moveos_std::storage_context; use moveos_std::object_id; - use moveos_std::tx_context; - entry public fun test_entry_function_valid_struct_string( _str: string::String ){ @@ -24,9 +22,4 @@ module creator::test { entry public fun test_entry_function_valid_struct_object_id( _id: object_id::ObjectID ){ } - - entry public fun test_entry_function_valid_struct_tx_context( _ctx: &mut tx_context::TxContext ){ - - } - } diff --git a/crates/rooch/src/commands/move_cli/commands/integration_test.rs b/crates/rooch/src/commands/move_cli/commands/integration_test.rs index 65d63b63fe..d964f5546d 100644 --- a/crates/rooch/src/commands/move_cli/commands/integration_test.rs +++ b/crates/rooch/src/commands/move_cli/commands/integration_test.rs @@ -186,10 +186,7 @@ impl IntegrationTest { construct_pre_compiled_lib(targets.clone(), None, move_compiler::Flags::empty())?; let pre_compiled_lib = match program_res { Ok(af) => af, - Err((files, errors)) => { - eprintln!("!!!Package failed to compile!!!"); - move_compiler::diagnostics::report_diagnostics(&files, errors) - } + Err((files, errors)) => move_compiler::diagnostics::report_diagnostics(&files, errors), }; { // update the global