From 2ed07b7f5e1f91e91aa8021c3317ae7717e44e4d Mon Sep 17 00:00:00 2001 From: Ladd Hoffman Date: Tue, 14 Mar 2023 21:18:12 -0500 Subject: [PATCH] Add test verifying reputation cannot be sourced from incinerator --- forum-network/src/classes/dao/forum.js | 1 + forum-network/src/tests/scripts/forum/forum8.test.js | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/forum-network/src/classes/dao/forum.js b/forum-network/src/classes/dao/forum.js index e311e1f..7826cca 100644 --- a/forum-network/src/classes/dao/forum.js +++ b/forum-network/src/classes/dao/forum.js @@ -184,6 +184,7 @@ export class Forum extends ReputationHolder { if (citationEdge.to.id === INCINERATOR_ADDRESS) { // Only a positive amount may be incinerated! Otherwise the sink could be used as a source. if (outboundAmount < 0) { + this.scene?.flowchart?.log(`style ${citationEdge.from.id} fill:#620000`); throw new Error('Incinerator can only receive positive citations!'); } // Reputation sent to the incinerator is burned! This means it is deducted from the sender, diff --git a/forum-network/src/tests/scripts/forum/forum8.test.js b/forum-network/src/tests/scripts/forum/forum8.test.js index 86a7fa6..513cc91 100644 --- a/forum-network/src/tests/scripts/forum/forum8.test.js +++ b/forum-network/src/tests/scripts/forum/forum8.test.js @@ -34,6 +34,16 @@ describe('Forum', function tests() { forum.getPost(posts[0]).value.should.equal(0); forum.getPost(posts[1]).value.should.equal(0); }); + + it('Reputation can not be sourced from the incinerator', async () => { + try { + await forumTest.addPost(experts[0], 10, [ + { postId: INCINERATOR_ADDRESS, weight: -1 }, + ]); + } catch (e) { + e.message.should.match(/Incinerator can only receive positive citations/); + } + }); }); });