Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
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
jami-daemon
Commits
51df8722
Commit
51df8722
authored
10 months ago
by
François-Simon Fauteux-Chapleau
Browse files
Options
Downloads
Patches
Plain Diff
contact_list: fix trust request update bugs
jami-client-qt#1804
Change-Id: I8cb3ffc7d5b1b2b8bbfe018b922c260a569411fb
parent
13e51e88
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/jamidht/contact_list.cpp
+2
-1
2 additions, 1 deletion
src/jamidht/contact_list.cpp
test/unitTest/conversation/conversationMembersEvent.cpp
+24
-0
24 additions, 0 deletions
test/unitTest/conversation/conversationMembersEvent.cpp
with
26 additions
and
1 deletion
src/jamidht/contact_list.cpp
+
2
−
1
View file @
51df8722
...
@@ -327,8 +327,9 @@ ContactList::onTrustRequest(const dht::InfoHash& peer_account,
...
@@ -327,8 +327,9 @@ ContactList::onTrustRequest(const dht::InfoHash& peer_account,
.
first
;
.
first
;
}
else
{
}
else
{
// Update trust request
// Update trust request
if
(
received
<
req
->
second
.
received
)
{
if
(
received
>
req
->
second
.
received
)
{
req
->
second
.
device
=
peer_device
;
req
->
second
.
device
=
peer_device
;
req
->
second
.
conversationId
=
conversationId
;
req
->
second
.
received
=
received
;
req
->
second
.
received
=
received
;
req
->
second
.
payload
=
payload
;
req
->
second
.
payload
=
payload
;
}
else
{
}
else
{
...
...
This diff is collapsed.
Click to expand it.
test/unitTest/conversation/conversationMembersEvent.cpp
+
24
−
0
View file @
51df8722
...
@@ -1657,12 +1657,25 @@ ConversationMembersEventTest::testAddContactTwice()
...
@@ -1657,12 +1657,25 @@ ConversationMembersEventTest::testAddContactTwice()
std
::
cout
<<
"
\n
Running test: "
<<
__func__
<<
std
::
endl
;
std
::
cout
<<
"
\n
Running test: "
<<
__func__
<<
std
::
endl
;
auto
aliceAccount
=
Manager
::
instance
().
getAccount
<
JamiAccount
>
(
aliceId
);
auto
aliceAccount
=
Manager
::
instance
().
getAccount
<
JamiAccount
>
(
aliceId
);
auto
aliceUri
=
aliceAccount
->
getUsername
();
auto
bobAccount
=
Manager
::
instance
().
getAccount
<
JamiAccount
>
(
bobId
);
auto
bobAccount
=
Manager
::
instance
().
getAccount
<
JamiAccount
>
(
bobId
);
auto
bobUri
=
bobAccount
->
getUsername
();
auto
bobUri
=
bobAccount
->
getUsername
();
// Add contact
aliceAccount
->
addContact
(
bobUri
);
aliceAccount
->
addContact
(
bobUri
);
aliceAccount
->
sendTrustRequest
(
bobUri
,
{});
aliceAccount
->
sendTrustRequest
(
bobUri
,
{});
CPPUNIT_ASSERT
(
cv
.
wait_for
(
lk
,
10s
,
[
&
]()
{
return
bobData
.
requestReceived
;
}));
CPPUNIT_ASSERT
(
cv
.
wait_for
(
lk
,
10s
,
[
&
]()
{
return
bobData
.
requestReceived
;
}));
auto
oldConversationId
=
aliceData
.
conversationId
;
CPPUNIT_ASSERT
(
!
oldConversationId
.
empty
());
// Check that the trust request's data is correct
auto
bobTrustRequests
=
bobAccount
->
getTrustRequests
();
CPPUNIT_ASSERT
(
bobTrustRequests
.
size
()
==
1
);
auto
request
=
bobTrustRequests
[
0
];
CPPUNIT_ASSERT
(
request
[
"from"
]
==
aliceUri
);
CPPUNIT_ASSERT
(
request
[
"conversationId"
]
==
oldConversationId
);
// Remove and re-add contact
aliceAccount
->
removeContact
(
bobUri
,
false
);
aliceAccount
->
removeContact
(
bobUri
,
false
);
CPPUNIT_ASSERT
(
cv
.
wait_for
(
lk
,
10s
,
[
&
]()
{
return
aliceData
.
removed
;
}));
CPPUNIT_ASSERT
(
cv
.
wait_for
(
lk
,
10s
,
[
&
]()
{
return
aliceData
.
removed
;
}));
// wait that connections are closed.
// wait that connections are closed.
...
@@ -1671,6 +1684,17 @@ ConversationMembersEventTest::testAddContactTwice()
...
@@ -1671,6 +1684,17 @@ ConversationMembersEventTest::testAddContactTwice()
aliceAccount
->
addContact
(
bobUri
);
aliceAccount
->
addContact
(
bobUri
);
aliceAccount
->
sendTrustRequest
(
bobUri
,
{});
aliceAccount
->
sendTrustRequest
(
bobUri
,
{});
CPPUNIT_ASSERT
(
cv
.
wait_for
(
lk
,
10s
,
[
&
]()
{
return
bobData
.
requestRemoved
&&
bobData
.
requestReceived
;
}));
CPPUNIT_ASSERT
(
cv
.
wait_for
(
lk
,
10s
,
[
&
]()
{
return
bobData
.
requestRemoved
&&
bobData
.
requestReceived
;
}));
auto
newConversationId
=
aliceData
.
conversationId
;
CPPUNIT_ASSERT
(
!
newConversationId
.
empty
());
CPPUNIT_ASSERT
(
newConversationId
!=
oldConversationId
);
// Check that the trust request's data was correctly
// updated when we received the second request
bobTrustRequests
=
bobAccount
->
getTrustRequests
();
CPPUNIT_ASSERT
(
bobTrustRequests
.
size
()
==
1
);
request
=
bobTrustRequests
[
0
];
CPPUNIT_ASSERT
(
request
[
"from"
]
==
aliceUri
);
CPPUNIT_ASSERT
(
request
[
"conversationId"
]
==
newConversationId
);
}
}
void
void
...
...
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