Skip to content

Commit

Permalink
Fix more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
max-dfinity committed Oct 24, 2024
1 parent 3e5b799 commit cb072fa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions rs/nns/governance/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1907,8 +1907,8 @@ impl Governance {
)
}

pub fn clone_proto(&self) -> GovernanceProto {
let neurons = self.neuron_store.clone_neurons();
pub fn __get_state_for_test(&self) -> GovernanceProto {
let neurons = self.neuron_store.__get_neurons_for_tests();
let heap_topic_followee_index = self.neuron_store.clone_topic_followee_index();
let heap_governance_proto = self.heap_data.clone();
let rng_seed = self.env.get_rng_seed();
Expand Down
16 changes: 13 additions & 3 deletions rs/nns/governance/src/neuron_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,21 @@ impl NeuronStore {

/// Clones all the neurons. This is only used for testing.
/// TODO(NNS-2474) clean it up after NNSState stop using GovernanceProto.
pub fn clone_neurons(&self) -> BTreeMap<u64, NeuronProto> {
self.heap_neurons
pub fn __get_neurons_for_tests(&self) -> BTreeMap<u64, NeuronProto> {
let mut stable_neurons = with_stable_neuron_store(|stable_store| {
stable_store
.range_neurons(..)
.map(|neuron| (neuron.id().id, neuron.into()))
.collect::<BTreeMap<u64, NeuronProto>>()
});
let mut heap_neurons = self
.heap_neurons
.iter()
.map(|(id, neuron)| (*id, neuron.clone().into()))
.collect()
.collect::<BTreeMap<u64, NeuronProto>>();

stable_neurons.extend(heap_neurons);
stable_neurons
}

pub fn clone_topic_followee_index(&self) -> HashMap<i32, FollowersMap> {
Expand Down
2 changes: 1 addition & 1 deletion rs/nns/governance/tests/fixtures/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ impl NNS {
.ledger
.accounts
.clone();
let governance_proto = self.governance.clone_proto();
let governance_proto = self.governance.__get_state_for_test();
NNSState {
now: self.now(),
accounts,
Expand Down

0 comments on commit cb072fa

Please sign in to comment.