From 5dc4e29fa3e39ed42ceb286961353b38c67feab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wo=C5=BAniak?= Date: Mon, 5 Feb 2024 15:51:56 +0100 Subject: [PATCH] test: Add sudo to custom example --- examples/contracts/custom/src/contract.rs | 9 ++++++++- examples/contracts/custom/src/multitest/tests.rs | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/examples/contracts/custom/src/contract.rs b/examples/contracts/custom/src/contract.rs index df0806a7..f6727e18 100644 --- a/examples/contracts/custom/src/contract.rs +++ b/examples/contracts/custom/src/contract.rs @@ -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"))] @@ -42,4 +42,11 @@ impl CustomContract { Ok(resp) } + + #[msg(sudo)] + pub fn sudo_custom(&self, _ctx: SudoCtx) -> StdResult> { + let msg = CosmosMsg::Custom(CounterMsg::Increment {}); + let resp = Response::default().add_message(msg); + Ok(resp) + } } diff --git a/examples/contracts/custom/src/multitest/tests.rs b/examples/contracts/custom/src/multitest/tests.rs index 566ee7ff..45860e7a 100644 --- a/examples/contracts/custom/src/multitest/tests.rs +++ b/examples/contracts/custom/src/multitest/tests.rs @@ -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); }