tests: wait for put before performing get

This commit is contained in:
Adrien Béraud committed 2018-12-26 00:56:49 -05:00
1 parent 56773baa98
commit c7604fbb8d
1 file changed
+5 -1
+5 -1
View File
@@ -50,7 +50,11 @@ DhtRunnerTester::testGetPut() {
auto key = dht::InfoHash::get("123");
dht::Value val {"hey"};
auto val_data = val.data;
node1.put(key, std::move(val));
std::promise<bool> p;
node1.put(key, std::move(val), [&](bool ok){
p.set_value(ok);
});
CPPUNIT_ASSERT(p.get_future().get());
auto vals = node2.get(key).get();
CPPUNIT_ASSERT(not vals.empty());
CPPUNIT_ASSERT(vals.front()->data == val_data);