support incineration
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 45s Details

This commit is contained in:
Ladd Hoffman 2024-04-12 18:07:38 -05:00
parent d8d0122e31
commit a49b42858a
2 changed files with 22 additions and 0 deletions

View File

@ -75,6 +75,15 @@ contract Forum is Reputation {
uint depth
) internal returns (int outboundAmount) {
outboundAmount = (amount * citation.weightPercent) / 100;
if (citation.targetPostIndex == type(uint256).max) {
// Incineration
require(
outboundAmount >= 0,
"Leaching from incinerator is forbidden"
);
_burn(address(this), uint(outboundAmount));
return outboundAmount;
}
int balanceToOutbound = _edgeBalances[postIndex][
citation.targetPostIndex
];

View File

@ -215,5 +215,18 @@ describe('Forum', () => {
expect(posts[2].reputation).to.equal(0);
expect(posts[3].reputation).to.equal(0);
});
it('should be able to incinerate reputation', async () => {
await dao.addPost(account1, 'content-id-1', [
{
weightPercent: 50,
targetPostIndex: ethers.MaxUint256,
},
]);
await initiateValidationPool({ postIndex: 0 });
expect(await dao.totalSupply()).to.equal(100);
await dao.evaluateOutcome(0);
expect((await dao.posts(0)).reputation).to.equal(50);
});
});
});