Skip to content

Commit

Permalink
fix: add auction tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maxrobot committed Sep 25, 2024
1 parent 1f59e58 commit 652d5b6
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 2 deletions.
73 changes: 73 additions & 0 deletions packages/injective-test-tube/src/module/auction.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
use injective_std::types::injective::auction::v1beta1::{
QueryAuctionParamsRequest, QueryAuctionParamsResponse, QueryCurrentAuctionBasketRequest,
QueryCurrentAuctionBasketResponse, QueryLastAuctionResultRequest,
QueryLastAuctionResultResponse, QueryModuleStateRequest, QueryModuleStateResponse,
};
use test_tube_inj::fn_query;

use test_tube_inj::module::Module;
use test_tube_inj::runner::Runner;

pub struct Auction<'a, R: Runner<'a>> {
runner: &'a R,
}

impl<'a, R: Runner<'a>> Module<'a, R> for Auction<'a, R> {
fn new(runner: &'a R) -> Self {
Self { runner }
}
}

impl<'a, R> Auction<'a, R>
where
R: Runner<'a>,
{
fn_query! {
pub query_auction_params ["/injective.auction.v1beta1.Query/AuctionParams"]: QueryAuctionParamsRequest => QueryAuctionParamsResponse
}

fn_query! {
pub query_current_auction_basket ["/injective.auction.v1beta1.Query/CurrentAuctionBasket"]: QueryCurrentAuctionBasketRequest => QueryCurrentAuctionBasketResponse
}

fn_query! {
pub query_module_state ["/injective.auction.v1beta1.Query/ModuleState"]: QueryModuleStateRequest => QueryModuleStateResponse
}

fn_query! {
pub query_last_auction_result ["/injective.auction.v1beta1.Query/LastAuctionResult"]: QueryLastAuctionResultRequest => QueryLastAuctionResultResponse
}
}

#[cfg(test)]
mod tests {
use injective_std::types::injective::auction::v1beta1::{
Params, QueryAuctionParamsRequest, QueryLastAuctionResultRequest,
};

use crate::{Auction, InjectiveTestApp};
use test_tube_inj::Module;

#[test]
fn auction_integration() {
let app = InjectiveTestApp::new();

let auction = Auction::new(&app);

let response = auction
.query_auction_params(&QueryAuctionParamsRequest {})
.unwrap();
assert_eq!(
response.params,
Some(Params {
auction_period: 604800,
min_next_bid_increment_rate: 2_500_000_000_000_000u128.to_string()
})
);

let response = auction
.query_last_auction_result(&QueryLastAuctionResultRequest {})
.unwrap();
assert!(response.last_auction_result.is_some(),);
}
}
2 changes: 2 additions & 0 deletions packages/injective-test-tube/src/module/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod auction;
mod authz;
mod bank;
mod exchange;
Expand All @@ -12,6 +13,7 @@ mod wasmx;
pub use test_tube_inj::macros;
pub use test_tube_inj::module::Module;

pub use auction::Auction;
pub use authz::Authz;
pub use bank::Bank;
pub use exchange::Exchange;
Expand Down
2 changes: 0 additions & 2 deletions packages/injective-test-tube/src/module/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ mod tests {
)
.unwrap();

println!("{:#?}", res);

let proposal_id = res
.events
.iter()
Expand Down

0 comments on commit 652d5b6

Please sign in to comment.