-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add job to test scripts printed in README (#249)
* test: add workflow to test readme scripts * ci: run doc test on completed integration tst * does this do it? * ci: include docs tests in integration workflow
- Loading branch information
Showing
7 changed files
with
216 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
set -xe | ||
|
||
hc s clean | ||
echo "" | hc s --piped create | ||
echo "" | hc s --piped -f=65000 run & | ||
HC_ID=$! | ||
echo "HC_ID is $HC_ID" | ||
sleep 5 | ||
|
||
set +e | ||
|
||
npm run build | ||
npx tsx doc-test-app-ws.ts | ||
|
||
pkill -15 -P $HC_ID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { | ||
AdminWebsocket, | ||
AppWebsocket, | ||
CellType, | ||
type ActionHash, | ||
type CallZomeRequest, | ||
} from "./lib/index.js"; | ||
|
||
const adminWs = await AdminWebsocket.connect({ | ||
url: new URL("ws://127.0.0.1:65000"), | ||
wsClientOptions: { origin: "my-happ" }, | ||
}); | ||
const agent_key = await adminWs.generateAgentPubKey(); | ||
const role_name = "foo"; | ||
const installed_app_id = "test-app"; | ||
const appInfo = await adminWs.installApp({ | ||
agent_key, | ||
path: "./test/e2e/fixture/test.happ", | ||
installed_app_id, | ||
membrane_proofs: {}, | ||
}); | ||
await adminWs.enableApp({ installed_app_id }); | ||
if (!(CellType.Provisioned in appInfo.cell_info[role_name][0])) { | ||
throw new Error(`No cell found under role name ${role_name}`); | ||
} | ||
const { cell_id } = appInfo.cell_info[role_name][0][CellType.Provisioned]; | ||
await adminWs.authorizeSigningCredentials(cell_id); | ||
await adminWs.attachAppInterface({ port: 65001, allowed_origins: "my-happ" }); | ||
const issuedToken = await adminWs.issueAppAuthenticationToken({ | ||
installed_app_id, | ||
}); | ||
const appWs = await AppWebsocket.connect({ | ||
url: new URL("ws://127.0.0.1:65001"), | ||
token: issuedToken.token, | ||
wsClientOptions: { origin: "my-happ" }, | ||
}); | ||
|
||
const zomeCallPayload: CallZomeRequest = { | ||
cell_id, | ||
zome_name: "foo", | ||
fn_name: "foo", | ||
provenance: agent_key, | ||
payload: null, | ||
}; | ||
|
||
const response: ActionHash = await appWs.callZome(zomeCallPayload, 30000); | ||
console.log("zome call response is", response); | ||
|
||
await appWs.client.close(); | ||
await adminWs.client.close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
set -xe | ||
|
||
hc s clean | ||
echo "" | hc s --piped create | ||
echo "" | hc s --piped -f=65000 run & | ||
HC_ID=$! | ||
echo "HC_ID is $HC_ID" | ||
sleep 5 | ||
|
||
set +e | ||
|
||
npm run build | ||
npx tsx doc-test-signal.ts | ||
|
||
pkill -15 -P $HC_ID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { AdminWebsocket, AppWebsocket, CellType } from "./lib/index.js"; | ||
|
||
const adminWs = await AdminWebsocket.connect({ | ||
url: new URL("ws://127.0.0.1:65000"), | ||
wsClientOptions: { origin: "my-happ" }, | ||
}); | ||
const agent_key = await adminWs.generateAgentPubKey(); | ||
const role_name = "foo"; | ||
const installed_app_id = "test-app"; | ||
const appInfo = await adminWs.installApp({ | ||
agent_key, | ||
path: "./test/e2e/fixture/test.happ", | ||
installed_app_id, | ||
membrane_proofs: {}, | ||
}); | ||
await adminWs.enableApp({ installed_app_id }); | ||
if (!(CellType.Provisioned in appInfo.cell_info[role_name][0])) { | ||
throw new Error(`No cell found under role name ${role_name}`); | ||
} | ||
const { cell_id } = appInfo.cell_info[role_name][0][CellType.Provisioned]; | ||
await adminWs.authorizeSigningCredentials(cell_id); | ||
await adminWs.attachAppInterface({ port: 65001, allowed_origins: "my-happ" }); | ||
const issuedToken = await adminWs.issueAppAuthenticationToken({ | ||
installed_app_id, | ||
}); | ||
const appWs = await AppWebsocket.connect({ | ||
url: new URL("ws://127.0.0.1:65001"), | ||
token: issuedToken.token, | ||
wsClientOptions: { origin: "my-happ" }, | ||
}); | ||
|
||
let signalCb; | ||
const signalReceived = new Promise<void>((resolve) => { | ||
signalCb = (signal) => { | ||
console.log("signal received", signal); | ||
// act on signal | ||
resolve(); | ||
}; | ||
}); | ||
|
||
appWs.on("signal", signalCb); | ||
|
||
// trigger an emit_signal | ||
await appWs.callZome({ | ||
cell_id, | ||
zome_name: "foo", | ||
fn_name: "emitter", | ||
provenance: agent_key, | ||
payload: null, | ||
}); | ||
await signalReceived; | ||
|
||
await appWs.client.close(); | ||
await adminWs.client.close(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.