Skip to content

Commit

Permalink
refactor(integration-tests): move get_dr_id to util function
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesondh committed Sep 28, 2023
1 parent 949ef55 commit 0d9599a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
7 changes: 2 additions & 5 deletions packages/integration-tests/src/data_request.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::tests::utils::{proper_instantiate, USER};
use crate::tests::utils::{get_dr_id, proper_instantiate, USER};
use common::msg::{GetDataRequestResponse, GetDataRequestsFromPoolResponse, PostDataRequestArgs};
use common::types::{Bytes, Hash};
use cosmwasm_std::Addr;
Expand Down Expand Up @@ -67,10 +67,7 @@ fn post_data_request() {
assert!(app.execute(Addr::unchecked(USER), cosmos_msg).is_err());

// should be able to fetch data request
// TODO: this is an ugly way to get the dr_id.
// although PostDataRequest on the DataRequest contract returns it in `data`, the Proxy contract does not yet.
// https://github.com/sedaprotocol/seda-chain-contracts/issues/68
let dr_id = &res.events.last().unwrap().attributes[2].value;
let dr_id = get_dr_id(res);

let msg = ProxyQueryMsg::GetDataRequest {
dr_id: dr_id.clone(),
Expand Down
14 changes: 5 additions & 9 deletions packages/integration-tests/src/data_result.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::tests::utils::{proper_instantiate, send_tokens, EXECUTOR_1, EXECUTOR_2, USER};
use crate::tests::utils::{
get_dr_id, proper_instantiate, send_tokens, EXECUTOR_1, EXECUTOR_2, USER,
};
use common::msg::{
GetCommittedDataResultResponse, GetResolvedDataResultResponse, GetRevealedDataResultResponse,
PostDataRequestArgs,
Expand Down Expand Up @@ -92,10 +94,7 @@ fn commit_reveal_result() {
.unwrap();

// get dr_id
// TODO: this is an ugly way to get the dr_id.
// although PostDataRequest on the DataRequest contract returns it in `data`, the Proxy contract does not yet.
// https://github.com/sedaprotocol/seda-chain-contracts/issues/68
let dr_id = &res.events.last().unwrap().attributes[2].value;
let dr_id = get_dr_id(res);

// executor1 commits on the data request
let reveal = "2000";
Expand Down Expand Up @@ -243,10 +242,7 @@ fn ineligible_post_data_result() {
.unwrap();

// get dr_id
// TODO: this is an ugly way to get the dr_id.
// although PostDataRequest on the DataRequest contract returns it in `data`, the Proxy contract does not yet.
// https://github.com/sedaprotocol/seda-chain-contracts/issues/68
let dr_id = &res.events.last().unwrap().attributes[2].value;
let dr_id = get_dr_id(res);

// ineligible shouldn't be able to post a data result
let reveal = "2000";
Expand Down
9 changes: 8 additions & 1 deletion packages/integration-tests/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_std::{to_binary, Addr, BankMsg, Coin, CosmosMsg, Empty, StdResult, Uint128, WasmMsg};
use cw_multi_test::{App, AppBuilder, Contract, ContractWrapper, Executor};
use cw_multi_test::{App, AppBuilder, AppResponse, Contract, ContractWrapper, Executor};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -174,3 +174,10 @@ pub fn proper_instantiate() -> (App, CwTemplateContract) {

(app, proxy_template_contract)
}

pub fn get_dr_id(res: AppResponse) -> String {
// TODO: this is an ugly way to get the dr_id.
// although PostDataRequest on the DataRequest contract returns it in `data`, the Proxy contract does not yet.
// https://github.com/sedaprotocol/seda-chain-contracts/issues/68
res.events.last().unwrap().attributes[2].value.clone()
}

0 comments on commit 0d9599a

Please sign in to comment.