Skip to content

Commit

Permalink
Attempt to get test working
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Nov 19, 2024
1 parent fb6cec6 commit 1e8680e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,16 @@ jobs:
homerunnersha: ${{ steps.gitsha.outputs.sha }}
steps:
- name: Checkout matrix-org/complement
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: matrix-org/complement
ref: e1b98b67a3ca19551fe8640d10bd3611c0995288
- name: Get complement git sha
id: gitsha
run: echo sha=`git rev-parse --short HEAD` >> "$GITHUB_OUTPUT"
- name: Cache homerunner
id: cached
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: homerunner
key: ${{ runner.os }}-homerunner-${{ steps.gitsha.outputs.sha }}
Expand Down Expand Up @@ -135,18 +136,18 @@ jobs:
run: |
sudo apt-get update && sudo apt-get install -y libolm3
- name: Load cached homerunner bin
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: homerunner
key: ${{ runner.os }}-homerunner-${{ needs.build-synapse.outputs.homerunnersha }}
fail-on-cache-miss: true # Shouldn't happen, we build this in the needs step.
- name: Checkout matrix-hookshot
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: matrix-hookshot
# Setup node & run tests
- name: Use Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: matrix-hookshot/.node-version
- uses: Swatinem/rust-cache@v2
Expand Down
5 changes: 3 additions & 2 deletions spec/util/e2e-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export class E2ETestEnv {
let cacheConfig: BridgeConfigRoot["cache"]|undefined;
if (opts.useRedis) {
cacheConfig = {
redisUri: `${REDIS_DATABASE_URI}/${Math.ceil(Math.random() * 99)}`,
redisUri: `${REDIS_DATABASE_URI}/${workerID}`,
}
}

Expand Down Expand Up @@ -248,7 +248,8 @@ export class E2ETestEnv {
}],
rooms: [],
aliases: [],
}
},
"de.sorunome.msc2409.push_ephemeral": true
};
const app = await start(config, registration);
app.listener.finaliseListeners();
Expand Down
20 changes: 13 additions & 7 deletions spec/util/homerunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,35 @@ export async function createHS(localparts: string[] = [], workerId: number, cryp
SenderLocalpart: 'hookshot',
RateLimited: false,
...{ASToken: asToken,
HSToken: hsToken},
HSToken: hsToken,
SendEphemeral: true,
EnableEncryption: true},
}]
}],
}
});
const [homeserverName, homeserver] = Object.entries(blueprintResponse.homeservers)[0];
// Skip AS user.
const users = Object.entries(homeserver.AccessTokens)
const users = await Promise.all(Object.entries(homeserver.AccessTokens)
.filter(([_uId, accessToken]) => accessToken !== asToken)
.map(([userId, accessToken]) => {
.map(async ([userId, accessToken]) => {
const cryptoStore = cryptoRootPath ? new RustSdkCryptoStorageProvider(path.join(cryptoRootPath, userId), RustSdkCryptoStoreType.Sqlite) : undefined;
const client = new E2ETestMatrixClient(homeserver.BaseURL, accessToken, new MemoryStorageProvider(), cryptoStore);
if (cryptoStore) {
await client.crypto.prepare();
}
// Start syncing proactively.
await client.start();
return {
userId: userId,
accessToken,
deviceId: homeserver.DeviceIDs[userId],
client: new E2ETestMatrixClient(homeserver.BaseURL, accessToken, new MemoryStorageProvider(), cryptoStore),
client,
}
}
);
));


// Start syncing proactively.
await Promise.all(users.map(u => void u.client.start()));
return {
users,
id: blueprint,
Expand Down
4 changes: 2 additions & 2 deletions src/Stores/RedisStorageProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ export class RedisStorageProvider extends RedisStorageContextualProvider impleme
}

public async addRegisteredUser(userId: string) {
this.redis.sadd(REGISTERED_USERS_KEY, [userId]);
await this.redis.sadd(REGISTERED_USERS_KEY, [userId]);
}

public async isUserRegistered(userId: string): Promise<boolean> {
return (await this.redis.sismember(REGISTERED_USERS_KEY, userId)) === 1;
}

public async setTransactionCompleted(transactionId: string) {
this.redis.sadd(COMPLETED_TRANSACTIONS_KEY, [transactionId]);
await this.redis.sadd(COMPLETED_TRANSACTIONS_KEY, [transactionId]);
}

public async isTransactionCompleted(transactionId: string): Promise<boolean> {
Expand Down
2 changes: 1 addition & 1 deletion src/appservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function getAppservice(config: BridgeConfig, registration: IAppserviceReg
},
storage: storage,
intentOptions: {
encryption: !!config.encryption,
encryption: !!cryptoStorage,
},
cryptoStorage: cryptoStorage,
});
Expand Down

0 comments on commit 1e8680e

Please sign in to comment.