Skip to content

Commit

Permalink
test: Add sudo to custom example
Browse files Browse the repository at this point in the history
  • Loading branch information
jawoznia committed Feb 5, 2024
1 parent 6397a4a commit 5dc4e29
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion examples/contracts/custom/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_std::{CosmosMsg, QueryRequest, Response, StdResult};
use sylvia::types::{ExecCtx, InstantiateCtx, QueryCtx};
use sylvia::types::{ExecCtx, InstantiateCtx, QueryCtx, SudoCtx};
use sylvia::{contract, schemars};

#[cfg(not(feature = "library"))]
Expand Down Expand Up @@ -42,4 +42,11 @@ impl CustomContract {

Ok(resp)
}

#[msg(sudo)]
pub fn sudo_custom(&self, _ctx: SudoCtx<CounterQuery>) -> StdResult<Response<CounterMsg>> {
let msg = CosmosMsg::Custom(CounterMsg::Increment {});
let resp = Response::default().add_message(msg);
Ok(resp)
}
}
5 changes: 5 additions & 0 deletions examples/contracts/custom/src/multitest/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ fn test_custom() {

let count = contract.query_custom().unwrap().count;
assert_eq!(count, 1);

contract.sudo_custom().unwrap();

let count = contract.query_custom().unwrap().count;
assert_eq!(count, 2);
}

0 comments on commit 5dc4e29

Please sign in to comment.