From 17fc81ab7a9366f8f4e93e372078a2622dd399ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCrten?= Date: Wed, 24 Mar 2021 15:40:21 +0100 Subject: [PATCH] Re-add integration test that goes through two full introduction cycles --- .../AutoDeleteIntegrationTest.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/briar-core/src/test/java/org/briarproject/briar/introduction/AutoDeleteIntegrationTest.java b/briar-core/src/test/java/org/briarproject/briar/introduction/AutoDeleteIntegrationTest.java index d99044de1..07f6d51b9 100644 --- a/briar-core/src/test/java/org/briarproject/briar/introduction/AutoDeleteIntegrationTest.java +++ b/briar-core/src/test/java/org/briarproject/briar/introduction/AutoDeleteIntegrationTest.java @@ -389,6 +389,70 @@ public class AutoDeleteIntegrationTest extends AbstractAutoDeleteTest { assertGroupCountAt2With0(count20, unread20); } + /** + * Go through two full cycles of introducing two contacts with + * self-destructing messages enabled, lettings them both introducees expire + * their introductions, thereby auto-declining it. + */ + @Test + public void testTwoIntroductionCycles() throws Exception { + // FIRST CYCLE + introduceAndAutoDecline(); + + // SECOND CYCLE + introduceAndAutoDecline(); + } + + private void introduceAndAutoDecline() throws Exception { + // send introduction + makeIntroduction(true, true); + markMessagesRead(c1, contact0From1); + markMessagesRead(c2, contact0From2); + assertGroupCounts(1, 0, 1, 0, 1, 0, 1, 0); + + // ack from 1 and 2 to 0. This starts 0's timer + ack1To0(1); + ack2To0(1); + waitForEvents(c0); + + // time travel on all devices, destroying the introductions at 0 and + // making 1 and 2 auto-decline + timeTravel(c0); + timeTravel(c1); + timeTravel(c2); + assertGroupCounts(0, 0, 0, 0, 1, 0, 1, 0); + + // sync the auto-decline messages to 0 + sync1To0(1, true); + sync2To0(1, true); + waitForEvents(c0); + assertGroupCounts(1, 1, 1, 1, 1, 0, 1, 0); + + // mark declines read on 0, starting the timer there and let them expire + markMessagesRead(c0, contact1From0); + markMessagesRead(c0, contact2From0); + timeTravel(c0); + assertGroupCounts(0, 0, 0, 0, 1, 0, 1, 0); + + // sync responses to 1 and 2 + sync0To1(1, true); + sync0To2(1, true); + waitForEvents(c1); + waitForEvents(c2); + + // ack the responses to 0 to clear the ack counts for subsequent cycles, + // also starts the timer for the responses at 1 and 2 + ack1To0(1); + ack2To0(1); + waitForEvents(c0); + assertGroupCounts(0, 0, 0, 0, 1, 0, 1, 0); + + // let timers for responses expire + timeTravel(c1); + timeTravel(c2); + assertGroupCounts(0, 0, 0, 0, 0, 0, 0, 0); + } + /** * Let introductions self-destruct at the introducer and one of the * introducees