Skip to content

Commit

Permalink
Update signature
Browse files Browse the repository at this point in the history
  • Loading branch information
max-dfinity committed Jan 29, 2025
1 parent 16a14b2 commit 3411732
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ pub mod nns {
include_public_neurons_in_full_neurons: None,
page_number: None,
page_size: None,
neuron_subaccounts: vec![],
neuron_subaccounts: None,
})
.unwrap(),
)
Expand Down
2 changes: 1 addition & 1 deletion rs/nns/governance/api/src/ic_nns_governance.pb.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3536,7 +3536,7 @@ pub struct ListNeurons {
/// A list of neurons by subaccounts to return in the response. If the neurons are not
/// found by subaccount, no error is returned, but the page will still be returned.
#[prost(message, repeated, tag = "7")]
pub neuron_subaccounts: Vec<list_neurons::NeuronSubaccount>,
pub neuron_subaccounts: Option<Vec<list_neurons::NeuronSubaccount>>,
}

pub mod list_neurons {
Expand Down
2 changes: 1 addition & 1 deletion rs/nns/governance/canister/governance.did
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ type ListNeurons = record {
include_neurons_readable_by_caller : bool;
page_number: opt nat64;
page_size: opt nat64;
neuron_subaccounts: vec NeuronSubaccount;
neuron_subaccounts: opt vec NeuronSubaccount;
};

type NeuronSubaccount = record {
Expand Down
2 changes: 1 addition & 1 deletion rs/nns/governance/canister/governance_test.did
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ type ListNeurons = record {
include_neurons_readable_by_caller : bool;
page_number: opt nat64;
page_size: opt nat64;
neuron_subaccounts: vec NeuronSubaccount;
neuron_subaccounts: opt vec NeuronSubaccount;
};

type NeuronSubaccount = record {
Expand Down
1 change: 1 addition & 0 deletions rs/nns/governance/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2316,6 +2316,7 @@ impl Governance {
};

let mut neurons_by_subaccount: BTreeSet<NeuronId> = neuron_subaccounts
.unwrap_or_default()
.iter()
.flat_map(|neuron_subaccount| {
Self::bytes_to_subaccount(&neuron_subaccount.subaccount)
Expand Down
4 changes: 2 additions & 2 deletions rs/nns/governance/src/governance/benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ fn list_neurons_by_subaccount_benchmark() -> BenchResult {
include_public_neurons_in_full_neurons: None,
page_number: None,
page_size: None,
neuron_subaccounts: subaccounts,
neuron_subaccounts: Some(subaccounts),
};

bench_fn(|| {
Expand Down Expand Up @@ -619,7 +619,7 @@ fn list_neurons_benchmark() -> BenchResult {
include_public_neurons_in_full_neurons: None,
page_number: None,
page_size: None,
neuron_subaccounts: vec![],
neuron_subaccounts: None,
};

bench_fn(|| {
Expand Down
30 changes: 17 additions & 13 deletions rs/nns/governance/src/governance/tests/list_neurons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn test_list_neurons_with_paging() {
include_public_neurons_in_full_neurons: None,
page_number: None,
page_size: None,
neuron_subaccounts: vec![],
neuron_subaccounts: Some(vec![]),
};

let response_with_no_page_number = governance.list_neurons(&request, user_id);
Expand All @@ -70,7 +70,7 @@ fn test_list_neurons_with_paging() {
include_public_neurons_in_full_neurons: None,
page_number: Some(1),
page_size: None,
neuron_subaccounts: vec![],
neuron_subaccounts: None,
},
user_id,
);
Expand All @@ -87,7 +87,7 @@ fn test_list_neurons_with_paging() {
include_public_neurons_in_full_neurons: None,
page_number: Some(0),
page_size: Some(501),
neuron_subaccounts: vec![],
neuron_subaccounts: None,
},
user_id,
);
Expand Down Expand Up @@ -139,11 +139,13 @@ fn test_list_neurons_by_subaccounts_and_ids() {
include_public_neurons_in_full_neurons: None,
page_number: None,
page_size: None,
neuron_subaccounts: (501..1000)
.map(|id| NeuronSubaccount {
subaccount: crate::test_utils::test_subaccount_for_neuron_id(id),
})
.collect(),
neuron_subaccounts: Some(
(501..1000)
.map(|id| NeuronSubaccount {
subaccount: crate::test_utils::test_subaccount_for_neuron_id(id),
})
.collect(),
),
};

let response_1 = governance.list_neurons(&request, user_id);
Expand All @@ -158,11 +160,13 @@ fn test_list_neurons_by_subaccounts_and_ids() {
include_public_neurons_in_full_neurons: None,
page_number: Some(1),
page_size: None,
neuron_subaccounts: (501..1000)
.map(|id| NeuronSubaccount {
subaccount: crate::test_utils::test_subaccount_for_neuron_id(id),
})
.collect(),
neuron_subaccounts: Some(
(501..1000)
.map(|id| NeuronSubaccount {
subaccount: crate::test_utils::test_subaccount_for_neuron_id(id),
})
.collect(),
),
},
user_id,
);
Expand Down
4 changes: 2 additions & 2 deletions rs/nns/governance/tests/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10807,7 +10807,7 @@ fn test_include_public_neurons_in_full_neurons() {

page_number: None,
page_size: None,
neuron_subaccounts: vec![],
neuron_subaccounts: None,
},
caller,
);
Expand Down Expand Up @@ -14889,7 +14889,7 @@ fn test_neuron_info_private_enforcement() {
include_public_neurons_in_full_neurons: None,
page_number: None,
page_size: None,
neuron_subaccounts: vec![],
neuron_subaccounts: None,
},
requester,
)
Expand Down
12 changes: 6 additions & 6 deletions rs/nns/integration_tests/src/governance_neurons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ fn test_list_neurons() {
include_public_neurons_in_full_neurons: None,
page_number: None,
page_size: None,
neuron_subaccounts: vec![],
neuron_subaccounts: None,
},
);
assert_eq!(list_neurons_response.neuron_infos.len(), 3);
Expand All @@ -572,7 +572,7 @@ fn test_list_neurons() {
include_public_neurons_in_full_neurons: None,
page_number: None,
page_size: None,
neuron_subaccounts: vec![],
neuron_subaccounts: None,
},
);
assert_eq!(list_neurons_response.neuron_infos.len(), 2);
Expand All @@ -589,7 +589,7 @@ fn test_list_neurons() {
include_public_neurons_in_full_neurons: None,
page_number: None,
page_size: None,
neuron_subaccounts: vec![],
neuron_subaccounts: Some(vec![]), // Should be equivalent to None
},
);
assert_eq!(list_neurons_response.neuron_infos.len(), 1);
Expand All @@ -607,7 +607,7 @@ fn test_list_neurons() {
include_public_neurons_in_full_neurons: None,
page_number: None,
page_size: None,
neuron_subaccounts: vec![],
neuron_subaccounts: Some(vec![]),
},
);
assert_eq!(list_neurons_response.neuron_infos.len(), 3);
Expand All @@ -627,9 +627,9 @@ fn test_list_neurons() {
include_public_neurons_in_full_neurons: None,
page_number: None,
page_size: None,
neuron_subaccounts: vec![NeuronSubaccount {
neuron_subaccounts: Some(vec![NeuronSubaccount {
subaccount: subaccount.to_vec(),
}],
}]),
},
);
assert_eq!(list_neurons_response.neuron_infos.len(), 3);
Expand Down
6 changes: 3 additions & 3 deletions rs/nns/integration_tests/src/neuron_voting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,15 +405,15 @@ fn test_voting_can_span_multiple_rounds() {
include_public_neurons_in_full_neurons: None,
page_number: None,
page_size: None,
neuron_subaccounts: vec![],
neuron_subaccounts: Some(vec![]),
},
);

