Skip to content

Commit dd178f9

Browse files
authored
Merge pull request #2161 from CosmWasm/mergify/bp/release/2.0/pr-2160
Add message_info and deprecate mock_info (backport #2160)
2 parents 204493f + 5a5acd0 commit dd178f9

File tree

19 files changed

+329
-178
lines changed

19 files changed

+329
-178
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ and this project adheres to
1414

1515
[#2158]: https://github.com/CosmWasm/cosmwasm/pull/2158
1616

17+
### Changed
18+
19+
- cosmwasm-std: Add message_info and deprecate mock_info ([#2160])
20+
21+
[#2160]: https://github.com/CosmWasm/cosmwasm/pull/2160
22+
1723
## [2.0.3] - 2024-05-10
1824

1925
### Changed

MIGRATING.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This guide explains what is needed to upgrade contracts when migrating over
44
major releases of `cosmwasm`. Note that you can also view the
55
[complete CHANGELOG](./CHANGELOG.md) to understand the differences.
66

7-
## 1.5.x -> 2.0.0
7+
## 1.5.x -> 2.0.x
88

99
- Update `cosmwasm-*` dependencies in Cargo.toml (skip the ones you don't use):
1010

@@ -262,6 +262,10 @@ major releases of `cosmwasm`. Note that you can also view the
262262
in 2.0. To keep the CosmWasm 1.x behaviour, just set payload to
263263
`Binary::default()`.
264264

265+
- In test code, replace calls to `mock_info` with `message_info`. This takes a
266+
`&Addr` as the first argument which you get by using owned `Addr` in the test
267+
bodies.
268+
265269
## 1.4.x -> 1.5.0
266270

267271
- Update `cosmwasm-*` dependencies in Cargo.toml (skip the ones you don't use):

contracts/burner/src/contract.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ fn cleanup(storage: &mut dyn Storage, mut limit: usize) -> usize {
8383
mod tests {
8484
use super::*;
8585
use cosmwasm_std::testing::{
86-
mock_dependencies, mock_dependencies_with_balance, mock_env, mock_info,
86+
message_info, mock_dependencies, mock_dependencies_with_balance, mock_env,
8787
};
8888
use cosmwasm_std::{coins, Attribute, StdError, Storage, SubMsg};
8989

@@ -102,8 +102,10 @@ mod tests {
102102
fn instantiate_fails() {
103103
let mut deps = mock_dependencies();
104104

105+
let creator = deps.api.addr_make("creator");
106+
105107
let msg = InstantiateMsg {};
106-
let info = mock_info("creator", &coins(1000, "earth"));
108+
let info = message_info(&creator, &coins(1000, "earth"));
107109
// we can just call .unwrap() to assert this was a success
108110
let res = instantiate(deps.as_mut(), mock_env(), info, msg);
109111
match res.unwrap_err() {
@@ -164,6 +166,8 @@ mod tests {
164166
fn execute_cleans_up_data() {
165167
let mut deps = mock_dependencies_with_balance(&coins(123456, "gold"));
166168

169+
let anon = deps.api.addr_make("anon");
170+
167171
// store some sample data
168172
deps.storage.set(b"foo", b"bar");
169173
deps.storage.set(b"key2", b"data2");
@@ -179,7 +183,7 @@ mod tests {
179183
let res = execute(
180184
deps.as_mut(),
181185
mock_env(),
182-
mock_info("anon", &[]),
186+
message_info(&anon, &[]),
183187
ExecuteMsg::Cleanup { limit: Some(2) },
184188
)
185189
.unwrap();
@@ -192,7 +196,7 @@ mod tests {
192196
let res = execute(
193197
deps.as_mut(),
194198
mock_env(),
195-
mock_info("anon", &[]),
199+
message_info(&anon, &[]),
196200
ExecuteMsg::Cleanup { limit: Some(2) },
197201
)
198202
.unwrap();

contracts/crypto-verify/src/contract.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ pub fn query_list_verifications(deps: Deps) -> StdResult<ListVerificationsRespon
215215
mod tests {
216216
use super::*;
217217
use cosmwasm_std::testing::{
218-
mock_dependencies, mock_env, mock_info, MockApi, MockQuerier, MockStorage,
218+
message_info, mock_dependencies, mock_env, MockApi, MockQuerier, MockStorage,
219219
};
220220
use cosmwasm_std::{
221221
from_json, Binary, OwnedDeps, RecoverPubkeyError, StdError, VerificationError,
@@ -247,8 +247,9 @@ mod tests {
247247

248248
fn setup() -> OwnedDeps<MockStorage, MockApi, MockQuerier> {
249249
let mut deps = mock_dependencies();
250+
let creator = deps.api.addr_make(CREATOR);
250251
let msg = InstantiateMsg {};
251-
let info = mock_info(CREATOR, &[]);
252+
let info = message_info(&creator, &[]);
252253
let res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap();
253254
assert_eq!(0, res.messages.len());
254255
deps

contracts/cyberpunk/src/contract.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,15 @@ fn query_denom(deps: Deps, denom: String) -> StdResult<DenomMetadata> {
229229
mod tests {
230230
use super::*;
231231
use cosmwasm_std::testing::{
232-
mock_dependencies, mock_env, mock_info, MockApi, MockQuerier, MockStorage,
232+
message_info, mock_dependencies, mock_env, MockApi, MockQuerier, MockStorage,
233233
};
234234
use cosmwasm_std::{from_json, DenomMetadata, DenomUnit, OwnedDeps};
235235

236236
fn setup() -> OwnedDeps<MockStorage, MockApi, MockQuerier> {
237237
let mut deps = mock_dependencies();
238+
let creator = deps.api.addr_make("creator");
238239
let msg = Empty {};
239-
let info = mock_info("creator", &[]);
240+
let info = message_info(&creator, &[]);
240241
let res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap();
241242
assert_eq!(0, res.messages.len());
242243
deps
@@ -250,9 +251,10 @@ mod tests {
250251
#[test]
251252
fn debug_works() {
252253
let mut deps = setup();
254+
let caller = deps.api.addr_make("caller");
253255

254256
let msg = ExecuteMsg::Debug {};
255-
execute(deps.as_mut(), mock_env(), mock_info("caller", &[]), msg).unwrap();
257+
execute(deps.as_mut(), mock_env(), message_info(&caller, &[]), msg).unwrap();
256258
}
257259

258260
#[test]

0 commit comments

Comments
 (0)