diff --git a/forum-network/src/classes/forum.js b/forum-network/src/classes/forum.js
index cbd0629..ec6da68 100644
--- a/forum-network/src/classes/forum.js
+++ b/forum-network/src/classes/forum.js
@@ -1,5 +1,5 @@
import { Actor } from './actor.js';
-import { WDAG, Vertex } from './wdag.js';
+import { WDAG } from './wdag.js';
import { Action } from './action.js';
import { CryptoUtil } from './crypto.js';
import params from '../params.js';
@@ -145,6 +145,7 @@ export class Forum extends ReputationHolder {
});
if (params.referenceChainLimit === null || depth <= params.referenceChainLimit) {
+ let totalOutboundAmount = 0;
for (const citationEdge of postVertex.getEdges(CITATION, true)) {
const { to: citedPostVertex, weight } = citationEdge;
let outboundAmount = weight * increment;
@@ -165,8 +166,9 @@ export class Forum extends ReputationHolder {
});
outboundAmount -= refundFromOutbound;
this.posts.setEdge(BALANCE, postVertex, citedPostVertex, balance + outboundAmount);
- increment -= outboundAmount * params.leachingValue;
+ totalOutboundAmount += outboundAmount;
}
+ increment -= totalOutboundAmount * params.leachingValue;
}
const rawNewValue = post.value + increment;
diff --git a/forum-network/src/index.html b/forum-network/src/index.html
index 9d68a12..947bda4 100644
--- a/forum-network/src/index.html
+++ b/forum-network/src/index.html
@@ -14,6 +14,7 @@
diff --git a/forum-network/src/tests/forum3.test.html b/forum-network/src/tests/forum3.test.html
new file mode 100644
index 0000000..dcb8a1b
--- /dev/null
+++ b/forum-network/src/tests/forum3.test.html
@@ -0,0 +1,27 @@
+
+
+ Forum test 3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/forum-network/src/tests/scripts/forum3.test.js b/forum-network/src/tests/scripts/forum3.test.js
new file mode 100644
index 0000000..662f04c
--- /dev/null
+++ b/forum-network/src/tests/scripts/forum3.test.js
@@ -0,0 +1,42 @@
+import { ForumTest } from './forum.test-util.js';
+
+describe('Forum', () => {
+ const forumTest = new ForumTest();
+
+ before(async () => {
+ await forumTest.setup();
+ });
+
+ context('Redistribute power', async () => {
+ it('Post1', async () => {
+ const { forum, experts, posts } = forumTest;
+ await forumTest.addPost(experts[0], 10);
+ forum.getPost(posts[0]).value.should.equal(10);
+ });
+
+ it('Post2', async () => {
+ const { forum, experts, posts } = forumTest;
+ await forumTest.addPost(experts[0], 10);
+ forum.getPost(posts[0]).value.should.equal(10);
+ forum.getPost(posts[1]).value.should.equal(10);
+ });
+
+ it('Post3 cites Post2 and negatively cites Post1', async () => {
+ const { forum, experts, posts } = forumTest;
+ await forumTest.addPost(experts[0], 20, [
+ { postId: posts[0], weight: -0.5 },
+ { postId: posts[1], weight: 0.5 },
+ ]);
+ forum.getPost(posts[0]).value.should.equal(0);
+ forum.getPost(posts[1]).value.should.equal(20);
+ forum.getPost(posts[2]).value.should.equal(20);
+ });
+ });
+});
+
+// await addPost(experts[0], 10);
+// await addPost(experts[0], 10, [{ postId: posts[3], weight: -1 }]);
+// await addPost(experts[0], 10, [{ postId: posts[4], weight: -1 }]);
+
+// await addPost(expert3, 'Post 4', 100, [{ postId: postId2, weight: -1 }]);
+// await addPost(expert1, 'Post 5', 100, [{ postId: postId3, weight: -1 }]);