forked from move-language/move
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFirstModule.move
26 lines (23 loc) · 919 Bytes
/
FirstModule.move
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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);
}
}