dao-governance-framework/forum-network/public/tests/forum-network.html

74 lines
2.1 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<head>
<title>Forum Network test</title>
<link type="text/css" rel="stylesheet" href="/index.css" />
</head>
<body>
<div id="forum-network"></div>
</body>
<script type="module">
import { Box } from "/classes/box.js";
import { Scene } from "/classes/scene.js";
import { PostContent } from "/classes/post.js";
import { Member } from "/classes/member.js";
import { ForumNode } from "/classes/forum-node.js";
import { ForumNetwork } from "/classes/forum-network.js";
import { CryptoUtil } from "/classes/crypto.js";
import { delay } from "/util.js";
const rootElement = document.getElementById("forum-network");
const rootBox = new Box("rootBox", rootElement).flex();
window.scene = new Scene("Forum Network test", rootBox).log(
"sequenceDiagram"
);
window.author1 = await new Member("author1", window.scene).initialize();
window.author2 = await new Member("author2", window.scene).initialize();
window.forumNetwork = new ForumNetwork();
window.forumNode1 = await new ForumNode("node1", window.scene).initialize(
window.forumNetwork
);
window.forumNode2 = await new ForumNode("node2", window.scene).initialize(
window.forumNetwork
);
window.forumNode3 = await new ForumNode("node3", window.scene).initialize(
window.forumNetwork
);
const processInterval = setInterval(async () => {
await window.forumNode1.processNextMessage();
await window.forumNode2.processNextMessage();
await window.forumNode3.processNextMessage();
await window.scene.renderSequenceDiagram();
}, 100);
// const blockchain = new Blockchain();
window.post1 = new PostContent({ message: "hi" });
window.post1.id = CryptoUtil.randomUUID();
window.post2 = new PostContent({ message: "hello" }).addCitation(
window.post1.id,
1.0
);
await delay(1000);
await window.author1.submitPostViaNetwork(
window.forumNode1,
window.post1,
50
);
await delay(1000);
await window.author2.submitPostViaNetwork(
window.forumNode2,
window.post2,
100
);
await delay(1000);
clearInterval(processInterval);
</script>