This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 129
fixed vote options serialization #560
Open
yamijuan
wants to merge
2
commits into
solana-labs:main
Choose a base branch
from
yamijuan:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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