Skip to content

Commit 11e31bc

Browse files
committed
test: use individual users for Matrix clients
1 parent 5f7ca5a commit 11e31bc

File tree

4 files changed

+41
-15
lines changed

4 files changed

+41
-15
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,5 @@ whisper.cpp/whisper.cpp-*/
7878

7979
# FVM Version Cache
8080
.fvm/
81+
82+
integration_test/dendrite/config/jetstream/

integration_test/matrix_service_test.dart

+29-10
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,41 @@ void main() {
2121
group('MatrixService Tests', () {
2222
final mockLoggingDb = MockLoggingDb();
2323
final secureStorageMock = MockSecureStorage();
24-
const testUserEnv = 'TEST_USER';
24+
const testUserEnv1 = 'TEST_USER1';
25+
const testUserEnv2 = 'TEST_USER2';
2526
const testServerEnv = 'TEST_SERVER';
2627
const testPasswordEnv = 'TEST_PASSWORD';
2728
const testSlowNetworkEnv = 'SLOW_NETWORK';
2829

29-
if (!const bool.hasEnvironment(testUserEnv)) {
30-
debugPrint('TEST_USER not defined!!! Run via run_matrix_tests.sh');
30+
if (!const bool.hasEnvironment(testUserEnv1)) {
31+
debugPrint('TEST_USER1 not defined!!! Run via run_matrix_tests.sh');
3132
exit(1);
3233
}
33-
const testUserName = String.fromEnvironment(testUserEnv);
34+
35+
if (!const bool.hasEnvironment(testUserEnv2)) {
36+
debugPrint('TEST_USER2 not defined!!! Run via run_matrix_tests.sh');
37+
exit(1);
38+
}
39+
40+
const testUserName1 = String.fromEnvironment(testUserEnv1);
41+
const testUserName2 = String.fromEnvironment(testUserEnv1);
42+
3443
const testHomeServer = bool.hasEnvironment(testServerEnv)
3544
? String.fromEnvironment(testServerEnv)
3645
: 'http://localhost:8008';
3746
const testPassword = bool.hasEnvironment(testPasswordEnv)
3847
? String.fromEnvironment(testPasswordEnv)
3948
: '?Secret123@!';
4049

41-
const config = MatrixConfig(
50+
const config1 = MatrixConfig(
4251
homeServer: testHomeServer,
43-
user: testUserName,
52+
user: testUserName1,
53+
password: testPassword,
54+
);
55+
56+
const config2 = MatrixConfig(
57+
homeServer: testHomeServer,
58+
user: testUserName2,
4459
password: testPassword,
4560
);
4661

@@ -67,7 +82,7 @@ void main() {
6782
() async {
6883
debugPrint('\n--- AliceDevice goes live');
6984
final aliceDevice = MatrixService(
70-
matrixConfig: config,
85+
matrixConfig: config1,
7186
hiveDbName: 'AliceDevice',
7287
deviceDisplayName: 'AliceDevice',
7388
);
@@ -89,7 +104,7 @@ void main() {
89104

90105
debugPrint('\n--- BobDevice goes live');
91106
final bobDevice = MatrixService(
92-
matrixConfig: config,
107+
matrixConfig: config2,
93108
hiveDbName: 'BobDevice',
94109
deviceDisplayName: 'BobDevice',
95110
);
@@ -101,14 +116,18 @@ void main() {
101116
final joinRes2 = await bobDevice.joinRoom(roomId);
102117
debugPrint('BobDevice - room joined: $joinRes2');
103118

119+
await Future<void>.delayed(
120+
const Duration(seconds: 1 * delayFactor),
121+
);
122+
104123
await waitUntil(() => aliceDevice.getUnverified().length == 1);
105124
await waitUntil(() => bobDevice.getUnverified().length == 1);
106125

107126
final unverifiedAlice = aliceDevice.getUnverified();
108127
final unverifiedBob = bobDevice.getUnverified();
109128

110-
debugPrint('AliceDevice - unverified: $unverifiedAlice');
111-
debugPrint('BobDevice - unverified: $unverifiedBob');
129+
debugPrint('\nAliceDevice - unverified: $unverifiedAlice');
130+
debugPrint('\nBobDevice - unverified: $unverifiedBob');
112131

113132
expect(unverifiedAlice.length, 1);
114133
expect(unverifiedBob.length, 1);

integration_test/run_matrix_tests.sh

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
#!/bin/bash
22

33
# Create user name
4-
uuid=$(uuidgen)
5-
TEST_USER="$(tr '[:upper:]' '[:lower:]' <<< "$uuid")"
4+
uuid1=$(uuidgen)
5+
uuid2=$(uuidgen)
6+
TEST_USER1="$(tr '[:upper:]' '[:lower:]' <<< "$uuid1")"
7+
TEST_USER2="$(tr '[:upper:]' '[:lower:]' <<< "$uuid2")"
68

79
# Go to dendrite docker directory that contains config and keys
810
cd ../dendrite/build/docker/config || exit
911

1012
# Create user using the create-account binary in dendrite build
11-
../../../bin/create-account -config dendrite.yaml -username "$TEST_USER" -admin -password "?Secret123@!"
13+
../../../bin/create-account -config dendrite.yaml -username "$TEST_USER1" -admin -password "?Secret123@!"
14+
../../../bin/create-account -config dendrite.yaml -username "$TEST_USER2" -admin -password "?Secret123@!"
1215
cd - > /dev/null || exit
1316

14-
fvm flutter test integration_test/matrix_service_test.dart --dart-define=TEST_USER="@$TEST_USER:localhost"
17+
fvm flutter test integration_test/matrix_service_test.dart \
18+
--dart-define=TEST_USER1="@$TEST_USER1:localhost" \
19+
--dart-define=TEST_USER2="@$TEST_USER2:localhost"

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: lotti
22
description: Achieve your goals and keep your data private with Lotti.
33
publish_to: 'none'
4-
version: 0.9.444+2431
4+
version: 0.9.445+2432
55

66
msix_config:
77
display_name: LottiApp

0 commit comments

Comments
 (0)