Skip to content

Commit

Permalink
Switch order of approval-single list queries (#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso authored Nov 16, 2023
1 parent e54d447 commit 1187dba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
&PENDING_PROPOSALS,
start_after,
limit,
Order::Descending,
Order::Ascending,
)?),
QueryExt::ReversePendingProposals {
start_before,
Expand All @@ -368,7 +368,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
&PENDING_PROPOSALS,
start_before,
limit,
Order::Ascending,
Order::Descending,
)?),
QueryExt::CompletedProposal { id } => {
to_binary(&COMPLETED_PROPOSALS.load(deps.storage, id)?)
Expand All @@ -378,7 +378,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
&COMPLETED_PROPOSALS,
start_after,
limit,
Order::Descending,
Order::Ascending,
)?),
QueryExt::ReverseCompletedProposals {
start_before,
Expand All @@ -388,7 +388,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
&COMPLETED_PROPOSALS,
start_before,
limit,
Order::Ascending,
Order::Descending,
)?),
QueryExt::CompletedProposalIdForCreatedProposalId { id } => {
to_binary(&CREATED_PROPOSAL_TO_COMPLETED_PROPOSAL.may_load(deps.storage, id)?)
Expand Down
20 changes: 10 additions & 10 deletions contracts/pre-propose/dao-pre-propose-approval-single/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ fn make_pre_proposal(app: &mut App, pre_propose: Addr, proposer: &str, funds: &[
)
.unwrap();

// Query for pending proposal and return latest id. Returns descending.
let pending: Vec<Proposal> = app
// Query for pending proposal and return latest id.
let mut pending: Vec<Proposal> = app
.wrap()
.query_wasm_smart(
pre_propose,
Expand All @@ -204,8 +204,8 @@ fn make_pre_proposal(app: &mut App, pre_propose: Addr, proposer: &str, funds: &[
)
.unwrap();

// Return first item in descending list, id is first element of tuple
pending[0].approval_id
// Return last item in ascending list, id is first element of tuple
pending.pop().unwrap().approval_id
}

fn mint_natives(app: &mut App, receiver: &str, coins: Vec<Coin>) {
Expand Down Expand Up @@ -911,7 +911,7 @@ fn test_pending_proposal_queries() {
)
.unwrap();
assert_eq!(pre_propose_props.len(), 2);
assert_eq!(pre_propose_props[0].approval_id, 2);
assert_eq!(pre_propose_props[0].approval_id, 1);

// Query props in reverse
let reverse_pre_propose_props: Vec<Proposal> = app
Expand All @@ -928,7 +928,7 @@ fn test_pending_proposal_queries() {
.unwrap();

assert_eq!(reverse_pre_propose_props.len(), 2);
assert_eq!(reverse_pre_propose_props[0].approval_id, 1);
assert_eq!(reverse_pre_propose_props[0].approval_id, 2);
}

#[test]
Expand Down Expand Up @@ -1051,8 +1051,8 @@ fn test_completed_proposal_queries() {
)
.unwrap();
assert_eq!(pre_propose_props.len(), 2);
assert_eq!(pre_propose_props[0].approval_id, reject_id);
assert_eq!(pre_propose_props[1].approval_id, approve_id);
assert_eq!(pre_propose_props[0].approval_id, approve_id);
assert_eq!(pre_propose_props[1].approval_id, reject_id);

// Query props in reverse
let reverse_pre_propose_props: Vec<Proposal> = app
Expand All @@ -1069,8 +1069,8 @@ fn test_completed_proposal_queries() {
.unwrap();

assert_eq!(reverse_pre_propose_props.len(), 2);
assert_eq!(reverse_pre_propose_props[0].approval_id, approve_id);
assert_eq!(reverse_pre_propose_props[1].approval_id, reject_id);
assert_eq!(reverse_pre_propose_props[0].approval_id, reject_id);
assert_eq!(reverse_pre_propose_props[1].approval_id, approve_id);
}

#[test]
Expand Down

0 comments on commit 1187dba

Please sign in to comment.