diff --git a/briar-core/src/main/java/org/briarproject/briar/remotewipe/RemoteWipeManagerImpl.java b/briar-core/src/main/java/org/briarproject/briar/remotewipe/RemoteWipeManagerImpl.java index c006a2432..239a1d839 100644 --- a/briar-core/src/main/java/org/briarproject/briar/remotewipe/RemoteWipeManagerImpl.java +++ b/briar-core/src/main/java/org/briarproject/briar/remotewipe/RemoteWipeManagerImpl.java @@ -97,7 +97,6 @@ public class RemoteWipeManagerImpl extends ConversationClientImpl @Override public void onDatabaseOpened(Transaction txn) throws DbException { - System.out.println("DATAbase opened"); if (db.containsGroup(txn, localGroup.getId())) return; db.addGroup(txn, localGroup); // Set things up for any pre-existing contacts @@ -140,7 +139,10 @@ public class RemoteWipeManagerImpl extends ConversationClientImpl for (int i = 0; i < receivedWipeMessages.size(); i++) { BdfList receivedWipeMessage = receivedWipeMessages.getList(i); // If we already have one from this contact, ignore - if (receivedWipeMessage.getLong(0).intValue() == contactId.getInt()) return false; + if (receivedWipeMessage.getLong(0).intValue() == contactId.getInt()) { + System.out.println("Duplicate wipe message received - ignoring"); + return false; + } // TODO filter the messages for old ones // long timestamp = receivedWipeMessage.getLong(1); diff --git a/briar-core/src/test/java/org/briarproject/briar/remotewipe/RemoteWipeIntegrationTest.java b/briar-core/src/test/java/org/briarproject/briar/remotewipe/RemoteWipeIntegrationTest.java index 7b6898814..02ea263da 100644 --- a/briar-core/src/test/java/org/briarproject/briar/remotewipe/RemoteWipeIntegrationTest.java +++ b/briar-core/src/test/java/org/briarproject/briar/remotewipe/RemoteWipeIntegrationTest.java @@ -130,6 +130,62 @@ public class RemoteWipeIntegrationTest extends BriarIntegrationTest { + // Assert that we do not already have a wipe setup + assertFalse(remoteWipeManager0.remoteWipeIsSetup(txn)); + remoteWipeManager0.setup(txn, + asList(contactId1From0, contactId2From0)); + // Now check that we do have a wipe setup + assertTrue(remoteWipeManager0.remoteWipeIsSetup(txn)); + }); + // Sync the setup messages to the contacts + sync0To1(1, true); + sync0To2(1, true); + + // The setup message from 0 should have arrived at 1 + Collection messages0At1 = + getMessages0At1(); + assertEquals(1, messages0At1.size()); + + Collection messages0At2 = + getMessages0At2(); + assertEquals(1, messages0At2.size()); + + for (ConversationMessageHeader h : messages0At1) { + assertTrue(h instanceof RemoteWipeMessageHeader); + RemoteWipeMessageHeader r = (RemoteWipeMessageHeader) h; + assertFalse(r.isLocal()); + } + + // The wipers check that they are now wipers + db1.transaction(false, txn -> { + assertTrue(remoteWipeManager1.amWiper(txn, contactId0From1)); + remoteWipeManager1.wipe(txn, contact0From1); + remoteWipeManager1.wipe(txn, contact0From1); + }); + + db2.transaction(false, txn -> { + assertTrue(remoteWipeManager2.amWiper(txn, contactId0From2)); +// remoteWipeManager2.wipe(txn, contact0From2); + }); + + // Sync the wipe messages to the wipee + sync1To0(2, true); +// sync2To0(1, true); + + Collection messages1At0 = + getMessages1At0(); + assertEquals(1, messages1At0.size()); + + Collection messages2At0 = + getMessages2At0(); + assertEquals(1, messages2At0.size()); + + assertFalse(panicCalled); + } private Collection getMessages1At0() throws DbException { return db0.transactionWithResult(true, txn -> remoteWipeManager0