keep track of post reputations
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 41s Details

This commit is contained in:
Ladd Hoffman 2024-04-10 17:40:17 -05:00
parent 842c1d2e81
commit b12759fac8
2 changed files with 8 additions and 0 deletions

View File

@ -15,6 +15,7 @@ struct Post {
address author;
string contentId;
Citation[] citations;
uint reputation;
}
contract Forum is Reputation {
@ -73,8 +74,10 @@ contract Forum is Reputation {
int remaining = amount - totalOutboundAmount;
if (remaining > 0) {
_update(address(this), post.author, uint(remaining));
post.reputation += uint(remaining);
} else {
_update(post.author, address(this), uint(-remaining));
post.reputation -= uint(-remaining);
}
}
}

View File

@ -77,10 +77,13 @@ describe('Forum', () => {
it('should be able to leach reputation via citations', async () => {
await dao.addPost(account1, 'content-id', []);
expect((await dao.posts(0)).reputation).to.equal(0);
await initiateValidationPool({ postIndex: 0 });
await dao.evaluateOutcome(0);
expect(await dao.balanceOf(account1)).to.equal(100);
expect((await dao.posts(0)).reputation).to.equal(100);
await dao.addPost(account2, 'second-content-id', [{ weightPercent: -50, targetPostIndex: 0 }]);
expect((await dao.posts(1)).reputation).to.equal(0);
await initiateValidationPool({ postIndex: 1 });
const pool = await dao.validationPools(1);
expect(pool.postIndex).to.equal(1);
@ -88,6 +91,8 @@ describe('Forum', () => {
await dao.evaluateOutcome(1);
expect(await dao.balanceOf(account1)).to.equal(50);
expect(await dao.balanceOf(account2)).to.equal(150);
expect((await dao.posts(0)).reputation).to.equal(50);
expect((await dao.posts(1)).reputation).to.equal(150);
});
it('should be able to redistribute power via citations', async () => {