forc_project.md fixes
@@ -24,20 +24,32 @@ $ tree .
For additional information on dependency management, see: [here](../forc/dependencies.md).
```toml
-{{#include ../../../examples/counter/Forc.toml}}
+[project]
+authors = ["User"]
+entry = "main.sw"
+license = "Apache-2.0"
+name = "my-fuel-project"
+
+[dependencies]
```
Here are the contents of the only Sway file in the project, and the main entry point, `src/main.sw`:
```sway
-script;
+contract;
-fn main() {
+abi MyContract {
+ fn test_function() -> bool;
+}
+impl MyContract for Contract {
+ fn test_function() -> bool {
+ true
+ }
}
```
-The project is a _script_, one of four different project types. For additional information on different project types, see [here](../sway-program-types/index.md).
+The project is a _contract_, one of four different project types. For additional information on different project types, see [here](../sway-program-types/index.md).
We now compile our project with `forc build`, passing the flag `--print-finalized-asm` to view the generated assembly:
@@ -49,18 +61,30 @@ noop
DATA_SECTION_OFFSET[0..32]
DATA_SECTION_OFFSET[32..64]
lw $ds $is 1
-add $ds $ds $is
-ret $zero ; main fn returns unit value
+add $$ds $$ds $is
+lw $r1 $fp i73 ; load input function selector
+lw $r0 data_1 ; load fn selector for comparison
+eq $r0 $r1 $r0 ; function selector comparison
+jnzi $r0 i11 ; jump to selected function
+rvrt $zero ; revert if no selectors matched
+lw $r0 data_0 ; literal instantiation
+ret $r0
.data:
+data_0 .bool 0x01
+data_1 .u32 0x2151bd4b
-Compiled script "my-fuel-project".
-Bytecode size is 28 bytes.
+ Compiled contract "my-fuel-project".
+ Bytecode size is 68 bytes.
```
-To run this script, use `forc run` (note that `fuel-core` must be running for this to work):
+To test this contract, use `forc test`:
```console
-$ forc run
-Bytecode size is 28 bytes.
-[Return { id: ContractId([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), val: 0, pc: 488, is: 464 }]
+$ forc test
+running 1 test
+test can_get_contract_id ... ok
+
+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.22s
```
+
+The `forc test` command tests the contract using the Rust SDK test harness that lives under `tests/`. The default test harness `harness.rs` contains boilerplate code to get you started but doesn't actually call any contract methods. For additional information on testing contracts using the Rust SDK, refer to the [Testing with Rust](../../testing/testing-with-rust.md) section.
