Files
cproof/tests/functionaltests/test_receipts.c
jabber.developer2 2b1b70665b
All checks were successful
CI Code / Check spelling (pull_request) Successful in 19s
CI Code / Check coding style (pull_request) Successful in 35s
CI Code / Code Coverage (pull_request) Successful in 2m28s
CI Code / Linux (debian) (pull_request) Successful in 4m23s
CI Code / Linux (arch) (pull_request) Successful in 4m41s
CI Code / Linux (ubuntu) (pull_request) Successful in 5m14s
fix(functests): fix send_receipt_request 60s timeout, rebalance groups, add per-test timing
Fix send_receipt_request test that wasted 60s on every run:
- Change caps hash from sha-256 to sha-1 (profanity only supports sha-1
  for standard caps path, sha-256 goes to unsupported-hash fallback)
- Fix expected output: 'Buddy1 is online' → 'Buddy1 (laptop) is online'
  (resource is always shown for full JID presence)
- Wrap prof_output_exact in assert_true so mismatches fail fast instead
  of silently waiting the full expect_timeout

Rebalance test groups for parallel execution:
- Move Disco tests (14) from Group 3 → Group 1
- Move DB History tests (12) from Group 2 → Group 3
- Before: G1=31s G2=63s G3=30s G4=37s (bottleneck 63s)
- After:  G1=46s G2=38s G3=40s G4=36s (bottleneck 46s, -27%)

Add per-test wall-clock timing via clock_gettime(CLOCK_MONOTONIC)
in init_prof_test/close_prof_test for profiling individual tests.
2026-03-12 21:02:22 +03:00

85 lines
2.4 KiB
C

#include <glib.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>
#include <stabber.h>
#include "proftest.h"
void
does_not_send_receipt_request_to_barejid(void **state)
{
prof_input("/receipts request on");
prof_connect();
prof_input("/msg somejid@someserver.com Hi there");
assert_true(stbbr_received(
"<message id='*' type='chat' to='somejid@someserver.com'>"
"<body>Hi there</body>"
"</message>"
));
}
void
send_receipt_request(void **state)
{
prof_input("/receipts request on");
prof_connect();
// Register disco#info response for capabilities query (receipts support)
stbbr_for_query("http://jabber.org/protocol/disco#info",
"<iq from='buddy1@localhost/laptop' to='stabber@localhost' id='*' type='result'>"
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#hAkb1xZdJV9BQpgGNw8zG5Xsals='>"
"<identity category='client' name='Profanity 0.5.0' type='console'/>"
"<feature var='urn:xmpp:receipts'/>"
"</query>"
"</iq>"
);
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/laptop'>"
"<priority>15</priority>"
"<status>My status</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='hAkb1xZdJV9BQpgGNw8zG5Xsals='/>"
"</presence>"
);
assert_true(prof_output_exact("Buddy1 (laptop) is online, \"My status\""));
prof_input("/msg Buddy1");
prof_input("/resource set laptop");
prof_input("Hi there, where is my receipt?");
assert_true(stbbr_received(
"<message id='*' type='chat' to='buddy1@localhost/laptop'>"
"<body>Hi there, where is my receipt?</body>"
"<request xmlns='urn:xmpp:receipts'/>"
"</message>"
));
}
void
send_receipt_on_request(void **state)
{
prof_input("/receipts send on");
prof_connect();
stbbr_send(
"<message id='msg12213' type='chat' to='stabber@localhost/profanity' from='someuser@server.org/profanity'>"
"<body>Wants a receipt</body>"
"<request xmlns='urn:xmpp:receipts'/>"
"</message>"
);
assert_true(stbbr_received(
"<message id='*' to='someuser@server.org/profanity'>"
"<received id='msg12213' xmlns='urn:xmpp:receipts'/>"
"</message>"
));
}