diff --git a/contracts/core/src/execute/rebalance/finalize.rs b/contracts/core/src/execute/rebalance/finalize.rs index 8cc527f..bf7e6aa 100644 --- a/contracts/core/src/execute/rebalance/finalize.rs +++ b/contracts/core/src/execute/rebalance/finalize.rs @@ -53,7 +53,7 @@ pub fn finalize(deps: DepsMut, env: Env, info: MessageInfo) -> StdResult>() .into(), )?; @@ -232,4 +232,60 @@ mod tests { .is_none()); } } + + #[rstest] + #[case( + "manager", + vec![("uatom", "0.0")].into(), + vec![("uatom", "0.0")].into(), + Some(Rebalance { + manager: Some(Addr::unchecked("manager")), + deflation: vec![("uatom", "0")].into(), + inflation: Units::default(), + }), + Units::default(), + )] + #[case( + "manager", + vec![("uatom", "0.89")].into(), + vec![("uatom", "0.0")].into(), + Some(Rebalance { + manager: Some(Addr::unchecked("manager")), + deflation: vec![("uatom", "0.90")].into(), + inflation: Units::default(), + }), + vec![("uatom", "0.89")].into(), + )] + fn test_pruning( + #[case] sender: &str, + #[case] index_units: Units, + #[case] reserve_units: Units, + #[case] rebalance: Option, + #[case] after_index_units: Units, + ) { + let env = mock_env(); + let mut deps = mock_dependencies(); + + FEE.save(deps.as_mut().storage, &Fee::default()).unwrap(); + + INDEX_UNITS + .save(deps.as_mut().storage, &index_units) + .unwrap(); + + RESERVE_UNITS + .save(deps.as_mut().storage, &reserve_units) + .unwrap(); + + REBALANCE.remove(deps.as_mut().storage); + if let Some(rebalance) = rebalance { + REBALANCE.save(deps.as_mut().storage, &rebalance).unwrap(); + } + + finalize(deps.as_mut(), env.clone(), mock_info(sender, &[])).unwrap(); + + assert_eq!( + INDEX_UNITS.load(deps.as_ref().storage).unwrap(), + after_index_units + ); + } } diff --git a/integration-test/tests/proposal.rs b/integration-test/tests/proposal.rs new file mode 100644 index 0000000..e6c7966 --- /dev/null +++ b/integration-test/tests/proposal.rs @@ -0,0 +1,16 @@ +use cosmwasm_std::{to_json_binary, CosmosMsg, WasmMsg}; + +use ibcx_interface::core; + +#[test] +fn test_proposal() { + let msgs: Vec = vec![WasmMsg::Migrate { + contract_addr: "osmo14klwqgkmackvx2tqa0trtg69dmy0nrg4ntq4gjgw2za4734r5seqjqm4gm" + .to_string(), + new_code_id: 455, + msg: to_json_binary(&core::MigrateMsg { force: None }).unwrap(), + } + .into()]; + + println!("{}", serde_json_wasm::to_string(&msgs).unwrap()); +}