mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Factor out mailbox constants into a MailboxConfig
so that we can change them for integration tests via the new ModularMailboxModule that now also includes the UrlProvider
This commit is contained in:
@@ -21,7 +21,8 @@ public class MailboxIntegrationTest extends AbstractMailboxIntegrationTest {
|
||||
// c1 one pairs the mailbox
|
||||
MailboxProperties props1 = pair(c1, mailbox);
|
||||
|
||||
// Check for number of contacts on mailbox via API every 100ms
|
||||
// Check for number of contacts on mailbox via API every 100ms.
|
||||
// This should be quick and will succeed with first call.
|
||||
retryUntilSuccessOrTimeout(1_000, 100, () -> {
|
||||
Collection<ContactId> contacts = api.getContacts(props1);
|
||||
return contacts.size() == 1;
|
||||
@@ -39,20 +40,17 @@ public class MailboxIntegrationTest extends AbstractMailboxIntegrationTest {
|
||||
// send message and wait for it to arrive via mailbox
|
||||
sendMessage(c1, contact2From1.getId(), "test");
|
||||
|
||||
// restart Tor for c1 to cause an immediate upload
|
||||
// and wait until file arrived on mailbox
|
||||
restartTor(c1);
|
||||
retryUntilSuccessOrTimeout(5_000, 100, () -> {
|
||||
// wait until file arrived on mailbox
|
||||
retryUntilSuccessOrTimeout(5_000, 500, () -> {
|
||||
List<MailboxFile> files = api.getFiles(props2, props2.getInboxId());
|
||||
return files.size() > 0;
|
||||
return files.size() > 1;
|
||||
});
|
||||
|
||||
// restart Tor for c2 to cause an immediate download
|
||||
// and wait for message to arrive
|
||||
restartTor(c2);
|
||||
awaitPendingMessageDelivery(1, 5_000);
|
||||
// wait for message to arrive
|
||||
// this might require 2nd download cycle after Tor reachability period
|
||||
awaitPendingMessageDelivery(1);
|
||||
|
||||
// private message arrived for c2
|
||||
// assert that private message arrived for c2
|
||||
int size = getFromDb(c2, txn -> c2.getMessagingManager()
|
||||
.getMessageHeaders(txn, contact1From2.getId()).size());
|
||||
assertEquals(1, size);
|
||||
|
||||
@@ -24,7 +24,7 @@ import dagger.Component;
|
||||
BrambleCoreIntegrationTestModule.class,
|
||||
BrambleCoreModule.class,
|
||||
BriarCoreModule.class,
|
||||
TestUrlConverterModule.class,
|
||||
TestModularMailboxModule.class,
|
||||
MailboxTestPluginConfigModule.class,
|
||||
TestSocksModule.class,
|
||||
TestDnsModule.class,
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static java.lang.System.currentTimeMillis;
|
||||
import static org.briarproject.bramble.mailbox.MailboxTestUtils.createHttpClientProvider;
|
||||
import static org.briarproject.bramble.mailbox.TestUrlConverterModule.urlConverter;
|
||||
import static org.briarproject.bramble.mailbox.TestModularMailboxModule.urlConverter;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
class MailboxIntegrationTestUtils {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.briarproject.bramble.mailbox;
|
||||
|
||||
import org.briarproject.nullsafety.NotNullByDefault;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
class TestMailboxConfigImpl implements MailboxConfig {
|
||||
|
||||
@Inject
|
||||
TestMailboxConfigImpl() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getApiCallerMinRetryInterval() {
|
||||
return 1000; // MailboxApiCaller.MIN_RETRY_INTERVAL_MS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getApiCallerMaxRetryInterval() {
|
||||
return 2000; // MailboxApiCaller.MAX_RETRY_INTERVAL_MS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTorReachabilityPeriod() {
|
||||
return 5000; // TorReachabilityMonitor.REACHABILITY_PERIOD_MS;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,12 @@ import static org.briarproject.bramble.mailbox.AbstractMailboxIntegrationTest.UR
|
||||
|
||||
@Module
|
||||
@NotNullByDefault
|
||||
class TestUrlConverterModule {
|
||||
class TestModularMailboxModule {
|
||||
|
||||
@Provides
|
||||
MailboxConfig provideMailboxConfig(TestMailboxConfigImpl mailboxConfig) {
|
||||
return mailboxConfig;
|
||||
}
|
||||
|
||||
static UrlConverter urlConverter = onion -> URL_BASE;
|
||||
|
||||
Reference in New Issue
Block a user