Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
c3bb16e9
Commit
c3bb16e9
authored
5 months ago
by
Adrien Béraud
Committed by
Adrien Béraud
5 months ago
Browse files
Options
Downloads
Patches
Plain Diff
tests: add testPutDuplicate
parent
3f27cd70
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/dhtrunnertester.cpp
+25
-0
25 additions, 0 deletions
tests/dhtrunnertester.cpp
tests/dhtrunnertester.h
+5
-0
5 additions, 0 deletions
tests/dhtrunnertester.h
with
30 additions
and
0 deletions
tests/dhtrunnertester.cpp
+
25
−
0
View file @
c3bb16e9
...
...
@@ -90,6 +90,31 @@ DhtRunnerTester::testGetPut() {
CPPUNIT_ASSERT
(
vals
.
front
()
->
data
==
val_data
);
}
void
DhtRunnerTester
::
testPutDuplicate
()
{
auto
key
=
dht
::
InfoHash
::
get
(
"123"
);
auto
val
=
std
::
make_shared
<
dht
::
Value
>
(
"hey"
);
val
->
id
=
42
;
auto
val_data
=
val
->
data
;
std
::
promise
<
bool
>
p1
;
std
::
promise
<
bool
>
p2
;
node2
.
put
(
key
,
val
,
[
&
](
bool
ok
){
p1
.
set_value
(
ok
);
});
node2
.
put
(
key
,
val
,
[
&
](
bool
ok
){
p2
.
set_value
(
ok
);
});
auto
p1ret
=
p1
.
get_future
().
get
();
auto
p2ret
=
p2
.
get_future
().
get
();
CPPUNIT_ASSERT
(
p1ret
);
CPPUNIT_ASSERT
(
p2ret
);
auto
vals
=
node1
.
get
(
key
).
get
();
CPPUNIT_ASSERT
(
not
vals
.
empty
());
CPPUNIT_ASSERT
(
vals
.
size
()
==
1
);
CPPUNIT_ASSERT
(
vals
.
front
()
->
data
==
val_data
);
}
void
DhtRunnerTester
::
testListen
()
{
std
::
mutex
mutex
;
...
...
This diff is collapsed.
Click to expand it.
tests/dhtrunnertester.h
+
5
−
0
View file @
c3bb16e9
...
...
@@ -31,6 +31,7 @@ class DhtRunnerTester : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE
(
DhtRunnerTester
);
CPPUNIT_TEST
(
testConstructors
);
CPPUNIT_TEST
(
testGetPut
);
CPPUNIT_TEST
(
testPutDuplicate
);
CPPUNIT_TEST
(
testListen
);
CPPUNIT_TEST
(
testListenLotOfBytes
);
CPPUNIT_TEST
(
testIdOps
);
...
...
@@ -55,6 +56,10 @@ class DhtRunnerTester : public CppUnit::TestFixture {
* Test get and put methods
*/
void
testGetPut
();
/**
* Test get and multiple put
*/
void
testPutDuplicate
();
/**
* Test listen method
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment