Skip to content

Commit

Permalink
test(registry): improve test for do_add_node - check rewardable_nodes (
Browse files Browse the repository at this point in the history
…#3934)

### Summary

Similarly to the test changes in #3924 that we made for removing nodes,
here is an equivalent one for adding nodes. The `rewardable_nodes` field
in `NodeOperatorRecord` is extended with sample `btreemap` values to
test that node allowance field value isn't lost in the node add
operation.
  • Loading branch information
sasa-tomic authored Feb 20, 2025
1 parent c249d05 commit 2bbbfd1
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ mod tests {
use ic_types::ReplicaVersion;
use itertools::Itertools;
use lazy_static::lazy_static;
use maplit::btreemap;
use prost::Message;
use std::str::FromStr;

Expand Down Expand Up @@ -594,6 +595,7 @@ mod tests {
// Add node operator record first
let node_operator_record = NodeOperatorRecord {
node_allowance: 1, // Should be > 0 to add a new node
rewardable_nodes: btreemap! { "type0".to_string() => 0, "type1".to_string() => 28 },
..Default::default()
};
let node_operator_id = PrincipalId::from_str(TEST_NODE_ID).unwrap();
Expand All @@ -616,10 +618,15 @@ mod tests {
};
let node_record = registry.get_node_or_panic(node_id);
assert_eq!(node_record, node_record_expected);
// Assert node allowance counter has decremented

// Assert the node operator record is correct
let node_operator_record_expected = NodeOperatorRecord {
node_allowance: 0,
..node_operator_record
};
let node_operator_record = get_node_operator_record(&registry, node_operator_id)
.expect("failed to get node operator");
assert_eq!(node_operator_record.node_allowance, 0);
assert_eq!(node_operator_record, node_operator_record_expected);
}

#[test]
Expand Down

0 comments on commit 2bbbfd1

Please sign in to comment.