Add test verifying reputation cannot be sourced from incinerator

This commit is contained in:
Ladd Hoffman 2023-03-14 21:18:12 -05:00
parent 353190fdcd
commit 2ed07b7f5e
2 changed files with 11 additions and 0 deletions

View File

@ -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,

View File

@ -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/);
}
});
});
});