-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when running unit tests: Generic error: Error decoding bech32
#66
Comments
try this #[test]
fn instantiation() {
let mut app = App::default();
let code = ContractWrapper::new(execute, instantiate, query);
let code_id = app.store_code(Box::new(code));
let addr = app
.instantiate_contract(
code_id,
Addr::unchecked("owner"),
&InstantiateMsg { admins: vec![] },
&[],
"Contract",
None,
)
.unwrap();
let resp: AdminsListResp = app
.wrap()
.query_wasm_smart(addr, &QueryMsg::AdminsList {})
.unwrap();
assert_eq!(resp, AdminsListResp { admins: vec![] });
let admin1 = app.api().addr_make("admin1").to_string();
let admin2 = app.api().addr_make("admin2").to_string();
let addr = app
.instantiate_contract(
code_id,
Addr::unchecked("owner"),
&(InstantiateMsg {
admins: vec![admin1.clone(), admin2.clone()],
}),
&[],
"Contract 2",
None,
)
.unwrap();
let resp: AdminsListResp = app
.wrap()
.query_wasm_smart(addr, &QueryMsg::AdminsList {})
.unwrap();
assert_eq!(
resp,
AdminsListResp {
admins: vec![Addr::unchecked(admin1), Addr::unchecked(admin2)],
}
);
} |
Hey @asher-gh, thank your for your response! I am a little bit confused to be honest:
If you have an explanation, I'd be very interested to understand what goes wrong with my code sample. Anyway I'll keep using the |
Yeah, I stumbled upon the same thing. It seems like it has something to do with bech32 address encoding in cw_multi_test. I found the usage of |
All right I'll have a look at those examples. I also opened an issue in the cw_multi_test repository, if anyone is interested: CosmWasm/cw-multi-test#169 Tell me when there is a consensus about how it should be done, I can submit a PR to update the book examples =) |
Hi everyone,
First, thanks a lot for writing/maintaining this book. This is an awesome learning resource!
While following the book, I found an error when running unit tests. The following block of code
leads to the next error:
From what I understand, it seems to come from cw_multi_test. They currently have an issue opened that seems to relate to the problem: CosmWasm/cw-multi-test#165
Here is a repository containing the bug: https://github.com/maxmousse/cosmwasm-test/tree/cosmwasm-tuto. Just run
cargo test
and the error should show.I'd be happy to submit a pull request when there is a consensus about how to fix this =)
The text was updated successfully, but these errors were encountered: