feat(descro): dispute() records unix_timestamp in dispute_raised_at
This commit is contained in:
@@ -20,6 +20,8 @@ pub struct Dispute<'info> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn handler(ctx: Context<Dispute>) -> Result<()> {
|
pub fn handler(ctx: Context<Dispute>) -> Result<()> {
|
||||||
ctx.accounts.escrow_account.state = EscrowState::Disputed;
|
let escrow = &mut ctx.accounts.escrow_account;
|
||||||
|
escrow.state = EscrowState::Disputed;
|
||||||
|
escrow.dispute_raised_at = Some(Clock::get()?.unix_timestamp);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,3 +62,19 @@ fn third_party_cannot_dispute() {
|
|||||||
&resolver,
|
&resolver,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn dispute_records_timestamp() {
|
||||||
|
let (mut svm, seller, buyer, _resolver) = setup();
|
||||||
|
send(
|
||||||
|
&mut svm,
|
||||||
|
ix_create_escrow(&seller.pubkey(), &buyer.pubkey(), AMOUNT, None, ESCROW_ID),
|
||||||
|
&seller,
|
||||||
|
);
|
||||||
|
send(&mut svm, ix_deposit(&buyer.pubkey(), &seller.pubkey(), ESCROW_ID), &buyer);
|
||||||
|
send(&mut svm, ix_dispute(&buyer.pubkey(), &seller.pubkey(), ESCROW_ID), &buyer);
|
||||||
|
|
||||||
|
let escrow = read_escrow(&svm, &seller.pubkey(), ESCROW_ID);
|
||||||
|
assert!(escrow.dispute_raised_at.is_some());
|
||||||
|
assert!(escrow.dispute_raised_at.unwrap() >= 0);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user