Skip to content

Commit

Permalink
escrow_release_operation tests #143
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Vandeberg committed Aug 18, 2016
1 parent 8201322 commit 100acb4
Show file tree
Hide file tree
Showing 4 changed files with 520 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ namespace steemit { namespace chain {
string agent;
string who; // Either to or agent
uint32_t escrow_id = 0;
bool approve;
bool approve = true;

void validate()const;
void get_required_active_authorities( flat_set<string>& a )const{ a.insert(who); }
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/protocol/steem_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ namespace steemit { namespace chain {
FC_ASSERT( sbd_amount.amount >= 0, "sbd amount cannot be negative" );
FC_ASSERT( steem_amount.amount >= 0, "steem amount cannot be negative" );
FC_ASSERT( sbd_amount.amount > 0 || steem_amount.amount > 0, "escrow must release a non-zero amount" );
FC_ASSERT( sbd_amount.symbol == VESTS_SYMBOL, "sbd amount must contain SBD" );
FC_ASSERT( sbd_amount.symbol == SBD_SYMBOL, "sbd amount must contain SBD" );
FC_ASSERT( steem_amount.symbol == STEEM_SYMBOL, "steem amount must contain STEEM" );
}

Expand Down
21 changes: 13 additions & 8 deletions libraries/chain/steem_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,16 +610,21 @@ void escrow_release_evaluator::do_apply( const escrow_release_operation& o )
{
FC_ASSERT( o.who == e.agent, "'agent' must release funds for a disputed escrow" );
}
else if( e.escrow_expiration > db().head_block_time() )
else
{
// If there is no dispute and escrow has not expired, either party can release funds to the other.
if( o.who == e.from )
{
FC_ASSERT( o.to == e.to, "'from' must release funds to 'to'" );
}
else if( o.who == e.to )
FC_ASSERT( o.who == e.from || o.who == e.to, "Only 'from' and 'to' can release from a non-disputed escrow" );

if( e.escrow_expiration > db().head_block_time() )
{
FC_ASSERT( o.to == e.from, "'to' must release funds to 'from'" );
// If there is no dispute and escrow has not expired, either party can release funds to the other.
if( o.who == e.from )
{
FC_ASSERT( o.to == e.to, "'from' must release funds to 'to'" );
}
else if( o.who == e.to )
{
FC_ASSERT( o.to == e.from, "'to' must release funds to 'from'" );
}
}
}
// If escrow expires and there is no dispute, either party can release funds to either party.
Expand Down
Loading

0 comments on commit 100acb4

Please sign in to comment.