PR comments
This commit is contained in:
@ -860,7 +860,7 @@ impl Bank {
|
||||
.store_slow(self.accounts_id, &program_id, &bogus_account);
|
||||
}
|
||||
|
||||
pub fn is_descendant_of(&self, parent: u64) -> bool {
|
||||
pub fn is_in_subtree_of(&self, parent: u64) -> bool {
|
||||
if self.slot() == parent {
|
||||
return true;
|
||||
}
|
||||
@ -1644,7 +1644,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_descendant_of() {
|
||||
fn test_is_in_subtree_of() {
|
||||
let (genesis_block, _) = GenesisBlock::new(1);
|
||||
let parent = Arc::new(Bank::new(&genesis_block));
|
||||
// Bank 1
|
||||
@ -1655,15 +1655,15 @@ mod tests {
|
||||
let bank5 = Bank::new_from_parent(&bank, &Pubkey::default(), 5);
|
||||
|
||||
// Parents of bank 2: 0 -> 1 -> 2
|
||||
assert!(bank2.is_descendant_of(0));
|
||||
assert!(bank2.is_descendant_of(1));
|
||||
assert!(bank2.is_descendant_of(2));
|
||||
assert!(!bank2.is_descendant_of(3));
|
||||
assert!(bank2.is_in_subtree_of(0));
|
||||
assert!(bank2.is_in_subtree_of(1));
|
||||
assert!(bank2.is_in_subtree_of(2));
|
||||
assert!(!bank2.is_in_subtree_of(3));
|
||||
|
||||
// Parents of bank 3: 0 -> 1 -> 5
|
||||
assert!(bank5.is_descendant_of(0));
|
||||
assert!(bank5.is_descendant_of(1));
|
||||
assert!(!bank5.is_descendant_of(2));
|
||||
assert!(!bank5.is_descendant_of(4));
|
||||
// Parents of bank 5: 0 -> 1 -> 5
|
||||
assert!(bank5.is_in_subtree_of(0));
|
||||
assert!(bank5.is_in_subtree_of(1));
|
||||
assert!(!bank5.is_in_subtree_of(2));
|
||||
assert!(!bank5.is_in_subtree_of(4));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user