@@ -9,7 +9,7 @@ jest.mock("../services/stellar", () => ({
99} ) ) ;
1010
1111jest . mock ( "../services/matchQueue" , ( ) => ( {
12- enqueueDonationMatching : jest . fn ( ) . mockResolvedValue ( "job-id" ) ,
12+ enqueueMatchDonation : jest . fn ( ) . mockResolvedValue ( undefined ) ,
1313} ) ) ;
1414
1515const http = require ( "http" ) ;
@@ -528,15 +528,17 @@ describe("POST /api/donations → broadcast hardening", () => {
528528 }
529529 } , 3000 ) ;
530530
531- test ( "emits a single primary event when donation is recorded (matching is now async)" , async ( ) => {
531+ test ( "emits only one event per donation (matching is now async via matchQueue )" , async ( ) => {
532532 const donorAddress = makePublicKey ( "K" ) ;
533533 const transactionHash = makeTxHash ( "f" ) ;
534+ // Matching is handled asynchronously by matchQueue, so recordDonation
535+ // no longer queries donation_matches or inserts match donations inline.
536+ // Only 6 queries remain: SELECT project, dedup, BEGIN, INSERT, UPDATE, COMMIT.
534537 createMockClient (
535538 queryResult ( [ { id : "project-match" } ] ) , // SELECT project
536539 queryResult ( [ ] ) , // dedup check
537540 queryResult ( ) , // BEGIN
538541 queryResult ( [
539- // INSERT primary donation
540542 {
541543 id : "match-primary" ,
542544 project_id : "project-match" ,
@@ -548,7 +550,7 @@ describe("POST /api/donations → broadcast hardening", () => {
548550 transaction_hash : transactionHash ,
549551 created_at : new Date ( ) . toISOString ( ) ,
550552 } ,
551- ] ) ,
553+ ] ) , // INSERT donation
552554 queryResult ( ) , // UPDATE projects
553555 queryResult ( ) , // COMMIT
554556 ) ;
0 commit comments