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

No active field for non-votable neurons #6375

Merged
merged 6 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
isNeuronMissingReward,
secondsUntilMissingReward,
isNeuronMissingRewardsSoon,
hasEnoughDissolveDelayToVote,
} from "$lib/utils/neuron.utils";
import {
IconCheckCircleFill,
Expand Down Expand Up @@ -96,7 +97,7 @@
};
</script>

{#if nonNullish($startReducingVotingPowerAfterSecondsStore) && nonNullish($clearFollowingAfterSecondsStore)}
{#if hasEnoughDissolveDelayToVote(neuron) && nonNullish($startReducingVotingPowerAfterSecondsStore) && nonNullish($clearFollowingAfterSecondsStore)}
<CommonItemAction
testId="nns-neuron-reward-status-action-component"
tooltipText={replacePlaceholders($i18n.missing_rewards.description, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ describe("NnsNeuronRewardStatusAction", () => {
});

it("should render active neuron state", async () => {
const testNeuron = {
const testNeuron: NeuronInfo = {
...mockNeuron,
dissolveDelaySeconds: BigInt(SECONDS_IN_HALF_YEAR),
fullNeuron: {
...mockFullNeuron,
votingPowerRefreshedTimestampSeconds: BigInt(nowInSeconds()),
Expand All @@ -54,9 +55,24 @@ describe("NnsNeuronRewardStatusAction", () => {
expect(await po.getFollowNeuronsButtonPo().isPresent()).toBe(false);
});

it("should not render active neuron state when neuron dissolve delay is too low for voting", async () => {
const testNeuron: NeuronInfo = {
...mockNeuron,
dissolveDelaySeconds: 0n,
fullNeuron: {
...mockFullNeuron,
votingPowerRefreshedTimestampSeconds: BigInt(nowInSeconds()),
},
};
const po = renderComponent(testNeuron);

expect(await po.isPresent()).toBe(false);
});

it("should not render active neuron state w/o voting power economics params", async () => {
const testNeuron = {
const testNeuron: NeuronInfo = {
...mockNeuron,
dissolveDelaySeconds: BigInt(SECONDS_IN_HALF_YEAR),
fullNeuron: {
...mockFullNeuron,
votingPowerRefreshedTimestampSeconds: BigInt(nowInSeconds()),
Expand All @@ -70,8 +86,9 @@ describe("NnsNeuronRewardStatusAction", () => {

it("should render losing soon neuron state", async () => {
const tenDays = 10;
const testNeuron = {
const testNeuron: NeuronInfo = {
...mockNeuron,
dissolveDelaySeconds: BigInt(SECONDS_IN_HALF_YEAR),
fullNeuron: {
...mockFullNeuron,
votingPowerRefreshedTimestampSeconds: BigInt(
Expand All @@ -90,8 +107,9 @@ describe("NnsNeuronRewardStatusAction", () => {
});

it("should render inactive neuron reward state", async () => {
const testNeuron = {
const testNeuron: NeuronInfo = {
...mockNeuron,
dissolveDelaySeconds: BigInt(SECONDS_IN_HALF_YEAR),
fullNeuron: {
...mockFullNeuron,
votingPowerRefreshedTimestampSeconds: BigInt(
Expand All @@ -110,8 +128,9 @@ describe("NnsNeuronRewardStatusAction", () => {
});

it("should render inactive/reset following neuron reward state", async () => {
const testNeuron = {
const testNeuron: NeuronInfo = {
...mockNeuron,
dissolveDelaySeconds: BigInt(SECONDS_IN_HALF_YEAR),
fullNeuron: {
...mockFullNeuron,
votingPowerRefreshedTimestampSeconds: BigInt(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import NnsNeuronVotingPowerSection from "$lib/components/neuron-detail/NnsNeuronVotingPowerSection.svelte";
import { SECONDS_IN_HALF_YEAR } from "$lib/constants/constants";
import { NNS_MINIMUM_DISSOLVE_DELAY_TO_VOTE } from "$lib/constants/neurons.constants";
import { overrideFeatureFlagsStore } from "$lib/stores/feature-flags.store";
import { networkEconomicsStore } from "$lib/stores/network-economics.store";
Expand Down Expand Up @@ -140,7 +141,10 @@ describe("NnsStakeItemAction", () => {
});

it("should render item actions", async () => {
const po = renderComponent(mockNeuron);
const po = renderComponent({
...mockNeuron,
dissolveDelaySeconds: BigInt(SECONDS_IN_HALF_YEAR),
});

expect(await po.hasStakeItemAction()).toBe(true);
expect(await po.hasNeuronStateItemAction()).toBe(true);
Expand All @@ -156,7 +160,10 @@ describe("NnsStakeItemAction", () => {
parameters: mockNetworkEconomics,
certified: true,
});
const po = renderComponent(mockNeuron);
const po = renderComponent({
...mockNeuron,
dissolveDelaySeconds: BigInt(SECONDS_IN_HALF_YEAR),
});

expect(await po.getNnsNeuronRewardStatusActionPo().isPresent()).toBe(true);
});
Expand All @@ -166,7 +173,10 @@ describe("NnsStakeItemAction", () => {
"ENABLE_PERIODIC_FOLLOWING_CONFIRMATION",
false
);
const po = renderComponent(mockNeuron);
const po = renderComponent({
...mockNeuron,
dissolveDelaySeconds: BigInt(SECONDS_IN_HALF_YEAR),
});

expect(await po.getNnsNeuronRewardStatusActionPo().isPresent()).toBe(false);
});
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/tests/lib/pages/NnsNeuronDetail.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ describe("NeuronDetail", () => {
);
const testNeuron = fakeGovernanceApi.addNeuronWith({
neuronId,
dissolveDelaySeconds: BigInt(SECONDS_IN_HALF_YEAR),
votingPowerRefreshedTimestampSeconds:
nowInSeconds() - SECONDS_IN_HALF_YEAR - SECONDS_IN_DAY,
controller: mockIdentity.getPrincipal().toText(),
dissolveDelaySeconds,
});

vi.spyOn(governanceApi, "queryNeurons").mockResolvedValue([testNeuron]);
Expand Down
Loading