-
Notifications
You must be signed in to change notification settings - Fork 60
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
Restart negotiations #1150
Restart negotiations #1150
Conversation
…start-negotiations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I'm still lacking |
3df3c1c
to
bf186c5
Compare
core/market/src/db/dao/proposal.rs
Outdated
@@ -72,6 +72,10 @@ impl<'c> ProposalDao<'c> { | |||
return Err(SaveProposalError::AlreadyCountered(prev_proposal)); | |||
} | |||
|
|||
// Proposal could be in Rejected state. It is ok to counter Rejected Proposal, | |||
// but we must change state of prev Proposal to Draft. | |||
update_proposal_state(conn, &prev_proposal, ProposalState::Draft)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this unconditional state change worries me
.unwrap() | ||
.body | ||
.state, | ||
ProposalState::Draft |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd expect some finalized agreement as a conclusion of restarted negotation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great job!
@@ -63,18 +63,30 @@ impl<'c> ProposalDao<'c> { | |||
pub async fn save_proposal(&self, proposal: &Proposal) -> Result<(), SaveProposalError> { | |||
let proposal = proposal.body.clone(); | |||
do_with_transaction(self.pool, move |conn| { | |||
let prev_proposal = proposal | |||
let prev_proposal_id = proposal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
// If previous Proposal was rejected, we must change it's state back. | ||
if prev_proposal.state == ProposalState::Rejected { | ||
// If rejected Proposal doesn't have prev_proposal_id, it was Initial Proposal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 great comments
@@ -984,7 +985,7 @@ async fn test_restart_negotiations() { | |||
.await | |||
.unwrap(); | |||
|
|||
let prov_proposal_id = req_market | |||
let req_proposal_id = req_market |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let req_proposal_id = req_market | |
// now the magic begins. We are countering a rejected proposal | |
let req_proposal_id = req_market |
@@ -1026,6 +1030,45 @@ async fn test_restart_negotiations() { | |||
.state, | |||
ProposalState::Draft | |||
); | |||
|
|||
// Agents should be able to sign Agreement after rejection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
.unwrap() | ||
.body | ||
.state, | ||
ProposalState::Initial |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
resolves: #1128