Skip to content

Commit 406a761

Browse files
authored
[dev] Update instructions to run tests (#208)
We have for very long relied on folks relying on some form of production infra to test this. This change now allows folks to test this out with a local checkout of goval.
1 parent 91a844f commit 406a761

File tree

3 files changed

+33
-14
lines changed

3 files changed

+33
-14
lines changed

.semaphore/semaphore.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ version: v1.0
22
name: Node JS
33
agent:
44
machine:
5-
type: e1-standard-2
6-
os_image: ubuntu1804
5+
type: e2-standard-2
6+
os_image: ubuntu2204
77
execution_time_limit:
88
minutes: 30
99
fail_fast:
@@ -17,8 +17,7 @@ auto_cancel:
1717
global_job_config:
1818
prologue:
1919
commands:
20-
- sem-version node 16
21-
- sem-version cpp 5
20+
- sem-version node 18
2221
- checkout --use-cache
2322
- git switch -c pr
2423
- cache restore yarn-cache-main

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
`yarn add @replit/crosis @replit/protocol`
44

5-
Crosis relies on the `@replit/protocol` package as a peer dependency.
5+
Crosis relies on the `@replit/protocol` package as a peer dependency.
66

77
### Prerequisites
88

@@ -99,16 +99,17 @@ const closeChannel = client.openChannel({ service: 'exec' }, function open({ cha
9999

100100
### Developing
101101

102-
To run tests run
102+
To run tests, in your Replit devvm check out the goval repository and run `process-compose up`, then
103+
run
103104

104105
```bash
105-
USER_KEY_ID=XXXX USER_PRIVATE_KEY=XXXX yarn test
106+
yarn test
106107
```
107108

108109
To interact with a connected client in the browser run
109110

110111
```bash
111-
USER_KEY_ID=XXXX USER_PRIVATE_KEY=XXXX yarn debug
112+
yarn debug
112113
```
113114

114115
You can then access the client from the console an send messages like:

debug/genConnectionMetadata.js

+25-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ const crypto = require('crypto');
33
const { api } = require('@replit/protocol');
44
const paseto = require('./paseto');
55

6+
let cluster = 'mark';
7+
if (!process.env.USER_KEY_ID && !process.env.USER_PRIVATE_KEY) {
8+
process.env.USER_KEY_ID = 'dev';
9+
process.env.USER_PRIVATE_KEY =
10+
'h/Qn2Wtu0bq85i3EF17r/diy4xNdYAMkCgHxLmu3xG+ifQWRKYQL5x7jRX1VzhAAFdLHpNej6WGn31voprSCug==';
11+
cluster = 'development';
12+
}
13+
614
if (!process.env.USER_KEY_ID || !process.env.USER_PRIVATE_KEY) {
715
throw new Error('Expected USER_KEY_ID and USER_PRIVATE_KEY in ENV');
816
}
@@ -23,9 +31,9 @@ ${keyData.toString('base64')}
2331
function genConnectionMetadata(options) {
2432
const now = Date.now();
2533

26-
const restrictNetwork = !!options?.restrictNetwork;
34+
const restrictNetwork = !!(options && options.restrictNetwork);
2735

28-
const repl = options?.repl || {
36+
const repl = (options && options.repl) || {
2937
id: `testing-crosis-${Math.random().toString(36).split('.')[1]}`,
3038
language: 'bash',
3139
slug: Math.random().toString(36).slice(2),
@@ -44,7 +52,7 @@ function genConnectionMetadata(options) {
4452
exp: {
4553
seconds: Math.floor(now / 1000) + 60 * 60,
4654
},
47-
cluster: 'global',
55+
cluster,
4856
persistence: api.repl.Persistence.NONE,
4957
format: api.ReplToken.WireFormat.PROTOBUF,
5058
repl,
@@ -74,12 +82,23 @@ function genConnectionMetadata(options) {
7482
),
7583
);
7684

85+
const clusterMetadata =
86+
cluster === 'development'
87+
? {
88+
gurl: 'ws://localhost:4560',
89+
conmanURL: 'http://localhost:4560',
90+
dotdevHostname: `http://${repl.id}-00-replittesting.${cluster}.replit.localhost:8081`,
91+
}
92+
: {
93+
gurl: `wss://eval.${cluster}.replit.com`,
94+
conmanURL: `https://eval.${cluster}.replit.com`,
95+
dotdevHostname: `https://${repl.id}-00-replittesting.${cluster}.replit.dev`,
96+
};
97+
7798
return {
7899
token: encodedToken,
79-
gurl: 'wss://eval.global.replit.com',
80-
conmanURL: 'https://eval.global.replit.com',
81100
repl,
82-
dotdevHostname: `https://${repl.id}-00-replittesting.gloval.replit.dev`,
101+
...clusterMetadata,
83102
};
84103
}
85104

0 commit comments

Comments
 (0)