Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Update the tutorial for creating a project (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch authored Aug 30, 2022
1 parent 5a0b355 commit de75fd7
Showing 1 changed file with 19 additions and 25 deletions.
44 changes: 19 additions & 25 deletions docs/tutorials/create-a-project.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,23 @@ The `soroban-sdk` is in early development. Report issues
soroban-sdk = "0.0.4"

[dev_dependencies]
project-name = { path = ".", features = ["testutils"] }
soroban-sdk = { version = "0.0.4", features = ["testutils"] }

[features]
default = ["export"]
export = []
testutils = ["soroban-sdk/testutils"]
```

The `features` list and `dev_dependencies` configure three variations that the
contract can be built with:
- By `default`, with `export` enabled, contract functions will be exported and
available to be invoked when the contract is deployed.
- Optionally without `export` enabled, contract functions will not be exported.
Types will be still exposed, which is useful when developing multiple contracts
together and this contract is to be imported into another but its functions are
not intended to be invoked.
- And `testutils` which will cause additional test utilities to be generated for
calling the contract in tests. The library itself is added as a `dev_dependencies`
so that whenever its tests are running the `testutils` feature is enabled.
The `features` list includes a `testutils` feature, which will cause additional
test utilities to be generated for calling the contract in tests.

:::info
The `testutils` test utilities are automatically enabled inside [Rust unit
tests] inside the same crate as your contract. If you write [Rust integration
tests], or write tests from another crate, you'll need to add `#[cfg(feature =
"testutils")]` to those tests and enable the `testutils` feature when running
your tests with `cargo test --features testutils` to be able to use those test
utilities.
:::

## Configure the `release` Profile

Expand All @@ -92,24 +90,17 @@ lto = true
The steps below should produce a `Cargo.toml` that looks like so.

```toml title="Cargo.toml"
[package]
name = "project-name"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]

[features]
testutils = ["soroban-sdk/testutils"]

[dependencies]
soroban-sdk = "0.0.4"

[dev_dependencies]
project-name = { path = ".", features = ["testutils"] }

[features]
default = ["export"]
export = []
testutils = ["soroban-sdk/testutils"]
soroban-sdk = { version = "0.0.4", features = ["testutils"] }

[profile.release]
opt-level = "z"
Expand All @@ -121,3 +112,6 @@ panic = "abort"
codegen-units = 1
lto = true
```

[Rust unit tests]: https://doc.rust-lang.org/rust-by-example/testing/unit_testing.html
[Rust integration tests]: https://doc.rust-lang.org/rust-by-example/testing/integration_testing.html

0 comments on commit de75fd7

Please sign in to comment.