-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
55 additions
and
11 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
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
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 |
---|---|---|
|
@@ -2,4 +2,7 @@ pub mod contract; | |
mod error; | ||
pub mod msg; | ||
|
||
#[cfg(test)] | ||
mod tests; | ||
|
||
pub use crate::error::VaultError; |
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
25 changes: 25 additions & 0 deletions
25
smart-contracts/contracts/babylon-vault/src/tests/instantiate.rs
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,25 @@ | ||
use crate::msg::InstantiateMsg; | ||
use crate::tests::setup::Vault; | ||
use cosmwasm_std::{Addr, Event}; | ||
use cw_orch::contract::interface_traits::{CwOrchInstantiate, CwOrchUpload}; | ||
use cw_orch::mock::Mock; | ||
|
||
#[test] | ||
fn test_instantiate() { | ||
let sender = Addr::unchecked("sender"); | ||
let chain = Mock::new(&sender); | ||
|
||
let vault: Vault<Mock> = Vault::new("vault", chain); | ||
vault.upload().unwrap(); | ||
|
||
let result = vault.instantiate(&InstantiateMsg {}, None, None); | ||
assert!(result.is_ok()); | ||
let response = result.unwrap(); | ||
assert_eq!(response.events.len(), 1); | ||
assert_eq!( | ||
response.events[0], | ||
Event::new("instantiate") | ||
.add_attribute("_contract_address", "contract0") | ||
.add_attribute("code_id", "1") | ||
); | ||
} |
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 @@ | ||
pub mod instantiate; | ||
pub mod setup; |
16 changes: 16 additions & 0 deletions
16
smart-contracts/contracts/babylon-vault/src/tests/setup.rs
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,16 @@ | ||
use crate::{ | ||
contract::{execute, instantiate, query}, | ||
msg::{ExecuteMsg, InstantiateMsg, QueryMsg}, | ||
}; | ||
use cosmwasm_std::Empty; | ||
use cw_orch::interface; | ||
use cw_orch::prelude::*; | ||
|
||
#[interface(InstantiateMsg, ExecuteMsg, QueryMsg, Empty)] | ||
pub struct Vault; | ||
|
||
impl<Chain> Uploadable for Vault<Chain> { | ||
fn wrapper() -> Box<dyn MockContract<Empty>> { | ||
Box::new(ContractWrapper::new_with_empty(execute, instantiate, query)) | ||
} | ||
} |