diff --git a/ethereum/contracts/core/Forum.sol b/ethereum/contracts/core/Forum.sol index 869ad30..ffdbd5d 100644 --- a/ethereum/contracts/core/Forum.sol +++ b/ethereum/contracts/core/Forum.sol @@ -175,6 +175,11 @@ contract Forum is Reputation { return amount; } Post storage post = posts[postId]; + if (post.authors.length == 0) { + // We most likely got here via a citation to a post that hasn't been added yet. + // We support this scenario so that a citation graph can be imported one post at a time. + return amount; + } // Propagate negative citations first for (uint i = 0; i < post.citations.length; i++) { if (post.citations[i].weightPercent < 0) { diff --git a/ethereum/contracts/core/ValidationPools.sol b/ethereum/contracts/core/ValidationPools.sol index c6299a4..0ca9ae1 100644 --- a/ethereum/contracts/core/ValidationPools.sol +++ b/ethereum/contracts/core/ValidationPools.sol @@ -193,7 +193,6 @@ contract ValidationPools is Reputation, Forum { // A tie is resolved in favor of the validation pool. // This is especially important so that the DAO's first pool can pass, // when no reputation has yet been minted. - votePasses = stakedFor * pool.params.winRatio[1] >= (stakedFor + stakedAgainst) * pool.params.winRatio[0]; diff --git a/ethereum/test/Forum.js b/ethereum/test/Forum.js index 67e01d7..94b74f4 100644 --- a/ethereum/test/Forum.js +++ b/ethereum/test/Forum.js @@ -185,6 +185,20 @@ describe('Forum', () => { expect(await dao.balanceOf(account3)).to.equal(200); }); + it('should be able to cite a post that has not (yet) been added', async () => { + await addPost(account1, 'content-id', []); + await addPost(account2, 'second-content-id', [ + { weightPercent: 10, targetPostId: 'content-id' }, + { weightPercent: 10, targetPostId: 'nonexistent-content-id' }, + ]); + await initiateValidationPool({ postId: 'second-content-id' }); + const pool = await dao.validationPools(0); + expect(pool.postId).to.equal('second-content-id'); + await dao.evaluateOutcome(0); + expect(await dao.balanceOf(account1)).to.equal(10); + expect(await dao.balanceOf(account2)).to.equal(90); + }); + it('forum reputation rewards are shared with validation pool policing rewards', async () => { await addPost(account1, 'content-id', []); await initiateValidationPool({ postId: 'content-id' });