forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable contract calls from unit tests in scripts (FuelLabs#4456)
## Description closes FuelLabs#4161. This PR enables the contract call feature for scripts. We had this feature for the contracts (introduced in FuelLabs#4156) but scripts were missing.
- Loading branch information
1 parent
59919b4
commit 51c2eaf
Showing
19 changed files
with
242 additions
and
42 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions
19
test/src/e2e_vm_tests/test_programs/should_pass/unit_tests/script-contract-calls/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,19 @@ | ||
[[package]] | ||
name = 'contract_to_call' | ||
source = 'member' | ||
dependencies = ['std'] | ||
|
||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-4A05C8C19F99901B' | ||
|
||
[[package]] | ||
name = 'script_multi_test' | ||
source = 'member' | ||
dependencies = ['std'] | ||
contract-dependencies = ['contract_to_call'] | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-4A05C8C19F99901B' | ||
dependencies = ['core'] |
2 changes: 2 additions & 0 deletions
2
test/src/e2e_vm_tests/test_programs/should_pass/unit_tests/script-contract-calls/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,2 @@ | ||
[workspace] | ||
members = ["script_multi_test", "contract_to_call"] |
13 changes: 13 additions & 0 deletions
13
...sts/test_programs/should_pass/unit_tests/script-contract-calls/contract_to_call/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 = 'contract_multi_test' | ||
source = 'member' | ||
dependencies = ['std'] | ||
|
||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-28E4A5A6A7E567F7' | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-28E4A5A6A7E567F7' | ||
dependencies = ['core'] |
8 changes: 8 additions & 0 deletions
8
...sts/test_programs/should_pass/unit_tests/script-contract-calls/contract_to_call/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 = "contract_to_call" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../../../../sway-lib-std" } |
11 changes: 11 additions & 0 deletions
11
...s/test_programs/should_pass/unit_tests/script-contract-calls/contract_to_call/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,11 @@ | ||
contract; | ||
|
||
abi MyContract { | ||
fn test_false() -> bool; | ||
} | ||
|
||
impl MyContract for Contract { | ||
fn test_false() -> bool { | ||
false | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...ts/test_programs/should_pass/unit_tests/script-contract-calls/script_multi_test/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 = 'contract_multi_test' | ||
source = 'member' | ||
dependencies = ['std'] | ||
|
||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-28E4A5A6A7E567F7' | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-28E4A5A6A7E567F7' | ||
dependencies = ['core'] |
11 changes: 11 additions & 0 deletions
11
...ts/test_programs/should_pass/unit_tests/script-contract-calls/script_multi_test/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,11 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "script_multi_test" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../../../../sway-lib-std" } | ||
|
||
[contract-dependencies] | ||
contract_to_call = { path = "../contract_to_call/" } |
14 changes: 14 additions & 0 deletions
14
.../test_programs/should_pass/unit_tests/script-contract-calls/script_multi_test/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,14 @@ | ||
script; | ||
|
||
abi MyContract { | ||
fn test_false() -> bool; | ||
} | ||
|
||
fn main() {} | ||
|
||
#[test] | ||
fn test_contract_call() { | ||
let caller = abi(MyContract, contract_to_call::CONTRACT_ID); | ||
let result = caller.test_false(); | ||
assert(result == false) | ||
} |
1 change: 1 addition & 0 deletions
1
test/src/e2e_vm_tests/test_programs/should_pass/unit_tests/script-contract-calls/test.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 @@ | ||
category = "unit_tests_pass" |