Skip to content

Commit

Permalink
Small format changes (MystenLabs#9704)
Browse files Browse the repository at this point in the history
## Description 

Small changes not saved for previous PR

## Test Plan 

Locally

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
  • Loading branch information
ronny-mysten authored Mar 22, 2023
1 parent b7978b3 commit b62a72c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions doc/src/build/move/debug-publish.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@ include a special _initializer function_ that runs at publication time. The goal

While the `sui move` command does not support publishing explicitly, you can still test module initializers using the testing framework by dedicating the first transaction to executing the initializer function.

Continuing the fantasy game example, the `init` function should create a Forge object.
Continuing the fantasy game example, the `init` function should create a `Forge` object.

``` rust
// module initializer to be executed when this module is published
// Module initializer to be executed when this module is published
fun init(ctx: &mut TxContext) {
let admin = Forge {
id: object::new(ctx),
swords_created: 0,
};
// transfer the forge object to the module/package publisher
// Transfer the Forge object to the module/package publisher
// (presumably the game admin)
transfer::transfer(admin, tx_context::sender(ctx));
}
```

The tests you have so far call the `init` function, but the initializer function itself isn't tested to ensure it properly creates a Forge object. To test this functionality, modify the `sword_create` function to take the forge as a parameter and to update the number of
The tests you have so far call the `init` function, but the initializer function itself isn't tested to ensure it properly creates a `Forge` object. To test this functionality, modify the `sword_create` function to take the forge as a parameter and to update the number of
created swords at the end of the function:

``` rust
Expand Down Expand Up @@ -99,7 +99,7 @@ Now, create a function to test the module initialization:

```

As the new test function shows, the first transaction (explicitly) calls the initializer. The next transaction checks if the `forge` object has been created and properly initialized.
As the new test function shows, the first transaction (explicitly) calls the initializer. The next transaction checks if the `Forge` object has been created and properly initialized.

If you try to run tests on the whole package at this point, you encounter compilation errors in the existing tests because of the
`sword_create` function signature change. The changes required for the tests to run again is an exercise left for you. If you need help, you can refer to the source code for the package (with all the tests properly adjusted) in [my_module.move](https://github.com/MystenLabs/sui/tree/main/sui_programmability/examples/move_tutorial/sources/my_module.move).

0 comments on commit b62a72c

Please sign in to comment.