diff --git a/packages/injective-test-tube/src/module/auction.rs b/packages/injective-test-tube/src/module/auction.rs new file mode 100644 index 0000000..503f48a --- /dev/null +++ b/packages/injective-test-tube/src/module/auction.rs @@ -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(),); + } +} diff --git a/packages/injective-test-tube/src/module/mod.rs b/packages/injective-test-tube/src/module/mod.rs index e8ba26d..e63044f 100644 --- a/packages/injective-test-tube/src/module/mod.rs +++ b/packages/injective-test-tube/src/module/mod.rs @@ -1,3 +1,4 @@ +mod auction; mod authz; mod bank; mod exchange; @@ -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; diff --git a/packages/injective-test-tube/src/module/oracle.rs b/packages/injective-test-tube/src/module/oracle.rs index 178b04d..8078068 100644 --- a/packages/injective-test-tube/src/module/oracle.rs +++ b/packages/injective-test-tube/src/module/oracle.rs @@ -138,8 +138,6 @@ mod tests { ) .unwrap(); - println!("{:#?}", res); - let proposal_id = res .events .iter()