Skip to content
Snippets Groups Projects
Commit 10243a1d authored by Jono Wenger's avatar Jono Wenger
Browse files

Add button to stop network follower

parent cb5e9799
No related branches found
No related tags found
1 merge request!6XX-4050 / Send E2E test
......@@ -2,3 +2,6 @@
This test sets up two clients in the browser and has one client send an E2E
message to the other.
## Running the Test
......@@ -32,6 +32,9 @@
// Get element to print log messages to
const logOutput = document.getElementById("logOutput")
// Get button that will stop the network follower
const stopNetworkFollowerBtn = document.getElementById("stopNetworkFollowerBtn")
// Client specific parameters
const recipientContactFile = '';
const myContactFileName = 'receiverContact.xxc';
......@@ -41,7 +44,7 @@
document.getElementById('ndfInput').addEventListener('change', e => {
let reader = new FileReader();
reader.onload = function (e) {
SendE2e(logOutput, e.target.result,
SendE2e(logOutput, stopNetworkFollowerBtn, e.target.result,
recipientContactFile, myContactFileName, statePath,
statePass);
};
......@@ -53,6 +56,7 @@
<body>
<h1 style="margin-top: 0">SendE2E: Receiver</h1>
<input type="button" style="float:right;" value="Download Log File" id="logFileDownload">
<input type="button" style="float:right;display:none;" value="Stop Network Follower" id="stopNetworkFollowerBtn">
<p>Selecting an NDF will start the client.</p>
<form id="startCmix">
<div>
......
......@@ -17,8 +17,6 @@
<script type="text/javascript" src="xxdk.js"></script>
<script type="text/javascript" src="../wasm_exec.js"></script>
<script>
// Use the encoder to convert a string to Uint8Array using enc.encode()
const go = new Go();
WebAssembly.instantiateStreaming(fetch("../xxdk.wasm"), go.importObject).then((result) => {
go.run(result.instance);
......@@ -34,6 +32,9 @@
// Get element to print log messages to
const logOutput = document.getElementById("logOutput")
// Get button that will stop the network follower
const stopNetworkFollowerBtn = document.getElementById("stopNetworkFollowerBtn")
// Client specific parameters
const recipientContactFile = '<xxc(2)3Rk5yAbf4xfrKbxuHXudBmy6Y8ftb9fxpqPzBOZL2nIDrgZ7Ugdw/BAr6UOUDFtAKbqUp7U6rfxNbwkYOuTySVFQqKpGAVNVaSWgNEUmG2fkK0bTCGamLELsIn+1dWmO3vA+TXx8HPq1Y79pFvs87wN5bD+F97sOto085y5oMuEwoSuQu4nwS9vCoXPgOpXJjeRBqKYOM/ObbtF4OAhwmR5C86F2pDSBAkenKVt2/4/SeHdlZqmriqd5QDMhEQlXdyjUl/GfuqOFHiTyqcfQq7krE3pNhI0YYZ2VPK+gnM7klGbTJeNZ23jQLxC8UjSTd/tZbz764dv3ncqQDhdGpqEjk/0larKIscMcKFT/JqHyduiVW6PjZ382vO+TZYre0pF4fG4bnY7rbiy2iegeH/GtemJJLtYsww1PFFRKEz7tM1P/B3+eT/CkrFwT2O7l6lobi7kamO4mmxX26IF7WOHc68c99SrIUKBzFViY67TCRvO3/yt11TOpudAsnoix7sEW8ZwozVnLvVvSBMr6FTEyDdn2JncL3l5xtWH7L5cimQsl+PLJTwtBKMX6aek9W4IuIBhdSu1yYQAAAgA7UO/H/diSxQainCF4/o6URQ==xxc>';
const myContactFileName = 'theirE2eContact.xxc';
......@@ -43,7 +44,7 @@
document.getElementById('ndfInput').addEventListener('change', e => {
let reader = new FileReader();
reader.onload = function (e) {
SendE2e(logOutput, e.target.result,
SendE2e(logOutput, stopNetworkFollowerBtn, e.target.result,
recipientContactFile, myContactFileName, statePath,
statePass);
};
......@@ -55,6 +56,7 @@
<body>
<h1 style="margin-top: 0">SendE2E: Sender</h1>
<input type="button" style="float:right;" value="Download Log File" id="logFileDownload">
<input type="button" style="float:right;display:none;" value="Stop Network Follower" id="stopNetworkFollowerBtn">
<p>Selecting an NDF will start the client.</p>
<form id="startCmix">
<div>
......
......@@ -5,8 +5,9 @@
// LICENSE file. //
////////////////////////////////////////////////////////////////////////////////
async function SendE2e(logOutput, ndf, recipientContactFile, myContactFileName,
statePath, statePassString) {
async function SendE2e(logOutput, stopNetworkFollowerBtn, ndf,
recipientContactFile, myContactFileName, statePath,
statePassString) {
const htmlConsole = newHtmlConsole(logOutput)
......@@ -101,6 +102,12 @@ async function SendE2e(logOutput, ndf, recipientContactFile, myContactFileName,
htmlConsole.log("Started network follower")
stopNetworkFollowerBtn.style.display = 'block';
stopNetworkFollowerBtn.addEventListener('click', () => {
htmlConsole.log("Stopping network follower")
net.StopNetworkFollower()
})
// Provide a callback that will be signalled when network health status changes
let health = false
net.AddHealthCallback({
......@@ -112,11 +119,11 @@ async function SendE2e(logOutput, ndf, recipientContactFile, myContactFileName,
htmlConsole.log("Waiting for network to be healthy")
try {
await sleepUntil(() => health === true, 25000);
htmlConsole.log("Network is healthy: " + health)
} catch {
htmlConsole.error("Timed out. Network is not healthy: " + health)
throw new Error("Timed out. Network is not healthy: " + health)
}
htmlConsole.log("Network is healthy: " + health)
////////////////////////////////////////////////////////////////////////////
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment