Skip to content

Commit

Permalink
[Move] Fixed test function calling entry functino and updated docs (M…
Browse files Browse the repository at this point in the history
  • Loading branch information
awelc authored and longbowlu committed May 12, 2022
1 parent bfeb09b commit 92fe654
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
19 changes: 8 additions & 11 deletions doc/src/build/move.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ In Sui, Move is used to define, create and manage programmable Sui
imposes additional restrictions on the code that can be written in
Move, effectively using a subset of Move (a.k.a. *Sui Move*), which
makes certain parts of the original Move documentation not applicable
to smart contract development in Sui (e.g., there is no concept of a
[script](https://github.com/diem/move/blob/main/language/documentation/book/src/modules-and-scripts.md#scripts)
in Sui Move). Consequently, it's best to simply follow this tutorial
to smart contract development in Sui. Consequently, it's best to simply follow this tutorial
and relevant Move documentation links provided in the tutorial.

Before we look at the Move code included with Sui, let's talk briefly
Expand Down Expand Up @@ -254,13 +252,10 @@ that it will do what it is intended to do.)

In general, an entry function, must satisfy the following properties:

- be public
- have `public(script)` visibility modifier
- have no return value
- have parameters ordered as follows:
- one or more Sui objects (or vectors of objects)
- one or more primitive types (or vectors of such types)
- a mutable reference to an instance of the `TxContext` struct
defined in the [TxContext module](https://github.com/MystenLabs/sui/tree/main/sui_programmability/framework/sources/TxContext.move)
- have a mutable reference to an instance of the `TxContext` struct
defined in the [TxContext module](https://github.com/MystenLabs/sui/tree/main/sui_programmability/framework/sources/TxContext.move) as the last parameter

More, concretely, the `transfer` function is public, has no return
value, and has three parameters:
Expand Down Expand Up @@ -659,11 +654,13 @@ struct available for function definitions:
We can now build the module extended with the new functions but still
have only one test defined. Let us change that by adding another test
function:
function. Note that this function needs to have `public(script)`
visibility modifier to be able to call other functions with the same
modifier, such as our entry function `sword_create`.
``` rust
#[test]
public fun test_sword_transactions() {
public(script) fun test_sword_transactions() {
use Sui::TestScenario;
let admin = @0xABBA;
Expand Down
2 changes: 1 addition & 1 deletion sui_programmability/tutorial/sources/M1.move
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ module MyFirstPackage::M1 {
}

#[test]
public fun test_sword_transactions() {
public(script) fun test_sword_transactions() {
use Sui::TestScenario;

// create test addresses representing users
Expand Down

0 comments on commit 92fe654

Please sign in to comment.