Skip to content

Commit

Permalink
progress on 3 chain test
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberHoward committed May 30, 2024
1 parent 6809ecf commit d527fec
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
2 changes: 1 addition & 1 deletion contracts/interchain-gov/src/handlers/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ pub fn finalize(
Ok(msg)
})
.collect::<AbstractSdkResult<Vec<CosmosMsg>>>()?;

Ok(app
.response("finalize")
.add_attribute("prop_id", prop_id)
Expand Down
2 changes: 0 additions & 2 deletions contracts/interchain-gov/src/handlers/module_ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,12 @@ pub fn module_ibc_handler(

// update proposal state to "proposed". Member will vote `NoVote` on the proposal by default
PROPOSAL_STATE_SYNC.propose_kv_state(deps.storage, prop_hash, (prop, Vote::NoVote))?;

Ok(app
.response("module_ibc")
.add_attribute("action", "propose"))
}
InterchainGovIbcMsg::FinalizeProposal { prop_hash: prop_id } => {
PROPOSAL_STATE_SYNC.finalize_kv_state(deps.storage, prop_id, None)?;

Ok(app
.response("module_ibc")
.add_attribute("action", "finalize"))
Expand Down
2 changes: 1 addition & 1 deletion contracts/interchain-gov/src/ibc_callbacks/finalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn finalize_callback(
prop_hash: _prop_id,
} => {
PROPOSAL_STATE_SYNC.apply_ack(deps.storage, proposed_to)?;

if !PROPOSAL_STATE_SYNC.has_outstanding_acks(deps.storage)? {
// finalize my proposal
MEMBERS_STATE_SYNC.finalize_members(deps.storage, None)?;
Expand Down
38 changes: 34 additions & 4 deletions contracts/interchain-gov/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ mod members {

use abstract_interchain_tests::setup::ibc_connect_abstract;
use cw_orch_interchain::MockBech32InterchainEnv;
use interchain_gov::msg::InterchainGovExecuteMsgFns;
use interchain_gov::{msg::InterchainGovExecuteMsgFns, state::Vote};

use super::*;

Expand Down Expand Up @@ -528,6 +528,8 @@ mod members {
b_env.enable_ibc()?;
c_env.enable_ibc()?;

a_env.test_register_gov_modules(vec![(b_env.chain_name(), b_env.gov.clone())])?;

// ibc_connect_polytone_and_abstract(&interchain, A_CHAIN_ID, B_CHAIN_ID)?;
// ibc_connect_polytone_and_abstract(&interchain, A_CHAIN_ID, C_CHAIN_ID)?;
// ibc_connect_polytone_and_abstract(&interchain, B_CHAIN_ID, A_CHAIN_ID)?;
Expand All @@ -545,6 +547,7 @@ mod members {

let a_gov = a_env.gov.clone();
let b_gov = b_env.gov.clone();
let c_gov = c_env.gov.clone();

// Propose a proposal
let (res, prop_id) = a_env.propose_first_member_proposal(
Expand Down Expand Up @@ -579,14 +582,41 @@ mod members {

a_env.assert_prop_state(prop_id.clone(), None)?;
b_env.assert_prop_state(prop_id.clone(), Some(DataState::Proposed))?;
c_env.assert_prop_state(prop_id.clone(), Some(DataState::Proposed))?;

a_gov.finalize(prop_id.clone())?;
let a = a_gov.finalize(prop_id.clone())?;
let res = interchain.wait_ibc(A_CHAIN_ID, a)?;
dbg!(&res.packets[0].outcome);

a_env.assert_prop_state(prop_id.clone(), None)?;
b_env.assert_prop_state(prop_id.clone(), None)?;
c_env.assert_prop_state(prop_id.clone(), None)?;


// find proposal
let prop = a_gov.proposal(prop_id.clone())?;
assert_eq!(prop.prop_id, prop_id.clone());
let prop = b_gov.proposal(prop_id.clone())?;
assert_eq!(prop.prop_id, prop_id.clone());

a_gov.vote_proposal(interchain_gov::state::Governance::Manual { }, prop_id.clone(), Vote::Yes)?;
b_gov.vote_proposal(interchain_gov::state::Governance::Manual { }, prop_id.clone(), Vote::Yes)?;

// Wait the test blocks after voting
a_env.wait_blocks(TEST_PROP_LEN + 1)?;
b_env.wait_blocks(TEST_PROP_LEN + 1)?;
c_env.wait_blocks(TEST_PROP_LEN + 1)?;

let res = a_gov.request_vote_results(prop_id.clone())?;
let res = interchain.wait_ibc(A_CHAIN_ID, res)?;
dbg!(&res.packets[0].outcome);

// a_gov.execute_proposal(prop_id.clone())?;

let a_members = dbg!(a_gov.members()?);
assert_eq!(a_members.members.members.len(), 3);
// let b_members = dbg!(b_gov.members()?);
// assert_eq!(b_members.members.members.len(), 3);
// let c_members = dbg!(c_gov.members()?);
// assert_eq!(c_members.members.members.len(), 3);
Ok(())
}
}
Expand Down

0 comments on commit d527fec

Please sign in to comment.