use std::str::FromStr;
use cosmwasm_std::{coins, Addr, BlockInfo, Decimal, Timestamp};
use counter_contract::{
msg::{ExecuteMsg, GetCountResponse, InstantiateMsg, QueryMsg},
CounterContract,
};
use cw_orch::prelude::*;
pub fn main() {
env_logger::init();
let sender = Addr::unchecked("juno16g2rahf5846rxzp3fwlswy08fz8ccuwk03k57y");
let mock = Mock::new(&sender);
let contract_counter = CounterContract::new(mock);
let upload_res = contract_counter.upload();
upload_res.unwrap();
let init_res = contract_counter.instantiate(&InstantiateMsg { count: 0 }, Some(&sender), &[]);
init_res.unwrap();
let exec_res = contract_counter.execute(&ExecuteMsg::Increment {}, &[]);
exec_res.unwrap();
let query_res = contract_counter.query::<GetCountResponse>(&QueryMsg::GetCount {});
assert_eq!(query_res.unwrap().count, 1);
}
pub fn customize() {
let mock = Mock::new("juno16g2rahf5846rxzp3fwlswy08fz8ccuwk03k57y");
let mut contract_counter = CounterContract::new(mock.clone());
let new_sender = Addr::unchecked("entirely-new-sender");
mock.set_balance(&new_sender, coins(100_000, "ujunox"))
.unwrap();
contract_counter.call_as(&new_sender).upload().unwrap();
contract_counter.set_sender(&new_sender);
mock.app
.borrow_mut()
.init_modules(|router, api, storage| {
router.staking.add_validator(
api,
storage,
&BlockInfo {
height: 16736,
time: Timestamp::from_seconds(13345762376),
chain_id: "juno-1".to_string(),
},
cosmwasm_std::Validator::create(
"new-validator-address".to_string(),
Decimal::from_str("0.5").unwrap(), Decimal::from_str("1").unwrap(), Decimal::from_str("1").unwrap(), ),
)
})
.unwrap();
}