From 6680abf925e5c96200f5f407cd97175c2f8de6a1 Mon Sep 17 00:00:00 2001
From: Torsten Grote <t@grobox.de>
Date: Fri, 4 Nov 2022 12:01:00 -0300
Subject: [PATCH] Make MailboxIntegrationTest a bit more thorough

 by checking, after adding the contact to the mailbox but before creating the message, that the first file containing the mailbox update gets uploaded. Then after creating the message, the second file should be uploaded.
---
 .../mailbox/MailboxIntegrationTest.java       | 22 +++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/mailbox-integration-tests/src/test/java/org/briarproject/bramble/mailbox/MailboxIntegrationTest.java b/mailbox-integration-tests/src/test/java/org/briarproject/bramble/mailbox/MailboxIntegrationTest.java
index 274b5e9e2f..96748a0185 100644
--- a/mailbox-integration-tests/src/test/java/org/briarproject/bramble/mailbox/MailboxIntegrationTest.java
+++ b/mailbox-integration-tests/src/test/java/org/briarproject/bramble/mailbox/MailboxIntegrationTest.java
@@ -7,13 +7,18 @@ import org.junit.Test;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.logging.Logger;
 
+import static java.util.logging.Logger.getLogger;
 import static org.briarproject.bramble.mailbox.MailboxIntegrationTestUtils.retryUntilSuccessOrTimeout;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
 public class MailboxIntegrationTest extends AbstractMailboxIntegrationTest {
 
+	private static final Logger LOG =
+			getLogger(MailboxIntegrationTest.class.getSimpleName());
+
 	@Test
 	public void testSendMessageViaMailbox() throws Exception {
 		addContacts();
@@ -37,21 +42,30 @@ public class MailboxIntegrationTest extends AbstractMailboxIntegrationTest {
 				getMailboxProperties(c2, contact1From2.getId());
 		assertNotNull(props2.getInboxId());
 
+		// wait until file containing mailbox properties arrived on mailbox
+		retryUntilSuccessOrTimeout(5_000, 500, () -> {
+			List<MailboxFile> files = api.getFiles(props2, props2.getInboxId());
+			return files.size() == 1;
+		});
+		LOG.info("Mailbox properties uploaded");
+
 		// send message and wait for it to arrive via mailbox
 		broadcastMessage(c1);
 
-		// wait until file arrived on mailbox
-		retryUntilSuccessOrTimeout(5_000, 500, () -> {
+		// wait until file with broadcast message arrived on mailbox
+		retryUntilSuccessOrTimeout(10_000, 500, () -> {
 			List<MailboxFile> files = api.getFiles(props2, props2.getInboxId());
-			return files.size() > 1;
+			return files.size() == 2;
 		});
+		LOG.info("Broadcast message uploaded");
 
 		// wait for message to arrive
 		// this might require 2nd download cycle after Tor reachability period
+		LOG.info("Waiting for delivery of broadcast message");
 		awaitPendingMessageDelivery(1);
 
 		// assert that message arrived for c2
-		assertNumMessages(c2,  contact1From2.getId(), 1);
+		assertNumMessages(c2, contact1From2.getId(), 1);
 
 		// all files were deleted from mailbox
 		assertEquals(0, api.getFiles(props2, props2.getInboxId()).size());
-- 
GitLab