Skip to content

Commit

Permalink
[move-docs] Update step 1, step 2, and step 5
Browse files Browse the repository at this point in the history
Closes: #9936
  • Loading branch information
Tim Zakian authored and bors-libra committed Dec 3, 2021
1 parent 1ed0119 commit 9d680d8
Show file tree
Hide file tree
Showing 15 changed files with 177 additions and 166 deletions.
280 changes: 137 additions & 143 deletions language/documentation/tutorial/README.md

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions language/documentation/tutorial/step_1/BasicCoin/Move.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[package]
name = "BasicCoin"
version = "0.0.0"

[addresses]
NamedAddr = "0xDEADBEEF"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module NamedAddr::Coin {
module 0xCAFE::Coin {
struct Coin has key {
value: u64,
}
Expand Down
4 changes: 2 additions & 2 deletions language/documentation/tutorial/step_2/BasicCoin/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
name = "BasicCoin"
version = "0.0.0"

[addresses]
NamedAddr = "0xDEADBEEF"
[dependencies]
MoveStdlib = { local = "../../../../move-stdlib/", addr_subst = { "Std" = "0x1" } }
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
module NamedAddr::Coin {
module 0xCAFE::BasicCoin {
// Only included in compilation for testing. Similar to #[cfg(testing)]
// in Rust. Imports the `Signer` module from the MoveStdlib package.
#[test_only]
use Std::Signer;

struct Coin has key {
value: u64,
}

public fun mint(account: signer, value: u64) {
move_to(&account, Coin { value })
}

// Declare a unit test. It takes a signer called `account` with an
// address value of `0xC0FFEE`.
#[test(account = @0xC0FFEE)]
fun test_mint_10(account: signer) acquires Coin {
let addr = Signer::address_of(&account);
mint(account, 10);
// Make sure there is a `Coin` resource under `addr` with a value of `10`.
// We can access this resource and its value since we are in the
// same module that defined the `Coin` resource.
assert!(borrow_global<Coin>(addr).value == 10, 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "BasicCoin"
version = "0.0.0"

[addresses]
NamedAddr = "0xDEADBEEF"
NamedAddr = "0xCAFE"

[dependencies]
MoveStdlib = { local = "../../../../move-stdlib/", addr_subst = { "Std" = "0x1" } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module NamedAddr::Coin {
module 0xCAFE::BasicCoin {
// Only included in compilation for testing. Similar to #[cfg(testing)]
// in Rust.
#[test_only]
Expand All @@ -13,8 +13,8 @@ module NamedAddr::Coin {
}

// Declare a unit test. It takes a signer called `account` with an
// address value of `0xCAFE`.
#[test(account = @0xCAFE)]
// address value of `0xC0FFEE`.
#[test(account = @0xC0FFEE)]
fun test_mint_10(account: signer) acquires Coin {
let addr = Signer::address_of(&account);
mint(account, 10);
Expand Down
13 changes: 8 additions & 5 deletions language/documentation/tutorial/step_2_sol/solution_commands
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
mpm test -g
# Exercise 1
move package test -g

mpm test --coverage
# Exercise 2
move package test --coverage

Followed by:
mpm coverage summary
mpm coverage summary --summarize-functions
mpm coverage source --module Coin

move package coverage summary
move package coverage summary --summarize-functions
move package coverage source --module BasicCoin
2 changes: 1 addition & 1 deletion language/documentation/tutorial/step_4/BasicCoin/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "BasicCoin"
version = "0.0.0"

[addresses]
NamedAddr = "0xDEADBEEF"
NamedAddr = "0xCAFE"

[dependencies]
MoveStdlib = { local = "../../../../move-stdlib/", addr_subst = { "Std" = "0x1" } }
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "BasicCoin"
version = "0.0.0"

[addresses]
NamedAddr = "0xDEADBEEF"
NamedAddr = "0xCAFE"

[dependencies]
MoveStdlib = { local = "../../../../move-stdlib/", addr_subst = { "Std" = "0x1" } }
2 changes: 1 addition & 1 deletion language/documentation/tutorial/step_5/BasicCoin/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "BasicCoin"
version = "0.0.0"

[addresses]
NamedAddr = "0xDEADBEEF"
NamedAddr = "0xCAFE"

[dependencies]
MoveStdlib = { local = "../../../../move-stdlib/", addr_subst = { "Std" = "0x1" } }
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "BasicCoin"
version = "0.0.0"

[addresses]
NamedAddr = "0xDEADBEEF"
NamedAddr = "0xCAFE"

[dependencies]
MoveStdlib = { local = "../../../../move-stdlib/", addr_subst = { "Std" = "0x1" } }
2 changes: 1 addition & 1 deletion language/documentation/tutorial/step_6/BasicCoin/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "BasicCoin"
version = "0.0.0"

[addresses]
NamedAddr = "0xDEADBEEF"
NamedAddr = "0xCAFE"

[dependencies]
MoveStdlib = { local = "../../../../move-stdlib/", addr_subst = { "Std" = "0x1" } }
2 changes: 1 addition & 1 deletion language/documentation/tutorial/step_7/BasicCoin/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "BasicCoin"
version = "0.0.0"

[addresses]
NamedAddr = "0xDEADBEEF"
NamedAddr = "0xCAFE"

[dependencies]
MoveStdlib = { local = "../../../../move-stdlib/", addr_subst = { "Std" = "0x1" } }
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "BasicCoin"
version = "0.0.0"

[addresses]
NamedAddr = "0xDEADBEEF"
NamedAddr = "0xCAFE"

[dependencies]
MoveStdlib = { local = "../../../../move-stdlib/", addr_subst = { "Std" = "0x1" } }

0 comments on commit 9d680d8

Please sign in to comment.