-
Notifications
You must be signed in to change notification settings - Fork 128
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
fixed vote options serialization #560
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { Keypair } from '@solana/web3.js'; | ||
import { GoverningTokenConfigAccountArgs, GoverningTokenType } from '../../src'; | ||
import { BenchBuilder } from '../tools/builders'; | ||
|
||
test('setRealmConfig', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests should be in V2.V3 because they should work for spl-gov V2 and V3 and there is no V4 yet There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the difference between this test and the one which already exists? |
||
// Arrange | ||
const realm = await BenchBuilder.withConnection() | ||
.then(b => b.withWallet()) | ||
.then(b => b.withRealm()) | ||
.then(b => b.sendTx()); | ||
|
||
const communityTokenConfig = new GoverningTokenConfigAccountArgs({ | ||
voterWeightAddin: Keypair.generate().publicKey, | ||
maxVoterWeightAddin: Keypair.generate().publicKey, | ||
tokenType: GoverningTokenType.Liquid, | ||
}); | ||
|
||
// Act | ||
await realm.setRealmConfig(communityTokenConfig); | ||
|
||
// Assert | ||
const realmConfig = await realm.getRealmConfig(); | ||
|
||
expect(realmConfig.account.realm).toEqual(realm.realmPk); | ||
|
||
// communityTokenConfig | ||
expect(realmConfig.account.communityTokenConfig.tokenType).toEqual( | ||
communityTokenConfig.tokenType, | ||
); | ||
expect(realmConfig.account.communityTokenConfig.voterWeightAddin).toEqual( | ||
communityTokenConfig.voterWeightAddin, | ||
); | ||
expect(realmConfig.account.communityTokenConfig.maxVoterWeightAddin).toEqual( | ||
communityTokenConfig.maxVoterWeightAddin, | ||
); | ||
|
||
// councilTokenConfig | ||
expect(realmConfig.account.councilTokenConfig.tokenType).toEqual( | ||
GoverningTokenType.Liquid, | ||
); | ||
expect(realmConfig.account.councilTokenConfig.voterWeightAddin).toEqual( | ||
undefined, | ||
); | ||
expect(realmConfig.account.councilTokenConfig.maxVoterWeightAddin).toEqual( | ||
undefined, | ||
); | ||
}); | ||
|
||
test('createGovernance', async () => { | ||
// Arrange | ||
const realm = await BenchBuilder.withConnection() | ||
.then(b => b.withWallet()) | ||
.then(b => b.withRealm()) | ||
.then(b => b.withCommunityMember()) | ||
.then(b => b.sendTx()); | ||
|
||
// Act | ||
const governancePk = await realm.createGovernance(); | ||
|
||
// // Assert | ||
const governance = await realm.getGovernance(governancePk); | ||
|
||
expect(governance.account.realm).toEqual(realm.realmPk); | ||
}); | ||
|
||
test('createProposal', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make the test name more specific |
||
// Arrange | ||
const realm = await BenchBuilder.withConnection() | ||
.then(b => b.withWallet()) | ||
.then(b => b.withRealm()) | ||
.then(b => b.withCommunityMember()) | ||
.then(b => b.withGovernance()) | ||
.then(b => b.sendTx()); | ||
|
||
// Act | ||
const proposalPk = await realm.createProposal('proposal 1', true); | ||
|
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the struct to match the program struct https://github.com/solana-labs/solana-program-library/blob/1892778b9ddb46545f0e7982065889ee7aec1bac/governance/program/src/state/proposal.rs#L89