Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added paranet incentives pool storage tests #355

Merged
Merged
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 175 additions & 0 deletions test/integration/Paranet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
IdentityStorage,
HubLib,
ParanetLib,
} from '../../typechain';

Check failure on line 28 in test/integration/Paranet.test.ts

View workflow job for this annotation

GitHub Actions / lint

Unable to resolve path to module '../../typechain'
import { ACCESS_POLICIES } from '../helpers/constants';
import {
createProfilesAndKC,
Expand Down Expand Up @@ -900,6 +900,181 @@
expect(await incentivesPoolStorage.paranetId()).to.equal(paranetId);
});

it('Access control for incentives pool storage', async () => {
const kcCreator = getDefaultKCCreator(accounts);
const publishingNode = getDefaultPublishingNode(accounts);
const receivingNodes = getDefaultReceivingNodes(accounts);

const {
paranetKCStorageContract,
paranetKCTokenId,
paranetKATokenId,
paranetOwner,
} = await setupParanet(kcCreator, publishingNode, receivingNodes, {
Paranet,
Profile,
Token,
KnowledgeCollection,
KnowledgeCollectionStorage,
});

const tx = await ParanetIncentivesPoolFactory.connect(
paranetOwner,
).deployIncentivesPool(
paranetKCStorageContract,
paranetKCTokenId,
paranetKATokenId,
ethers.parseUnits('1', 12), // 1 NEURO per 1 TRAC
1000, // 10% operator
2000, // 20% voters
'Pool',
await Token.getAddress(),
);

const receipt = await tx.wait();
const event = receipt!.logs.find(
(log) =>
log.topics[0] ===
ParanetIncentivesPoolFactory.interface.getEvent(
'ParanetIncentivesPoolDeployed',
).topicHash,
) as EventLog;

const poolStorage = await hre.ethers.getContractAt(
'ParanetIncentivesPoolStorage',
event?.args[3],
);

const notIncentivesPool = accounts[1];

await expect(
poolStorage
.connect(notIncentivesPool)
.addMinerClaimedReward(
accounts[0].address,
ethers.parseUnits('100', 12),
)

Check failure on line 956 in test/integration/Paranet.test.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
).to.be.revertedWith('Caller is not incentives pool contract');

await expect(

Check failure on line 959 in test/integration/Paranet.test.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `·`
poolStorage
.connect(notIncentivesPool)
.addMinerClaimedRewardProfile(
accounts[0].address,
ethers.parseUnits('100', 12),
)

Check failure on line 965 in test/integration/Paranet.test.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
).to.be.revertedWith('Caller is not incentives pool contract');

await expect(
poolStorage
.connect(notIncentivesPool)
.addClaimedOperatorReward(
accounts[0].address,
ethers.parseUnits('100', 12),
)
).to.be.revertedWith('Caller is not incentives pool contract');

await expect(
poolStorage
.connect(notIncentivesPool)
.addOperatorClaimedRewardsProfile(
accounts[0].address,
ethers.parseUnits('100', 12),
)
).to.be.revertedWith('Caller is not incentives pool contract');

await expect(
poolStorage
.connect(notIncentivesPool)
.addVoterclaimedToken(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be addVoterClaimedToken

accounts[0].address,
ethers.parseUnits('100', 12),
)
).to.be.revertedWith('Caller is not incentives pool contract');

await expect(
poolStorage
.connect(notIncentivesPool)
.addTotalMinersclaimedToken(
ethers.parseUnits('100', 12),
)
).to.be.revertedWith('Caller is not incentives pool contract');

await expect(
poolStorage
.connect(notIncentivesPool)
.addTotalOperatorsclaimedToken(
ethers.parseUnits('100', 12),
)
).to.be.revertedWith('Caller is not incentives pool contract');

await expect(
poolStorage
.connect(notIncentivesPool)
.addTotalVotersclaimedToken(
ethers.parseUnits('100', 12),
)
).to.be.revertedWith('Caller is not incentives pool contract');

await expect(
poolStorage
.connect(notIncentivesPool)
.transferReward(
accounts[0].address,
ethers.parseUnits('100', 12),
)
).to.be.revertedWith('Caller is not incentives pool contract');

await expect(
poolStorage
.connect(notIncentivesPool)
.setTotalMinersclaimedToken(
ethers.parseUnits('100', 12),
)
).to.be.revertedWith('Caller is not incentives pool contract');

await expect(
poolStorage
.connect(notIncentivesPool)
.setTotalVotersclaimedToken(
ethers.parseUnits('100', 12),
)
).to.be.revertedWith('Caller is not incentives pool contract');

await expect(
poolStorage
.connect(notIncentivesPool)
.setTotalOperatorsclaimedToken(
ethers.parseUnits('100', 12),
)
).to.be.revertedWith('Caller is not incentives pool contract');

await expect(
poolStorage
.connect(notIncentivesPool)
.decrementTotalMinersclaimedToken(
ethers.parseUnits('100', 12),
)
).to.be.revertedWith('Caller is not incentives pool contract');

await expect(
poolStorage
.connect(notIncentivesPool)
.decrementTotalVotersclaimedToken(
ethers.parseUnits('100', 12),
)
).to.be.revertedWith('Caller is not incentives pool contract');

await expect(
poolStorage
.connect(notIncentivesPool)
.decrementTotalOperatorsclaimedToken(
ethers.parseUnits('100', 12),
)
).to.be.revertedWith('Caller is not incentives pool contract');

});

it('Should handle multiple incentives pools for same paranet', async () => {
// 1. Setup paranet first
const kcCreator = getDefaultKCCreator(accounts);
Expand Down
Loading