Skip to content

Commit

Permalink
Remove the TxContext in the move test file. (#362)
Browse files Browse the repository at this point in the history
cargo fmt

Add negative tests for TxContext.
  • Loading branch information
steelgeek091 committed Jun 27, 2023
1 parent 8394e03 commit b7c061a
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -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 │ │ }
│ ╰─────^


Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

//# publish
module creator::test {
use moveos_std::tx_context;

struct Foo has copy, drop {
x: u64,
}

entry public fun test_entry_function_invalid_struct( _foo: Foo ){

}

entry public fun test_entry_function_invalid_struct_txcontext( _: &tx_context::TxContext ){

}
}
Original file line number Diff line number Diff line change
@@ -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 │ │ }
│ ╰─────^


Original file line number Diff line number Diff line change
Expand Up @@ -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 ){

Expand All @@ -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 ){

}

}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 ){

Expand All @@ -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 ){

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b7c061a

Please sign in to comment.