PR comments

This commit is contained in:
Carl
2019-03-18 20:23:34 -07:00
committed by Grimes
parent b38e3bef01
commit 5e21268ca0
3 changed files with 25 additions and 35 deletions

View File

@ -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));
}
}