-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description The `Output` enum did not have the `ContractCreated` variant. This has been added as well as a test to ensure this output type is returned when a contact is deployed with a predicate in the inputs. `Eq` for `Output` has also been added. ## 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). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [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: K1-R1 <[email protected]>
- Loading branch information
Showing
11 changed files
with
217 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
test/src/in_language_tests/test_programs/output_inline_tests/Forc.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "output_inline_tests" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../sway-lib-std" } |
46 changes: 46 additions & 0 deletions
46
test/src/in_language_tests/test_programs/output_inline_tests/src/main.sw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
library; | ||
|
||
use std::outputs::Output; | ||
|
||
#[test] | ||
fn output_output_eq() { | ||
let output_1 = Output::Coin; | ||
let output_2 = Output::Coin; | ||
let output_3 = Output::Contract; | ||
let output_4 = Output::Contract; | ||
let output_5 = Output::Change; | ||
let output_6 = Output::Change; | ||
let output_7 = Output::Variable; | ||
let output_8 = Output::Variable; | ||
let output_9 = Output::ContractCreated; | ||
let output_10 = Output::ContractCreated; | ||
|
||
assert(output_1 == output_2); | ||
assert(output_3 == output_4); | ||
assert(output_5 == output_6); | ||
assert(output_7 == output_8); | ||
assert(output_9 == output_10); | ||
} | ||
|
||
#[test] | ||
fn output_output_neq() { | ||
let output_1 = Output::Coin; | ||
let output_2 = Output::Contract; | ||
let output_3 = Output::Change; | ||
let output_4 = Output::Variable; | ||
let output_5 = Output::ContractCreated; | ||
|
||
assert(output_1 != output_2); | ||
assert(output_1 != output_3); | ||
assert(output_1 != output_4); | ||
assert(output_1 != output_5); | ||
|
||
assert(output_2 != output_3); | ||
assert(output_2 != output_4); | ||
assert(output_2 != output_5); | ||
|
||
assert(output_3 != output_4); | ||
assert(output_3 != output_5); | ||
|
||
assert(output_4 != output_5); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
test/src/sdk-harness/test_artifacts/tx_output_contract_creation_predicate/Forc.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[[package]] | ||
name = "core" | ||
source = "path+from-root-1EABD6DBC885D01E" | ||
|
||
[[package]] | ||
name = "std" | ||
source = "path+from-root-1EABD6DBC885D01E" | ||
dependencies = ["core"] | ||
|
||
[[package]] | ||
name = "tx_output_contract_creation_predicate" | ||
source = "member" | ||
dependencies = ["std"] |
8 changes: 8 additions & 0 deletions
8
test/src/sdk-harness/test_artifacts/tx_output_contract_creation_predicate/Forc.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "tx_output_contract_creation_predicate" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../sway-lib-std" } |
7 changes: 7 additions & 0 deletions
7
test/src/sdk-harness/test_artifacts/tx_output_contract_creation_predicate/src/main.sw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
predicate; | ||
|
||
use std::outputs::{Output, output_type}; | ||
|
||
fn main() -> bool { | ||
output_type(2) == Output::ContractCreated | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters