-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now only Created and Reclaimed bids can be picked.
- Loading branch information
Showing
10 changed files
with
95 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use crate::bid_escrow::bid::BidStatus; | ||
use crate::rules::validation::Validation; | ||
use crate::utils::Error; | ||
use macros::Rule; | ||
|
||
/// Makes sure the job poster is the one who picks the [`Bid`](crate::bid_escrow::bid::Bid). | ||
/// May return [Error::OnlyJobPosterCanPickABid]. | ||
#[derive(Rule)] | ||
pub struct CanBidBePicked { | ||
bid_status: BidStatus, | ||
} | ||
|
||
impl Validation for CanBidBePicked { | ||
fn validate(&self) -> Result<(), Error> { | ||
match self.bid_status { | ||
BidStatus::Created | BidStatus::Reclaimed => Ok(()), | ||
BidStatus::Picked => Err(Error::BidAlreadyPicked), | ||
BidStatus::Canceled => Err(Error::BidCanceled), | ||
BidStatus::Rejected => Err(Error::BidRejected), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
35 changes: 35 additions & 0 deletions
35
dao/tests/features/bid_escrow/hal-02-pick_canceled_bid.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Feature: Pick a canceled bid | ||
JobPoster cannot pick a bid that has already been cancelled. | ||
This is a presentation of HAL-02 issue fix. | ||
Background: | ||
Given accounts | ||
| account | CSPR balance | REP balance | REP stake | is_kyced | is_va | | ||
| JobPoster | 1000 | 0 | 0 | true | false | | ||
| Alice | 1000 | 0 | 0 | true | false | | ||
| ExternalWorker | 1000 | 0 | 0 | true | false | | ||
| InternalWorker | 0 | 1000 | 0 | true | true | | ||
| VA1 | 0 | 1000 | 0 | true | true | | ||
| VA2 | 0 | 1000 | 0 | true | true | | ||
When JobPoster posted a JobOffer with expected timeframe of 14 days, maximum budget of 1000 CSPR and 400 CSPR DOS Fee | ||
And 2 days passed | ||
And Alice posted a JobOffer with expected timeframe of 20 days, maximum budget of 2000 CSPR and 400 CSPR DOS Fee | ||
Scenario: JobPoster try to pick the cancelled bid | ||
When InternalWorker posted the Bid for JobOffer 0 with proposed timeframe of 7 days and 500 CSPR price and 100 REP stake | ||
Then InternalWorker Bid is posted | ||
And balances are | ||
| account | CSPR balance | REP balance | REP stake | | ||
| InternalWorker | 0 | 1000 | 100 | | ||
When InternalWorker posted the Bid for JobOffer 1 with proposed timeframe of 7 days and 500 CSPR price and 200 REP stake | ||
Then InternalWorker Bid is posted | ||
And balances are | ||
| account | CSPR balance | REP balance | REP stake | | ||
| InternalWorker | 0 | 1000 | 300 | | ||
When 2 days passed | ||
And InternalWorker cancels the Bid for JobPoster | ||
Then Bid 0 is canceled | ||
And balances are | ||
| account | CSPR balance | REP balance | REP stake | | ||
| InternalWorker | 0 | 1000 | 200 | | ||
When 1 days passed | ||
Then JobPoster fails to pick the Bid of InternalWorker | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters