feat(descro): dispute() records unix_timestamp in dispute_raised_at

This commit is contained in:
thesn10
2026-05-19 21:58:05 +02:00
parent 5448492616
commit 0fea30b0ae
2 changed files with 19 additions and 1 deletions

View File

@@ -20,6 +20,8 @@ pub struct Dispute<'info> {
}
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(())
}

View File

@@ -62,3 +62,19 @@ fn third_party_cannot_dispute() {
&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);
}