-
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: add constructor args example (#2)
* feat: add constructor args example Update `increment` to have a `__constructor` as well as a `get` to make it a more useful and realistic example, as well as giving us a way to test constructor args. Also: - add a test for it - upgrade to p22 for whole workspace - gitignore test_snapshots
- Loading branch information
Showing
10 changed files
with
36 additions
and
150 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
#![cfg(test)] | ||
|
||
use super::{IncrementContract, IncrementContractClient}; | ||
use soroban_sdk::{testutils::Logs, Env}; | ||
use soroban_sdk::{testutils::Logs, vec, xdr::ScVal, Env}; | ||
|
||
extern crate std; | ||
|
||
#[test] | ||
fn test() { | ||
fn construct_get_increment() { | ||
let env = Env::default(); | ||
let contract_id = env.register_contract(None, IncrementContract); | ||
let contract_id = env.register(IncrementContract, vec![&env, ScVal::U32(42)]); | ||
let client = IncrementContractClient::new(&env, &contract_id); | ||
|
||
assert_eq!(client.increment(), 1); | ||
assert_eq!(client.increment(), 2); | ||
assert_eq!(client.increment(), 3); | ||
assert_eq!(client.get(), 42); | ||
assert_eq!(client.increment(), 43); | ||
assert_eq!(client.increment(), 44); | ||
assert_eq!(client.increment(), 45); | ||
|
||
std::println!("{}", env.logs().all().join("\n")); | ||
} |
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 was deleted.
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