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

Switch order of approval-single list queries #772

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading