Skip to content

Commit f6eb45a

Browse files
Replace dendrite with conduit for testing
This change uses a different server implementation that implements the new room api.
1 parent d9feb70 commit f6eb45a

File tree

3 files changed

+36
-23
lines changed

3 files changed

+36
-23
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ Some tests requires a local matrix server, run integration service:
4343

4444
```ShellSession
4545
# In another terminal:
46-
$ nix develop -c dendrite-start
46+
$ nix develop -c conduit-start
4747
# Before running cabal test:
48-
$ export $(nix develop -c dendrite-setup)
48+
$ export $(nix develop -c conduit-setup)
4949
$ cabal test all
5050
```
5151

flake.nix

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,44 @@
3434
})
3535
];
3636
pkgs = import nixpkgs { inherit config overlays system; };
37-
dendriteHome = "/tmp/dendrite-home";
37+
conduitHome = "/tmp/conduit-home";
3838

39-
# A script to start a local matrix server with dendrite
40-
dendriteStart = pkgs.writeScriptBin "dendrite-start" ''
39+
conduitConfig = pkgs.writeTextFile {
40+
name = "conduit.toml";
41+
text = ''
42+
[global]
43+
server_name = "localhost"
44+
database_path = "${conduitHome}"
45+
database_backend = "rocksdb"
46+
port = 6167
47+
max_request_size = 20_000_000
48+
allow_registration = true
49+
allow_federation = false
50+
trusted_servers = []
51+
#log = "info,state_res=warn,rocket=off,_=off,sled=off"
52+
address = "127.0.0.1"
53+
'';
54+
};
55+
56+
# A script to start a local matrix server with conduit
57+
conduitStart = pkgs.writeScriptBin "conduit-start" ''
4158
#!/bin/sh -e
42-
mkdir -p ${dendriteHome}
43-
cd ${dendriteHome}
44-
if ! test -f dendrite.yaml; then
45-
${pkgs.dendrite}/bin/generate-config > dendrite.yaml
46-
sed -e 's|/var/log/dendrite|${dendriteHome}/logs|' -i dendrite.yaml
47-
fi
48-
if ! test -f matrix_key.pem; then
49-
${pkgs.dendrite}/bin/generate-keys -private-key matrix_key.pem -tls-cert test.crt -tls-key test.key
50-
fi
51-
${pkgs.dendrite}/bin/dendrite-monolith-server
59+
mkdir -p ${conduitHome}
60+
exec env CONDUIT_CONFIG=${conduitConfig} ${pkgs.matrix-conduit}/bin/conduit
5261
'';
5362

5463
# A script to setup test environment
55-
dendriteSetup = pkgs.writeScriptBin "dendrite-setup" ''
64+
conduitSetup = pkgs.writeScriptBin "conduit-setup" ''
5665
#!/bin/sh -e
57-
cd ${dendriteHome}
58-
HOMESERVER_URL=http://localhost:8008
66+
HOMESERVER_URL=http://localhost:6167
67+
export PATH=$PATH:${pkgs.jq}/bin:${pkgs.curl}/bin
5968
create_token () {
60-
${pkgs.dendrite}/bin/create-account -username $1 -password $2 || true
61-
${pkgs.curl}/bin/curl -XPOST $HOMESERVER_URL/_matrix/client/r0/login -d '{"user": "'$1'", "password": "'$2'", "type": "m.login.password"}' | ${pkgs.jq}/bin/jq -r ".access_token"
69+
REGISTER_TOKEN=$(curl -XPOST $HOMESERVER_URL/_matrix/client/v3/register -d '{"auth":{"type": "m.login.dummy"}, "username": "'$1'", "password": "'$2'"}' | jq -r ".access_token")
70+
if [ "$REGISTER_TOKEN" != "null" ]; then
71+
echo $REGISTER_TOKEN
72+
else
73+
curl -XPOST $HOMESERVER_URL/_matrix/client/v3/login -d '{"type": "m.login.password", "identifier": {"type": "m.id.user", "user": "'$1'"}, "password": "'$2'"}' | jq -r ".access_token"
74+
fi
6275
}
6376
echo HOMESERVER_URL=$HOMESERVER_URL
6477
echo PRIMARY_TOKEN=$(create_token "test-user" "test-pass")
@@ -88,8 +101,8 @@
88101
pkgs.haskell-language-server
89102
pkgs.ghcid
90103
testScript
91-
dendriteStart
92-
dendriteSetup
104+
conduitStart
105+
conduitSetup
93106
];
94107

95108
withHoogle = false;

matrix-client/src/Network/Matrix/Tutorial.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
-- > git clone https://github.com/matrix-org/dendrite
1111
-- > cd dendrite; ./build.sh; ./bin/generate-keys --private-key matrix_key.pem; cp dendrite-config.yaml dendrite.yaml
1212
-- > ./bin/dendrite-monolith-server --config dendrite.yaml
13-
-- > curl -XPOST http://localhost:8008/_matrix/client/r0/register -d'{"username": "tristanC", "password": "supersecret", "auth": {"type": "mlogin.dummy"}}
13+
-- > curl -XPOST http://localhost:8008/_matrix/client/r0/register -d'{"username": "tristanC", "password": "supersecret", "auth": {"type": "m.login.dummy"}}'
1414
--
1515
-- To avoid manipulating the token directly, put it in your environment:
1616
--

0 commit comments

Comments
 (0)