add contract support for citing posts that have not (yet) been added
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 36s
Details
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 36s
Details
This commit is contained in:
parent
0eee2ef7ae
commit
ece57c9706
|
@ -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) {
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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' });
|
||||
|
|
Loading…
Reference in New Issue