@@ -152,10 +152,40 @@ def test_local_backup(self, tmp_path):
152
152
# Leave community
153
153
backend_client .rpc_valid_request ("wakuext_leaveCommunity" , [community_id ])
154
154
155
+ # Create chats
156
+ response = backend_client .rpc_valid_request ("wakuext_createGroupChatWithMembers" , [None , "test-group-chat" , []])
157
+ jsonResponse = response .json ()
158
+ result = response .json ().get ("result" , {})
159
+ assert result is not None , "Group chat creation failed"
160
+ chats = result .get ("chats" , [])
161
+ assert chats is not None , "Group chat was not created (None)"
162
+ assert len (chats ) == 1 , "Group chat was not created (empty)"
163
+ group_chat_id = chats [0 ].get ("id" , "" )
164
+ assert group_chat_id != "" , "Group chat ID was not returned"
165
+
166
+ backend_client .rpc_valid_request (
167
+ "wakuext_createOneToOneChat" ,
168
+ [
169
+ {
170
+ "id" : "0x043329fc08727f15c4ec9a17bf7d6a3dc44e9d0d8f782a55804f3660b28827194a365dc1765cf96b6fa5cd66"
171
+ + "6b9ee5298e8ac82f51f7952c4110cbf321d4f63864"
172
+ }
173
+ ],
174
+ )
175
+ jsonResponse = response .json ()
176
+ result = response .json ().get ("result" , {})
177
+ assert result is not None , "One-to-one chat creation failed"
178
+ chats = result .get ("chats" , [])
179
+ assert chats is not None , "One-to-one chat was not created (None)"
180
+ assert len (chats ) == 1 , "One-to-one chat was not created (empty)"
181
+ one_to_one_chat_id = chats [0 ].get ("id" , "" )
182
+ assert one_to_one_chat_id != "" , "One-to-one chat ID was not returned"
183
+
155
184
# Validate settings on the first backend client
156
185
response = backend_client .rpc_valid_request ("settings_getSettings" , [])
157
186
jsonResponse = response .json ()
158
187
result = response .json ().get ("result" , {})
188
+ assert result is not None , "Settings were not set"
159
189
assert result .get ("display-name" ) == "myname" , "Display name setting was not set"
160
190
assert result .get ("bio" ) == "new bio" , "Bio setting was not set"
161
191
assert result .get ("preferred-name" ) == "new-prefered-name" , "Preferred name setting was not set"
@@ -202,6 +232,21 @@ def test_local_backup(self, tmp_path):
202
232
assert result [1 ].get ("description" ) == "This is another test community" , "Second community description was not restored correctly"
203
233
assert not result [1 ].get ("joined" ), "Second community was not left correctly"
204
234
235
+ # Validate chats
236
+ response = backend_client .rpc_valid_request ("wakuext_chats" , [])
237
+ jsonResponse = response .json ()
238
+ result = jsonResponse .get ("result" , [])
239
+ assert result is not None , "Chats were not restored"
240
+ for chat in result :
241
+ if chat .get ("id" ) == group_chat_id :
242
+ assert chat .get ("name" ) == "test-group-chat" , "Group chat name was not restored correctly"
243
+ elif chat .get ("id" ) == one_to_one_chat_id :
244
+ assert (
245
+ chat .get ("name" )
246
+ == "0x043329fc08727f15c4ec9a17bf7d6a3dc44e9d0d8f782a55804f3660b28827194a365dc17"
247
+ + "65cf96b6fa5cd666b9ee5298e8ac82f51f7952c4110cbf321d4f63864"
248
+ ), "One-to-one chat name was not restored correctly"
249
+
205
250
# Perform the backup
206
251
response = backend_client .api_valid_request ("PerformLocalBackup" , "" )
207
252
jsonResponse = response .json ()
@@ -290,3 +335,18 @@ def test_local_backup(self, tmp_path):
290
335
assert len (result ) == 1 , "Communities were not restored correctly"
291
336
assert result [0 ].get ("name" ) == "Test Community" , "Community name was not restored correctly"
292
337
assert result [0 ].get ("description" ) == "This is a test community" , "Community description was not restored correctly"
338
+
339
+ # Validate chats
340
+ response = backend_client2 .rpc_valid_request ("wakuext_chats" , [])
341
+ jsonResponse = response .json ()
342
+ result = jsonResponse .get ("result" , [])
343
+ assert result is not None , "Chats were not restored"
344
+ for chat in result :
345
+ if chat .get ("id" ) == group_chat_id :
346
+ assert chat .get ("name" ) == "test-group-chat" , "Group chat name was not restored correctly"
347
+ elif chat .get ("id" ) == one_to_one_chat_id :
348
+ assert (
349
+ chat .get ("name" )
350
+ == "0x043329fc08727f15c4ec9a17bf7d6a3dc44e9d0d8f782a55804f3660b2882"
351
+ + "7194a365dc1765cf96b6fa5cd666b9ee5298e8ac82f51f7952c4110cbf321d4f63864"
352
+ ), "One-to-one chat name was not restored correctly"
0 commit comments