assert_eq!(listed_neurons.full_neurons.len(), 999);

// No recent ballots, bc ran out of instructions, should wait til next round.
for neuron in listed_neurons.full_neurons {
assert_eq!(neuron.recent_ballots, vec![], "Neuron: {:?}", neuron);
assert_eq!(neuron.recent_ballots, Some(vec![]), "Neuron: {:?}", neuron);
}

// The timer should run, which should record all the ballots.
Expand All @@ -433,7 +433,7 @@ fn test_voting_can_span_multiple_rounds() {
include_public_neurons_in_full_neurons: None,
page_number: None,
page_size: None,
neuron_subaccounts: vec![],
neuron_subaccounts: Some(vec![]),
},
);

Expand Down
2 changes: 1 addition & 1 deletion rs/nns/test_utils/src/state_test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ pub fn list_neurons_by_principal(
include_public_neurons_in_full_neurons: None,
page_number: None,
page_size: None,
neuron_subaccounts: vec![],
neuron_subaccounts: None,
},
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ fn handle_list_neurons(
include_public_neurons_in_full_neurons: None,
page_number: None,
page_size: None,
neuron_subaccounts: vec![],
neuron_subaccounts: None,
};
let update = HttpCanisterUpdate {
canister_id: Blob(ic_nns_constants::GOVERNANCE_CANISTER_ID.get().to_vec()),
Expand Down
2 changes: 1 addition & 1 deletion rs/rosetta-api/icp/tests/system_tests/common/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub async fn list_neurons(agent: &Agent) -> ListNeuronsResponse {
include_public_neurons_in_full_neurons: None,
page_number: None,
page_size: None,
neuron_subaccounts: vec![]
neuron_subaccounts: None
})
.unwrap()
)
Expand Down
2 changes: 1 addition & 1 deletion rs/tests/driver/src/canister_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ impl ListNnsNeuronsRequest {
include_public_neurons_in_full_neurons: None,
page_number: None,
page_size: None,
neuron_subaccounts: vec![],
neuron_subaccounts: None,
},
}
}
Expand Down

0 comments on commit 3411732

Please sign in to comment.