Skip to content

Commit

Permalink
Add a regression test to make sure voting strategies are unique
Browse files Browse the repository at this point in the history
  • Loading branch information
pscott committed Aug 24, 2022
1 parent f9ccd71 commit cfb617b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/starknet/Space.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { StarknetContract, Account } from 'hardhat/types';
import { utils } from '@snapshot-labs/sx';
import { vanillaSetup } from '../shared/setup';
import { PROPOSE_SELECTOR, VOTE_SELECTOR } from '../shared/constants';
import { getProposeCalldata } from '@snapshot-labs/sx/dist/utils/encoding';

describe('Space Testing', () => {
// Contracts
Expand Down Expand Up @@ -118,6 +119,35 @@ describe('Space Testing', () => {
}
}).timeout(6000000);

it('Fails if the same voting strategy is used multiple times', async () => {
// -- Creates the proposal --
{
const duplicateVotingStrategies = [
vanillaVotingStrategy.address,
vanillaAuthenticator.address,
vanillaVotingStrategy.address,
];
const duplicateCalldata = utils.encoding.getProposeCalldata(
proposerEthAddress,
metadataUri,
executionStrategy,
duplicateVotingStrategies,
userVotingParamsAll1,
executionParams
);

try {
await vanillaAuthenticator.invoke('authenticate', {
target: spaceAddress,
function_selector: PROPOSE_SELECTOR,
calldata: duplicateCalldata,
});
} catch (error: any) {
expect(error.message).to.contain('Duplicate entry found');
}
}
}).timeout(6000000);

it('Reverts when querying an invalid proposal id', async () => {
try {
await space.call('get_proposal_info', {
Expand Down

0 comments on commit cfb617b

Please sign in to comment.