feat(enclave): add ping function for echoing input messages
This commit is contained in:
@@ -40,6 +40,12 @@
|
||||
<button onclick="runAllTests()" style="margin-left: 1rem;">Run All Tests</button>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>ping(message)</h2>
|
||||
<input type="text" id="ping-msg" value="hello from browser" placeholder="Message to echo">
|
||||
<button onclick="testPing()">Run</button>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>generate(credential)</h2>
|
||||
<input type="text" id="credential" value="dGVzdC1jcmVkZW50aWFs" placeholder="Base64 credential">
|
||||
|
||||
@@ -40,6 +40,26 @@ async function init() {
|
||||
}
|
||||
}
|
||||
|
||||
window.testPing = async function() {
|
||||
if (!enclave) return log(LogLevel.ERR, 'ping', 'Plugin not loaded');
|
||||
|
||||
const message = document.getElementById('ping-msg').value || 'hello';
|
||||
log(LogLevel.INFO, 'ping', `message="${message}"`);
|
||||
|
||||
try {
|
||||
const result = await enclave.ping(message);
|
||||
if (result.success) {
|
||||
log(LogLevel.OK, 'ping', `echo="${result.echo}"`, result);
|
||||
} else {
|
||||
log(LogLevel.ERR, 'ping', result.message, result);
|
||||
}
|
||||
return result;
|
||||
} catch (err) {
|
||||
log(LogLevel.ERR, 'ping', err?.message || String(err));
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
window.testGenerate = async function() {
|
||||
if (!enclave) return log(LogLevel.ERR, 'generate', 'Plugin not loaded');
|
||||
|
||||
@@ -137,6 +157,7 @@ window.runAllTests = async function() {
|
||||
log(LogLevel.INFO, null, '=== Running all tests ===');
|
||||
|
||||
try {
|
||||
await testPing();
|
||||
await testGenerate();
|
||||
await testLoad();
|
||||
await testExec();
|
||||
|
||||
Reference in New Issue
Block a user