forked from stellar/soroban-examples
-
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.
Change the events contract to be an adaption of the increment example (…
- Loading branch information
1 parent
395d839
commit 2b29013
Showing
2 changed files
with
57 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,37 @@ | ||
#![cfg(test)] | ||
|
||
use super::*; | ||
use soroban_sdk::{symbol, Env}; | ||
use soroban_sdk::{testutils::Events, vec, Env, IntoVal}; | ||
|
||
#[test] | ||
fn test() { | ||
let env = Env::default(); | ||
let contract_id = env.register_contract(None, EventsContract); | ||
let client = EventsContractClient::new(&env, &contract_id); | ||
let contract_id = env.register_contract(None, IncrementContract); | ||
let client = IncrementContractClient::new(&env, &contract_id); | ||
|
||
client.hello(&symbol!("Dev")); | ||
assert_eq!(client.increment(), 1); | ||
assert_eq!(client.increment(), 2); | ||
assert_eq!(client.increment(), 3); | ||
|
||
assert_eq!( | ||
env.events().all(), | ||
vec![ | ||
&env, | ||
( | ||
contract_id.clone(), | ||
(symbol!("COUNTER"), symbol!("increment")).into_val(&env), | ||
1u32.into_val(&env) | ||
), | ||
( | ||
contract_id.clone(), | ||
(symbol!("COUNTER"), symbol!("increment")).into_val(&env), | ||
2u32.into_val(&env) | ||
), | ||
( | ||
contract_id.clone(), | ||
(symbol!("COUNTER"), symbol!("increment")).into_val(&env), | ||
3u32.into_val(&env) | ||
), | ||
] | ||
); | ||
} |