mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 12:28:42 +00:00
tests: cover a peer restarting with the same key
A node restarting with the same key and contacting a peer by address gets answers encrypted with the ephemeral key of its previous run.
This commit is contained in:
1 parent
e78e54b8c5
commit
d23cb42b27
2 files changed
+29
No files matched your search
@@ -1634,6 +1634,33 @@ NetworkEngineTester::testTransportEphemeralBoundToAddress()
|
||||
CPPUNIT_ASSERT_EQUAL((size_t) 1, b.socket->sends.size());
|
||||
}
|
||||
|
||||
void
|
||||
NetworkEngineTester::testTransportRestartedPeerReconnects()
|
||||
{
|
||||
TransportConfig configA;
|
||||
configA.key = transport::KeyPair::generate();
|
||||
auto a = std::make_unique<TransportTestNode>("127.0.0.2", configA, 1);
|
||||
TransportTestNode b("127.0.0.3", {}, 2);
|
||||
bool done = false;
|
||||
a->ping(b.addr, done);
|
||||
a->deliverTo(b);
|
||||
b.deliverTo(*a);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
a->ping(a->node(b), done);
|
||||
a->deliverTo(b);
|
||||
b.deliverTo(*a);
|
||||
}
|
||||
|
||||
// a restarts with the same key, and contacts b by address: b must forget a's ephemeral key
|
||||
a = std::make_unique<TransportTestNode>("127.0.0.2", configA, 3);
|
||||
done = false;
|
||||
a->ping(b.addr, done);
|
||||
a->deliverTo(b);
|
||||
CPPUNIT_ASSERT(isEnvelope(b.socket->sends.at(0), transport::EnvelopeType::Initial));
|
||||
b.deliverTo(*a);
|
||||
CPPUNIT_ASSERT(done);
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user