mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
Fix introduction after one was declined
When we received a remote decline we always went into the REMOTE_DECLINED state while there's two cases where we need to go into the START state instead. So when the new request arrived, we weren't in START and thus aborted the protocol. This commit fixes this. Fixes #1516
This commit is contained in:
@@ -365,10 +365,13 @@ class IntroduceeProtocolEngine
|
||||
broadcastIntroductionResponseReceivedEvent(txn, s,
|
||||
s.getIntroducer().getId(), s.getRemote().author, m);
|
||||
|
||||
// Move to REMOTE_DECLINED state
|
||||
return IntroduceeSession.clear(s, REMOTE_DECLINED,
|
||||
s.getLastLocalMessageId(), s.getLocalTimestamp(),
|
||||
m.getMessageId());
|
||||
// Determine next state
|
||||
IntroduceeState state =
|
||||
s.getState() == AWAIT_RESPONSES ? REMOTE_DECLINED : START;
|
||||
|
||||
// Move to the next state
|
||||
return IntroduceeSession.clear(s, state, s.getLastLocalMessageId(),
|
||||
s.getLocalTimestamp(), m.getMessageId());
|
||||
}
|
||||
|
||||
private IntroduceeSession onRemoteResponseWhenDeclined(Transaction txn,
|
||||
|
||||
@@ -405,6 +405,51 @@ public class IntroductionIntegrationTest
|
||||
assertFalse(listener2.aborted);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewIntroductionAfterDecline() throws Exception {
|
||||
addListeners(false, true);
|
||||
|
||||
// make introduction
|
||||
long time = clock.currentTimeMillis();
|
||||
introductionManager0
|
||||
.makeIntroduction(contact1From0, contact2From0, null, time);
|
||||
|
||||
// sync request messages
|
||||
sync0To1(1, true);
|
||||
sync0To2(1, true);
|
||||
eventWaiter.await(TIMEOUT, 2);
|
||||
|
||||
// sync first response
|
||||
sync1To0(1, true);
|
||||
eventWaiter.await(TIMEOUT, 1);
|
||||
|
||||
// sync second response
|
||||
sync2To0(1, true);
|
||||
eventWaiter.await(TIMEOUT, 1);
|
||||
|
||||
// sync both forwarded response
|
||||
sync0To2(1, true);
|
||||
sync0To1(1, true);
|
||||
eventWaiter.await(TIMEOUT, 1);
|
||||
|
||||
assertFalse(listener0.aborted);
|
||||
assertFalse(listener1.aborted);
|
||||
assertFalse(listener2.aborted);
|
||||
|
||||
time = clock.currentTimeMillis();
|
||||
introductionManager0
|
||||
.makeIntroduction(contact1From0, contact2From0, null, time);
|
||||
|
||||
// sync request messages
|
||||
sync0To1(1, true);
|
||||
sync0To2(1, true);
|
||||
eventWaiter.await(TIMEOUT, 2);
|
||||
|
||||
assertFalse(listener0.aborted);
|
||||
assertFalse(listener1.aborted);
|
||||
assertFalse(listener2.aborted);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResponseAndAuthInOneSync() throws Exception {
|
||||
addListeners(true, true);
|
||||
|
||||
Reference in New Issue
Block a user