Skip to content

Commit 26fb6fe

Browse files
committed
increase time before querying total staked, and fixed height in execute fn
1 parent 472b7c5 commit 26fb6fe

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

contracts/voting/dao-voting-cosmos-staked/src/contract.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,13 @@ pub fn execute_update_total_staked(
5454
amount: Uint128,
5555
height: Option<u64>,
5656
) -> Result<Response, ContractError> {
57-
STAKED_TOTAL.save(deps.storage, &amount, env.block.height)?;
57+
let height = height.unwrap_or(env.block.height);
58+
STAKED_TOTAL.save(deps.storage, &amount, height)?;
5859

5960
Ok(Response::new()
6061
.add_attribute("action", "update_total_staked")
6162
.add_attribute("amount", amount)
62-
.add_attribute("height", height.unwrap_or(env.block.height).to_string()))
63+
.add_attribute("height", height.to_string()))
6364
}
6465

6566
#[cfg_attr(not(feature = "library"), entry_point)]

contracts/voting/dao-voting-cosmos-staked/src/tests/test_tube/integration_tests.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ fn test_staked_voting_power_and_update() {
8282
msgs: vec![CosmosMsg::Stargate {
8383
type_url: "/cosmos.authz.v1beta1.MsgGrant".to_string(),
8484
value: MsgGrant {
85-
granter: dao.contract_addr.to_string(),
86-
grantee: bot.address().to_string(),
85+
granter: dao.contract_addr.clone(),
86+
grantee: bot.address(),
8787
grant: Some(Grant {
8888
authorization: Some(
8989
ContractExecutionAuthorization {
@@ -119,9 +119,6 @@ fn test_staked_voting_power_and_update() {
119119
staker,
120120
)
121121
.unwrap();
122-
123-
app.increase_time(10);
124-
125122
proposal_single
126123
.execute(
127124
&dao_proposal_single::msg::ExecuteMsg::Execute { proposal_id: 1 },
@@ -152,6 +149,9 @@ fn test_staked_voting_power_and_update() {
152149
)
153150
.unwrap();
154151

152+
// Move chain forward so we can update total staked on a new block
153+
app.increase_time(100);
154+
155155
// Query total power
156156
let total_power = vp_contract.query_tp(None).unwrap();
157157
assert_eq!(total_power.power, Uint128::new(100));

0 commit comments

Comments
 (0)