-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test vector for workspace setups where contract types live in a l…
…ib (#1070) ### What Add test vector for workspace setups where contract types live in a lib. ### Why In #1063 it was mentioned that folks were having trouble with using types in other libs. Added this test vector to confirm if that was an issue or not. Appears to work fine, and this is a use case that is important, so committing the test vector.
- Loading branch information
1 parent
535a9dd
commit c844b88
Showing
8 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Binary file not shown.
Binary file not shown.
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,20 @@ | ||
[package] | ||
name = "test_workspace_contract" | ||
version.workspace = true | ||
authors = ["Stellar Development Foundation <info@stellar.org>"] | ||
license = "Apache-2.0" | ||
edition = "2021" | ||
publish = false | ||
rust-version = "1.71" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
doctest = false | ||
|
||
[dependencies] | ||
soroban-sdk = {path = "../../soroban-sdk"} | ||
test_workspace_lib = {path = "../workspace_lib"} | ||
|
||
[dev-dependencies] | ||
soroban-sdk = {path = "../../soroban-sdk", features = ["testutils"]} | ||
test_workspace_lib = {path = "../workspace_lib", features = ["testutils"]} |
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,31 @@ | ||
#![no_std] | ||
use soroban_sdk::{contract, contractimpl}; | ||
|
||
use test_workspace_lib::Value; | ||
|
||
#[contract] | ||
pub struct Contract; | ||
|
||
#[contractimpl] | ||
impl Contract { | ||
pub fn value() -> Value { | ||
return Value { value: 13 }; | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use super::*; | ||
use soroban_sdk::Env; | ||
|
||
#[test] | ||
fn test_add() { | ||
let e = Env::default(); | ||
|
||
let contract_id = e.register_contract(None, Contract); | ||
let client = ContractClient::new(&e, &contract_id); | ||
|
||
let z = client.value(); | ||
assert_eq!(z, Value { value: 13 }); | ||
} | ||
} |
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,21 @@ | ||
[package] | ||
name = "test_workspace_lib" | ||
version.workspace = true | ||
authors = ["Stellar Development Foundation <info@stellar.org>"] | ||
license = "Apache-2.0" | ||
edition = "2021" | ||
publish = false | ||
rust-version = "1.71" | ||
|
||
[lib] | ||
crate-type = ["rlib"] | ||
doctest = false | ||
|
||
[features] | ||
testutils = [] | ||
|
||
[dependencies] | ||
soroban-sdk = {path = "../../soroban-sdk"} | ||
|
||
[dev-dependencies] | ||
soroban-sdk = {path = "../../soroban-sdk", features = ["testutils"]} |
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 @@ | ||
#![no_std] | ||
use soroban_sdk::contracttype; | ||
|
||
#[contracttype] | ||
#[derive(Debug, Eq, PartialEq)] | ||
pub struct Value { | ||
pub value: i32, | ||
} |