Skip to content
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

Support submessages in multitest #323

Merged
merged 20 commits into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions contracts/cw20-escrow/src/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,14 @@ fn escrow_happy_path_cw20_tokens() {
let res = router
.execute_contract(owner.clone(), cash_addr.clone(), &send_msg, &[])
.unwrap();
println!("{:?}", res.attributes);
assert_eq!(6, res.attributes.len());
assert_eq!(2, res.events.len());
println!("{:?}", res.events);
let cw20_attr = res.custom_attrs(0);
println!("{:?}", cw20_attr);
assert_eq!(4, cw20_attr.len());
let escrow_attr = res.custom_attrs(1);
println!("{:?}", escrow_attr);
assert_eq!(2, escrow_attr.len());

// ensure balances updated
let owner_balance = cash.balance(&router, owner.clone()).unwrap();
Expand Down
56 changes: 28 additions & 28 deletions contracts/cw3-flex-multisig/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,8 @@ mod tests {
.execute_contract(Addr::unchecked(VOTER3), flex_addr.clone(), &proposal, &[])
.unwrap();
assert_eq!(
res.attributes,
vec![
res.custom_attrs(0),
&[
attr("action", "propose"),
attr("sender", VOTER3),
attr("proposal_id", 1),
Expand All @@ -765,8 +765,8 @@ mod tests {
.execute_contract(Addr::unchecked(VOTER4), flex_addr, &proposal, &[])
.unwrap();
assert_eq!(
res.attributes,
vec![
res.custom_attrs(0),
&[
attr("action", "propose"),
attr("sender", VOTER4),
attr("proposal_id", 2),
Expand Down Expand Up @@ -832,15 +832,15 @@ mod tests {
let res = app
.execute_contract(Addr::unchecked(VOTER1), flex_addr.clone(), &proposal, &[])
.unwrap();
let proposal_id1: u64 = res.attributes[2].value.parse().unwrap();
let proposal_id1: u64 = res.custom_attrs(0)[2].value.parse().unwrap();

// another proposal immediately passes
app.update_block(next_block);
let proposal = pay_somebody_proposal();
let res = app
.execute_contract(Addr::unchecked(VOTER3), flex_addr.clone(), &proposal, &[])
.unwrap();
let proposal_id2: u64 = res.attributes[2].value.parse().unwrap();
let proposal_id2: u64 = res.custom_attrs(0)[2].value.parse().unwrap();

// expire them both
app.update_block(expire(voting_period));
Expand All @@ -850,7 +850,7 @@ mod tests {
let res = app
.execute_contract(Addr::unchecked(VOTER2), flex_addr.clone(), &proposal, &[])
.unwrap();
let proposal_id3: u64 = res.attributes[2].value.parse().unwrap();
let proposal_id3: u64 = res.custom_attrs(0)[2].value.parse().unwrap();
let proposed_at = app.block_info();

// next block, let's query them all... make sure status is properly updated (1 should be rejected in query)
Expand Down Expand Up @@ -930,7 +930,7 @@ mod tests {
.unwrap();

// Get the proposal id from the logs
let proposal_id: u64 = res.attributes[2].value.parse().unwrap();
let proposal_id: u64 = res.custom_attrs(0)[2].value.parse().unwrap();

// Owner cannot vote (again)
let yes_vote = ExecuteMsg::Vote {
Expand All @@ -953,8 +953,8 @@ mod tests {
.execute_contract(Addr::unchecked(VOTER1), flex_addr.clone(), &yes_vote, &[])
.unwrap();
assert_eq!(
res.attributes,
vec![
res.custom_attrs(0),
&[
attr("action", "vote"),
attr("sender", VOTER1),
attr("proposal_id", proposal_id),
Expand Down Expand Up @@ -1006,8 +1006,8 @@ mod tests {
.execute_contract(Addr::unchecked(VOTER4), flex_addr.clone(), &yes_vote, &[])
.unwrap();
assert_eq!(
res.attributes,
vec![
res.custom_attrs(0),
&[
attr("action", "vote"),
attr("sender", VOTER4),
attr("proposal_id", proposal_id),
Expand Down Expand Up @@ -1086,7 +1086,7 @@ mod tests {
.unwrap();

// Get the proposal id from the logs
let proposal_id: u64 = res.attributes[2].value.parse().unwrap();
let proposal_id: u64 = res.custom_attrs(0)[2].value.parse().unwrap();

// Only Passed can be executed
let execution = ExecuteMsg::Execute { proposal_id };
Expand All @@ -1104,8 +1104,8 @@ mod tests {
.execute_contract(Addr::unchecked(VOTER3), flex_addr.clone(), &vote, &[])
.unwrap();
assert_eq!(
res.attributes,
vec![
res.custom_attrs(0),
&[
attr("action", "vote"),
attr("sender", VOTER3),
attr("proposal_id", proposal_id),
Expand All @@ -1130,8 +1130,8 @@ mod tests {
)
.unwrap();
assert_eq!(
res.attributes,
vec![
res.custom_attrs(0),
&[
attr("action", "execute"),
attr("sender", SOMEBODY),
attr("proposal_id", proposal_id),
Expand Down Expand Up @@ -1172,7 +1172,7 @@ mod tests {
.unwrap();

// Get the proposal id from the logs
let proposal_id: u64 = res.attributes[2].value.parse().unwrap();
let proposal_id: u64 = res.custom_attrs(0)[2].value.parse().unwrap();

// Non-expired proposals cannot be closed
let closing = ExecuteMsg::Close { proposal_id };
Expand All @@ -1187,8 +1187,8 @@ mod tests {
.execute_contract(Addr::unchecked(SOMEBODY), flex_addr.clone(), &closing, &[])
.unwrap();
assert_eq!(
res.attributes,
vec![
res.custom_attrs(0),
&[
attr("action", "close"),
attr("sender", SOMEBODY),
attr("proposal_id", proposal_id),
Expand Down Expand Up @@ -1224,7 +1224,7 @@ mod tests {
.execute_contract(Addr::unchecked(VOTER1), flex_addr.clone(), &proposal, &[])
.unwrap();
// Get the proposal id from the logs
let proposal_id: u64 = res.attributes[2].value.parse().unwrap();
let proposal_id: u64 = res.custom_attrs(0)[2].value.parse().unwrap();
let prop_status = |app: &App, proposal_id: u64| -> Status {
let query_prop = QueryMsg::Proposal { proposal_id };
let prop: ProposalResponse = app
Expand Down Expand Up @@ -1285,7 +1285,7 @@ mod tests {
.execute_contract(Addr::unchecked(VOTER1), flex_addr.clone(), &proposal2, &[])
.unwrap();
// Get the proposal id from the logs
let proposal_id2: u64 = res.attributes[2].value.parse().unwrap();
let proposal_id2: u64 = res.custom_attrs(0)[2].value.parse().unwrap();

// VOTER2 can pass this alone with the updated vote (newer height ignores snapshot)
let yes_vote = ExecuteMsg::Vote {
Expand Down Expand Up @@ -1366,7 +1366,7 @@ mod tests {
)
.unwrap();
// Get the proposal id from the logs
let update_proposal_id: u64 = res.attributes[2].value.parse().unwrap();
let update_proposal_id: u64 = res.custom_attrs(0)[2].value.parse().unwrap();

// next block...
app.update_block(|b| b.height += 1);
Expand All @@ -1382,7 +1382,7 @@ mod tests {
)
.unwrap();
// Get the proposal id from the logs
let cash_proposal_id: u64 = res.attributes[2].value.parse().unwrap();
let cash_proposal_id: u64 = res.custom_attrs(0)[2].value.parse().unwrap();
assert_ne!(cash_proposal_id, update_proposal_id);

// query proposal state
Expand Down Expand Up @@ -1475,7 +1475,7 @@ mod tests {
.execute_contract(Addr::unchecked(VOTER3), flex_addr.clone(), &proposal, &[])
.unwrap();
// Get the proposal id from the logs
let proposal_id: u64 = res.attributes[2].value.parse().unwrap();
let proposal_id: u64 = res.custom_attrs(0)[2].value.parse().unwrap();
let prop_status = |app: &App| -> Status {
let query_prop = QueryMsg::Proposal { proposal_id };
let prop: ProposalResponse = app
Expand Down Expand Up @@ -1519,7 +1519,7 @@ mod tests {
.execute_contract(Addr::unchecked(newbie), flex_addr.clone(), &proposal, &[])
.unwrap();
// Get the proposal id from the logs
let proposal_id2: u64 = res.attributes[2].value.parse().unwrap();
let proposal_id2: u64 = res.custom_attrs(0)[2].value.parse().unwrap();

// check proposal2 status
let query_prop = QueryMsg::Proposal {
Expand Down Expand Up @@ -1557,7 +1557,7 @@ mod tests {
.execute_contract(Addr::unchecked(VOTER3), flex_addr.clone(), &proposal, &[])
.unwrap();
// Get the proposal id from the logs
let proposal_id: u64 = res.attributes[2].value.parse().unwrap();
let proposal_id: u64 = res.custom_attrs(0)[2].value.parse().unwrap();
let prop_status = |app: &App| -> Status {
let query_prop = QueryMsg::Proposal { proposal_id };
let prop: ProposalResponse = app
Expand Down Expand Up @@ -1626,7 +1626,7 @@ mod tests {
.execute_contract(Addr::unchecked(VOTER5), flex_addr.clone(), &proposal, &[])
.unwrap();
// Get the proposal id from the logs
let proposal_id: u64 = res.attributes[2].value.parse().unwrap();
let proposal_id: u64 = res.custom_attrs(0)[2].value.parse().unwrap();
let prop_status = |app: &App| -> Status {
let query_prop = QueryMsg::Proposal { proposal_id };
let prop: ProposalResponse = app
Expand Down
Loading