From 0fea30b0aeb04240aa03a85f4dd623c0a2bdc5d6 Mon Sep 17 00:00:00 2001 From: thesn10 <38666407+thesn10@users.noreply.github.com> Date: Tue, 19 May 2026 21:58:05 +0200 Subject: [PATCH] feat(descro): dispute() records unix_timestamp in dispute_raised_at --- programs/descro/src/instructions/dispute.rs | 4 +++- programs/descro/tests/test_dispute.rs | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/programs/descro/src/instructions/dispute.rs b/programs/descro/src/instructions/dispute.rs index b5db3ca..5ebd13b 100644 --- a/programs/descro/src/instructions/dispute.rs +++ b/programs/descro/src/instructions/dispute.rs @@ -20,6 +20,8 @@ pub struct Dispute<'info> { } pub fn handler(ctx: Context) -> 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(()) } diff --git a/programs/descro/tests/test_dispute.rs b/programs/descro/tests/test_dispute.rs index 1179fa3..0369618 100644 --- a/programs/descro/tests/test_dispute.rs +++ b/programs/descro/tests/test_dispute.rs @@ -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); +}