From 7aaaece42c565fe8bc6ff8c5a2f05249974042a6 Mon Sep 17 00:00:00 2001 From: gardners Date: Fri, 10 May 2013 20:54:11 +0930 Subject: [PATCH] meshms list conversations deduplicates output, and is covered by a test. --- rhizome_database.c | 4 ++-- tests/meshms | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/rhizome_database.c b/rhizome_database.c index 4c77d267..9aafb15e 100644 --- a/rhizome_database.c +++ b/rhizome_database.c @@ -1343,8 +1343,8 @@ int rhizome_meshms_find_conversations(const char *sid, int offset, int count) cli_put_string(left, ":"); cli_put_string(right, "\n"); } - snprintf(last_left,SID_STRLEN,"%s",left); - snprintf(last_right,SID_STRLEN,"%s",right); + snprintf(last_left,SID_STRLEN+1,"%s",left); + snprintf(last_right,SID_STRLEN+1,"%s",right); } cleanup: diff --git a/tests/meshms b/tests/meshms index e89fbcb6..05dbe3c0 100755 --- a/tests/meshms +++ b/tests/meshms @@ -125,6 +125,27 @@ test_qsoList() { assertStdoutGrep --stdout --stderr --matches=1 '^'${SIDA2}':'${SIDA1}'$' } +doc_qsoList2="meshms list conversations deduplicates threads" +setup_qsoList2() { + setup +} +test_qsoList2() { + executeOk_servald meshms add message 12345 67890 $SIDA1 $SIDA2 "Message-1a" + executeOk_servald meshms list conversations $SIDA1 + assertStdoutGrep --stdout --stderr --matches=1 '^'$SIDA1':'$SIDA2'$' + assertStdoutGrep --stdout --stderr --matches=0 '^'$SIDA2':'$SIDA1'$' + executeOk_servald meshms list conversations $SIDA2 + assertStdoutGrep --stdout --stderr --matches=0 '^'${SIDA1}':'${SIDA2}'$' + assertStdoutGrep --stdout --stderr --matches=1 '^'${SIDA2}':'${SIDA1}'$' + executeOk_servald meshms add message 12345 67890 $SIDA2 $SIDA1 "Message-2b" + executeOk_servald meshms list conversations $SIDA1 + assertStdoutGrep --stdout --stderr --matches=1 '^'$SIDA1':'$SIDA2'$' + assertStdoutGrep --stdout --stderr --matches=0 '^'$SIDA2':'$SIDA1'$' + executeOk_servald meshms list conversations $SIDA2 + assertStdoutGrep --stdout --stderr --matches=0 '^'${SIDA1}':'${SIDA2}'$' + assertStdoutGrep --stdout --stderr --matches=1 '^'${SIDA2}':'${SIDA1}'$' +} + doc_ack="Acking messages works" setup_ack() { setup