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

Proposal based votable state #725

Merged
merged 17 commits into from
Oct 2, 2024
Merged
Changes from 1 commit
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
49 changes: 32 additions & 17 deletions packages/nns/src/utils/neurons.utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe("neurons-utils", () => {
} as unknown as NeuronInfo,
];

const eligibleNeuronsDate: NeuronInfo[] = [
const eligibleNeuronsData: NeuronInfo[] = [
{
createdTimestampSeconds: proposalTimestampSeconds - BigInt(1),
neuronId: proposalNeuronId,
Expand Down Expand Up @@ -101,7 +101,7 @@ describe("neurons-utils", () => {
proposal,
neurons: [
{
...eligibleNeuronsDate[0],
...eligibleNeuronsData[0],
recentBallots: [
{
proposalId,
Expand All @@ -120,15 +120,25 @@ describe("neurons-utils", () => {
...proposal,
ballots: [
{
neuronId: eligibleNeuronsDate[0].neuronId,
neuronId: eligibleNeuronsData[0].neuronId,
vote: Vote.Unspecified,
votingPower: BigInt(1),
},
{
neuronId: eligibleNeuronsData[0].neuronId,
vote: Vote.Yes,
votingPower: BigInt(1),
},
{
neuronId: eligibleNeuronsData[0].neuronId,
vote: Vote.No,
votingPower: BigInt(1),
},
],
},
neurons: [
{
...eligibleNeuronsDate[0],
...eligibleNeuronsData[0],
},
],
});
mstrasinskis marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -141,15 +151,20 @@ describe("neurons-utils", () => {
...proposal,
ballots: [
{
neuronId: eligibleNeuronsDate[0].neuronId,
neuronId: eligibleNeuronsData[0].neuronId,
vote: Vote.Unspecified,
votingPower: BigInt(1),
},
{
neuronId: eligibleNeuronsData[1].neuronId,
vote: Vote.No,
votingPower: BigInt(1),
},
],
},
neurons: [
{
...eligibleNeuronsDate[0],
...eligibleNeuronsData[0],
},
],
});
mstrasinskis marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -162,25 +177,25 @@ describe("neurons-utils", () => {
...proposal,
ballots: [
{
neuronId: eligibleNeuronsDate[0].neuronId,
neuronId: eligibleNeuronsData[0].neuronId,
vote: Vote.Unspecified,
votingPower: BigInt(0),
},
{
neuronId: eligibleNeuronsDate[1].neuronId,
vote: Vote.Unspecified,
neuronId: eligibleNeuronsData[1].neuronId,
vote: Vote.Yes,
votingPower: BigInt(1),
},
{
neuronId: eligibleNeuronsDate[2].neuronId,
neuronId: eligibleNeuronsData[2].neuronId,
vote: Vote.Unspecified,
votingPower: BigInt(0),
},
],
},
neurons: eligibleNeuronsDate,
neurons: eligibleNeuronsData,
});
expect(votable.length).toEqual(3);
expect(votable.length).toEqual(2);
mstrasinskis marked this conversation as resolved.
Show resolved Hide resolved
});

it("should not have voted neurons because votable", () => {
Expand All @@ -189,15 +204,15 @@ describe("neurons-utils", () => {
...proposal,
ballots: [
{
neuronId: eligibleNeuronsDate[0].neuronId,
neuronId: eligibleNeuronsData[0].neuronId,
vote: Vote.Unspecified,
votingPower: BigInt(1),
},
],
},
neurons: [
{
...eligibleNeuronsDate[0],
...eligibleNeuronsData[0],
},
],
});
Expand All @@ -210,15 +225,15 @@ describe("neurons-utils", () => {
...proposal,
ballots: [
{
neuronId: eligibleNeuronsDate[0].neuronId,
neuronId: eligibleNeuronsData[0].neuronId,
vote: Vote.Unspecified,
votingPower: BigInt(1),
},
],
},
neurons: [
{
...eligibleNeuronsDate[0],
...eligibleNeuronsData[0],
},
],
});
Expand All @@ -230,7 +245,7 @@ describe("neurons-utils", () => {
proposal,
neurons: [
{
...eligibleNeuronsDate[0],
...eligibleNeuronsData[0],
recentBallots: [
{
proposalId,
Expand Down