Skip to content

Commit

Permalink
fix: 🥅 add error handling
Browse files Browse the repository at this point in the history
Adding error handling for total_bid when no bid is available.
  • Loading branch information
giorgionocera committed Oct 30, 2024
1 parent 30c5856 commit d0197f6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/multitest/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,9 @@ fn query_total_bid() {
)
.unwrap();

let resp = contract.query_total_bid(&app, &sender).unwrap();
assert_eq!(resp, Uint128::new(0));

// Making a simple bid
contract
.bid(&mut app, &sender, &coins(3_500_000, UATOM))
Expand Down
2 changes: 1 addition & 1 deletion src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
pub fn total_bid(deps: Deps, address: String) -> StdResult<Uint128> {
let address = deps.api.addr_validate(&address)?;

BIDS.load(deps.storage, &address)
Ok(BIDS.may_load(deps.storage, &address)?.unwrap_or_default())
}

pub fn highest_bid(deps: Deps) -> StdResult<BidResp> {
Expand Down

0 comments on commit d0197f6

Please sign in to comment.