Skip to content

Commit

Permalink
Fix ColorObject tests (MystenLabs#1395)
Browse files Browse the repository at this point in the history
  • Loading branch information
lxfind authored Apr 15, 2022
1 parent bcd727e commit cc418cb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
8 changes: 4 additions & 4 deletions doc/src/build/programming-with-objects/ch1-object-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public fun get_color(self: &ColorObject): (u8, u8, u8) {
}
```

Find the full code online in [ColorObject.move](../../../move_code/objects_tutorial/sources/Ch1_2/ColorObject.move).
Find the full code online in [ColorObject.move](../../../../sui_programmability/examples/objects_tutorial/sources/ColorObject.move).

To compile the code, make sure you have [installed Sui](../install.md) so that `sui-move` is in `PATH`. In the code [root directory](../../../move_code/objects_tutorial/) (where `Move.toml` is), run:
```
Expand Down Expand Up @@ -139,7 +139,7 @@ You may have noticed that `take_object` picks the object only based on the type

You may have noticed that `take_object` picks the object based solely on the type parameter. What if there are multiple objects of the same type owned by the account? How do we retrieve each of them? In fact, if you call `take_object` when there are more than one object of the same type in the same account, an assertion failure will be triggered. We are working on adding an API just for this. Update coming soon.

Again, you can find the full code in [ColorObject.move](../../../move_code/objects_tutorial/sources/Ch1_2/ColorObject.move).
Again, you can find the full code in [ColorObject.move](../../../../sui_programmability/examples/objects_tutorial/sources/ColorObject.move).

To run the test, simply run the following in the code root directory:
```
Expand All @@ -157,7 +157,7 @@ This will tell you the current wallet address.

First, we need to publish the code on-chain. Assuming the path to the root of the repository is $ROOT:
```
$ wallet publish --path $ROOT/doc/move_code/objects_tutorial --gas-budget 10000
$ wallet publish --path $ROOT/sui_programmability/examples/objects_tutorial --gas-budget 10000
```
You can find the published package object ID in the **Publish Results** output:
```
Expand Down Expand Up @@ -192,7 +192,7 @@ Owner: AddressOwner(k#5db53ebb05fd3ea5f1d163d9d487ee8cd7b591ee)
Version: 1
ID: 5EB2C3E55693282FAA7F5B07CE1C4803E6FDC1BB
Readonly: false
Type: 0x57258f32746fd1443f2a077c0c6ec03282087c19::Ch1::ColorObject
Type: 0x57258f32746fd1443f2a077c0c6ec03282087c19::ColorObject
```
As we can see, it's owned by the current default wallet address that we saw earlier. And the type of this object is `ColorObject`!

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module Tutorial::ColorObjectTests {
// == Tests covered in Chapter 1 ==

#[test]
fun test_create() {
public(script) fun test_create() {
let owner = @0x1;
// Create a ColorObject and transfer it to @owner.
let scenario = &mut TestScenario::begin(&owner);
Expand Down Expand Up @@ -81,7 +81,7 @@ module Tutorial::ColorObjectTests {
// == Tests covered in Chapter 2 ==

#[test]
fun test_delete() {
public(script) fun test_delete() {
let owner = @0x1;
// Create a ColorObject and transfer it to @owner.
let scenario = &mut TestScenario::begin(&owner);
Expand All @@ -104,7 +104,7 @@ module Tutorial::ColorObjectTests {
}

#[test]
fun test_transfer() {
public(script) fun test_transfer() {
let owner = @0x1;
// Create a ColorObject and transfer it to @owner.
let scenario = &mut TestScenario::begin(&owner);
Expand Down
9 changes: 8 additions & 1 deletion sui_programmability/framework/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,14 @@ fn run_framework_move_unit_tests() {

#[test]
fn run_examples_move_unit_tests() {
let examples = vec!["basics", "defi", "fungible_tokens", "games", "nfts"];
let examples = vec![
"basics",
"defi",
"fungible_tokens",
"games",
"nfts",
"objects_tutorial",
];
for example in examples {
let path = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../examples")
Expand Down

0 comments on commit cc418cb

Please sign in to comment.