## Description
This introduces the `CompiledPackage` and `CompiledContractDependency`
types in order to more accurately model the inputs and outputs of the
`compile` function.
We also move the `name` and `target` fields from `BuiltPackage` into the
`PackageDescriptor`, construct the descriptor earlier in the build
process, and use the descriptor to consolidate more of the `compile`
function arguments.
I started on refactoring some of the ABI generation related code, but
realised that this might involve a more dedicated effort and opened
#4208.
## Checklist
- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
## Description
Implement RFC 0006, fix#4191.
Remove the `dep` reseved keyword in favor of `mod`.
Change path resolution for submodules to use an adjascent file at the
root and a folder named after the current module in other cases.
Remove the need for an argument to `library`, the LSP now points to
empty spans at the top of module files.
The library names are now determined by the file name, or the package
name at the top level.
## Checklist
- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
## Description
Reference to external dependency struct now looks like: `"type": "struct
abi_with_tuples::Person",`
`"type": "enum std::option::Option",`
Struct reference in root module still looks like:
`"type": "struct MyStruct",`
Struct reference in sub modules looks like:
`"type": "struct dep_1::MyStruct1",`
` forc build` will not generate json ABI with call path by default to do
so we have to use the flag `--json-abi-with-callpaths`, one example is:
```cargo run --bin forc build --json-abi-with-callpaths --path `pwd`/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_same_name_types/```
This will generate `test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_same_name_types/out/debug/abi_with_same_name_types-abi.json` with call paths for structs and enums.
This is related to:
https://github.com/FuelLabs/fuel-specs/issues/450https://github.com/FuelLabs/fuels-rs/issues/791
## Checklist
- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand areas.
- [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my feature works.
- [x] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
## Description
closes#2411.
This PR adds used gas information to the output of `forc test`. An
example run can be seen below:
<img width="534" alt="Screen Shot 2023-02-24 at 4 47 29 PM"
src="https://user-images.githubusercontent.com/20915464/221198624-a3bdb264-2182-4b9d-9497-7d8cfe84132b.png">
This is done automatically without any flags. I felt like this should be
the default way but open to suggestions if you feel like it should be
behind a flag like `--gas-usage`.
Also by accessing `TestResult` structs new used gas field, we can add
this information into vscode plugin just like #513. We do not have a
line by line gas cast information just yet but we could show the whole
test's used gas info next to the run button or something in vscode.
Thoughts @JoshuaBatty @sdankel
Please let me know if anyone has any requests around the flag and the
way we are printing the used gas. Maybe @nfurfaro could have some ideas
as the prime user of `forc-test` 😄
## Checklist
- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.
Closes#3190
## Checklist
- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
## Description
In anticipation of the upcoming ipfs support (#3926), this PR refactors
`forc-pkg` to more clearly separate out the "source" abstraction from
the rest of the pkg-handling logic.
We do so by creating a common interface for sources in the form of
traits for pinning and fetching. This should allow for adding in the
upcoming ipfs implementation (or future alternative source kind) in a
manner that doesn't further complicate the rest of package handling.
There is still room for further refactor of `pkg.rs`, but this should do
enough to clear the way for ipfs support and closes#3927.
## Checklist
- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
## Description
closes#3952.
This PR adds:
1. Revert code for failing tests
2. Known error signals for failing tests
3. Logs for failing tests
## Checklist
- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
## Description
closes#3329.
This PR filters unrelevant member nodes for `forc-client` operations in
workspaces. `forc deploy` only builds contracts and `forc run` only
builds scripts. This is done by adding a filtering capability to
`forc-pkg`.
## Checklist
- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
## Description
Bump to `v0.35.0` for a new release.
## Checklist
- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
This is a small refactor of the `forc-client` crate in anticipation of
including the new `forc submit` command (see #3885) as a new binary
output for the crate.
This PR inverts the forc-client module hierarchy to follow `forc`'s
layout a little more closely.
It also refactors the command types in order to better share sets of
clap arguments between different commands with the aim of reducing code
duplication and providing a more uniform experience across all official
forc commands/plugins. This will be improved further once the `forc
submit` command is included, allowing us to share some of the networking
arguments too.
---------
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
closes#3673.
## About this PR
This PR adds `CONTRACT_ID` injection while building contracts with `forc
build --test`. `CONTRACT_ID` is the id of the contract without the tests
added. To find out that id, we first compile the contract without tests
enabled.
The rough outline of stuff happening here:
1. We iterate over `BuildPlan` members to find out contracts and collect
their contract id into an injection map. In this step only the contracts
are built. To determine contract id we need to compile the contract
without tests. Since we also need the bytecode of the contract without
tests, we are collecting them as we come across them while iterating
over members.
2. With the injection map build and execute all the tests, so basically
after first step we are just doing the old `forc-test` behaviour.
So basically I added a pre-processing step for contract id collection
for those members that require it (contracts).
This enables the following test structure:
```rust
let caller = abi(MyContract, CONTRACT_ID);
let result = caller.test_function {}();
assert(result == true)
```
closes#3824.
With this PR, different tests are emitting logs separately as pointed
out by @mitchmindtree in #3808.
(Github code block indentations are showing up weird)
## Before this PR
```console
fuel/test_projects/deploy [⏱ 4s]
❯ mforc test --logs
Compiled library "core".
Compiled library "std".
Compiled library "deploy".
Bytecode size is 52 bytes.
Running 2 tests
[{"Log":{"id":"0000000000000000000000000000000000000000000000000000000000000000","is":10344,"pc":10368,"ra":1,"rb":0,"rc":0,"rd":0}}]
[{"Log":{"id":"0000000000000000000000000000000000000000000000000000000000000000","is":10344,"pc":10380,"ra":2,"rb":1,"rc":0,"rd":0}}]
test my_test ... ok (393.833µs)
test my_test2 ... ok (371.833µs)
Result: OK. 2 passed. 0 failed. Finished in 765.666µs.
```
## After this PR
```console
fuel/test_projects/deploy [⏱ 4s]
❯ mforc test --logs
Compiled library "core".
Compiled library "std".
Compiled library "deploy".
Bytecode size is 52 bytes.
Running 2 tests
test my_test ... ok (608.041µs)
[{"Log":{"id":"0000000000000000000000000000000000000000000000000000000000000000","is":10344,"pc":10368,"ra":1,"rb":0,"rc":0,"rd":0}}]
test my_test2 ... ok (360.041µs)
[{"Log":{"id":"0000000000000000000000000000000000000000000000000000000000000000","is":10344,"pc":10380,"ra":2,"rb":1,"rc":0,"rd":0}}]
Result: OK. 2 passed. 0 failed. Finished in 968.082µs.
```
closes#3807.
- Moved `Log` and `LogData` formatting code from `forc-client` to
`forc-util` as `forc-test` needs it too.
- Added `--logs` and `--pretty-print` flags to `forc-test`
This PR, refactor the `BuildPlan` generation a little to be able to
re-use some of the parts from other crates that requires to create
`BuildPlan` from build opts.
On top of that this PR also introduces a way to inject list of items
into the namespace of any member of the workspace.
This is done to unblock #3729closes#3763.
This bootstraps the EVM backend via the following:
- [x] Add build target support. This is implemented as a `--build-target
/ --target` CLI flag in Forc.
- [x] Allow for multiple asm builders The existing architecture was
refactored to be trait-based, and the code was split into two
directories, for `fuel` and `evm` backends.
- [x] Add minimal EVM assembly output.
- [x] Add `evm` target testing support.
- [x] Implement EVM smart contract memory loader
- [x] Implement basic Solidity ABI generation
The goal of this PR is to reduce code bloat. So it does a number of
things, although there are _no functional changes_.
1. Change the canonical code name from "declaration engine" to "decl
engine", including renaming `DeclarationEngine` to `DeclEngine`,
`DeclarationId` to `DeclId`, and `DeclarationWrapper` to `DeclWrapper`.
"`Declaration`" is a lot of syllables to say all the time haha 😅
2. Rename the `DeclEngine::look_up_decl_id` method to `DeclEngine::get`
and rename the `DeclEngine::replace_decl_id` method to
`DeclEngine::replace`.
3. Rename the `DeclEngine::insert` method to
`DeclEngine::insert_wrapper`.
4. Add a new `DeclEngine::insert` method with type param `T:
Into<DeclWrapper>` and add traits for `From<DeclWrapper>` for different
declarations. Replace and remove the dedicated "`insert`" methods with
the generic `DeclEngine::insert` method.
Co-authored-by: emilyaherbert <emily.herbert@fuel.sh>
closes#3622.
closes#3586.
unblocks #3673.
## About this PR
After parsing, I added a check to remove tests from `AstTree` if tests
are not enabled. Since all the other checks are done after this
exclusion of tests, this PR also prevents warnings and errors coming
from test functions to be emitted while using `forc build`. They are
still visible with `forc test` as they should be.
Previous to this PR, `forc_pkg::check()` would only return the
`ParseProgram` and `TyProgram` AST's. In the language server, we now
also need access to the initial lexing stage produced by `sway_parse` in
order to get access to the sway keyword tokens.
This PR now returns the lexing stage of a program along with the parsed
and typed stages.
closes#3524
This PR removes the global `DeclarationEngine` in favor of keeping a
local copy in the `TypeCheckContext`.
This PR is pretty big... there aren't any additional things added other
than what I """ had to add """ in order to complete this task. At a high
level:
- This PR introduces the `Engines` struct, which has two fields
`type_engine: &TypeEngine` and `declaration_engine: &DeclarationEngine`.
- For most/many of the traits introduced in #3353, this PR changes these
traits to take a `Engines` instead of a `&TypeEngine`
Closes#2063
Co-authored-by: emilyaherbert <emily.herbert@fuel.sh>
closes#3358.
## Summary
This PR adds workspace support to `forc-test`. Executing `forc test` in
a workspace runs all tests coming from the members of the workspace and
outputs them formatted separately. An example of the output can be seen
below. I also added workspace unit test support to testing suite and
added a `should_pass/unit_tests/` test with a workspace.
<img width="419" alt="image"
src="https://user-images.githubusercontent.com/20915464/206710608-b65fd509-6131-4ab0-8393-27bc220b220d.png">
This is a minimal start at documenting the Sway unit testing feature
provided via `forc test`.
We should continue to extend this as we land new features like contract
calling, dev-dependencies, `#[test(should_revert)]`, etc.