Skip to content

Commit

Permalink
fix(pagination): correct initial page number for list_neurons paginat…
Browse files Browse the repository at this point in the history
…ion (#843)

# Motivation

A bug was introduced in #833 in this
[commit](45eb69d#diff-f4f0835b56118edf98f5b690eb524de8bd8738c8d742c69c3c2cd516d55e9857R174)
as the initial page should be `0n`, and not `1n`, as shown
[here](https://github.com/dfinity/ic/blob/a34724ef3feef15510ab055b4f5e4aa961ce9e86/rs/nns/governance/src/governance.rs#L2085).
The bug was found through [this failing e2e
pipeline](dfinity/nns-dapp#6419).

# Changes

- Changed the initially requested page from `1n` to `0n`.

# Tests

- Update expectations for the requested page.
- Manually tested in
[devenv](https://qsgjb-riaaa-aaaaa-aaaga-cai.yhabib-ingress.devenv.dfinity.network/neurons/?u=qsgjb-riaaa-aaaaa-aaaga-cai)
- Tested against [e2e
test](dfinity/nns-dapp#6428) from nns-dapp

# Todos

- [ ] Add entry to changelog (if necessary).
  • Loading branch information
yhabib authored Feb 14, 2025
1 parent 6ab5ec6 commit fcbba69
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions packages/nns/src/governance.canister.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ describe("GovernanceCanister", () => {
include_empty_neurons_readable_by_caller: [true],
include_public_neurons_in_full_neurons: [true],
neuron_subaccounts: [],
page_number: [1n],
page_number: [0n],
page_size: [500n],
});
expect(neurons.length).toBe(1);
Expand Down Expand Up @@ -502,7 +502,7 @@ describe("GovernanceCanister", () => {
include_empty_neurons_readable_by_caller: [true],
include_public_neurons_in_full_neurons: [true],
neuron_subaccounts: [],
page_number: [1n],
page_number: [0n],
page_size: [500n],
});

Expand Down Expand Up @@ -543,7 +543,7 @@ describe("GovernanceCanister", () => {
include_empty_neurons_readable_by_caller: [false],
include_public_neurons_in_full_neurons: [],
neuron_subaccounts: [],
page_number: [1n],
page_number: [0n],
page_size: [500n],
});
expect(service.list_neurons).toBeCalledTimes(1);
Expand All @@ -570,7 +570,7 @@ describe("GovernanceCanister", () => {
include_empty_neurons_readable_by_caller: [],
include_public_neurons_in_full_neurons: [false],
neuron_subaccounts: [],
page_number: [1n],
page_number: [0n],
page_size: [500n],
});
expect(service.list_neurons).toBeCalledTimes(1);
Expand Down Expand Up @@ -601,7 +601,7 @@ describe("GovernanceCanister", () => {
include_neurons_readable_by_caller: true,
include_empty_neurons_readable_by_caller: [true],
include_public_neurons_in_full_neurons: [true],
page_number: [1n],
page_number: [0n],
page_size: [500n],
neuron_subaccounts: [
[
Expand Down Expand Up @@ -665,7 +665,7 @@ describe("GovernanceCanister", () => {
include_neurons_readable_by_caller: true,
include_empty_neurons_readable_by_caller: [],
include_public_neurons_in_full_neurons: [],
page_number: [1n],
page_number: [0n],
page_size: [500n],
neuron_subaccounts: [],
});
Expand Down
2 changes: 1 addition & 1 deletion packages/nns/src/governance.canister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class GovernanceCanister {
includeEmptyNeurons,
includePublicNeurons,
neuronSubaccounts,
pageNumber: 1n,
pageNumber: 0n,
});
const { neurons: firstPageNeurons, totalPages } = firstPageResult;

Expand Down

0 comments on commit fcbba69

Please sign in to comment.