-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added multiindex for #20 * Moved tests to separate module --------- Co-authored-by: Alpo <[email protected]>
- Loading branch information
1 parent
d62d528
commit ca96a0e
Showing
7 changed files
with
258 additions
and
259 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,9 +1,12 @@ | ||
pub mod contract; | ||
mod error; | ||
pub mod msg; | ||
pub mod types; | ||
pub mod state; | ||
mod orderbook; | ||
mod order; | ||
mod orderbook; | ||
pub mod state; | ||
pub mod types; | ||
|
||
#[cfg(test)] | ||
pub mod tests; | ||
|
||
pub use crate::error::ContractError; |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod test_orderbook; | ||
pub mod test_state; |
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,42 @@ | ||
use crate::{ | ||
orderbook::*, | ||
state::{MAX_TICK, MIN_TICK, ORDERBOOKS}, | ||
}; | ||
use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; | ||
|
||
#[test] | ||
fn test_create_orderbook() { | ||
let mut deps = mock_dependencies(); | ||
let env = mock_env(); | ||
let info = mock_info("creator", &[]); | ||
|
||
// Attempt to create an orderbook | ||
let quote_denom = "quote".to_string(); | ||
let base_denom = "base".to_string(); | ||
let create_response = create_orderbook( | ||
deps.as_mut(), | ||
env, | ||
info, | ||
quote_denom.clone(), | ||
base_denom.clone(), | ||
) | ||
.unwrap(); | ||
|
||
// Verify response | ||
let expected_book_id: u64 = 0; | ||
assert_eq!(create_response.attributes[0], ("method", "createOrderbook")); | ||
assert_eq!( | ||
create_response.attributes[1], | ||
("book_id", &expected_book_id.to_string()) | ||
); | ||
|
||
// Verify orderbook is saved correctly | ||
let orderbook = ORDERBOOKS | ||
.load(deps.as_ref().storage, &expected_book_id) | ||
.unwrap(); | ||
assert_eq!(orderbook.quote_denom, quote_denom); | ||
assert_eq!(orderbook.base_denom, base_denom); | ||
assert_eq!(orderbook.current_tick, 0); | ||
assert_eq!(orderbook.next_bid_tick, MIN_TICK); | ||
assert_eq!(orderbook.next_ask_tick, MAX_TICK); | ||
} |
Oops, something went wrong.