@@ -61,7 +61,14 @@ def run_test(self):
6161 descendant_fees = 0
6262 descendant_size = 0
6363
64+ descendants = []
65+ ancestors = list (chain )
6466 for x in reversed (chain ):
67+ # Check that getmempoolentry is consistent with getrawmempool
68+ entry = self .nodes [0 ].getmempoolentry (x )
69+ assert_equal (entry , mempool [x ])
70+
71+ # Check that the descendant calculations are correct
6572 assert_equal (mempool [x ]['descendantcount' ], descendant_count )
6673 descendant_fees += mempool [x ]['fee' ]
6774 assert_equal (mempool [x ]['modifiedfee' ], mempool [x ]['fee' ])
@@ -70,6 +77,27 @@ def run_test(self):
7077 assert_equal (mempool [x ]['descendantsize' ], descendant_size )
7178 descendant_count += 1
7279
80+ # Check that getmempooldescendants is correct
81+ assert_equal (sorted (descendants ), sorted (self .nodes [0 ].getmempooldescendants (x )))
82+ descendants .append (x )
83+
84+ # Check that getmempoolancestors is correct
85+ ancestors .remove (x )
86+ assert_equal (sorted (ancestors ), sorted (self .nodes [0 ].getmempoolancestors (x )))
87+
88+ # Check that getmempoolancestors/getmempooldescendants correctly handle verbose=true
89+ v_ancestors = self .nodes [0 ].getmempoolancestors (chain [- 1 ], True )
90+ assert_equal (len (v_ancestors ), len (chain )- 1 )
91+ for x in v_ancestors .keys ():
92+ assert_equal (mempool [x ], v_ancestors [x ])
93+ assert (chain [- 1 ] not in v_ancestors .keys ())
94+
95+ v_descendants = self .nodes [0 ].getmempooldescendants (chain [0 ], True )
96+ assert_equal (len (v_descendants ), len (chain )- 1 )
97+ for x in v_descendants .keys ():
98+ assert_equal (mempool [x ], v_descendants [x ])
99+ assert (chain [0 ] not in v_descendants .keys ())
100+
73101 # Check that descendant modified fees includes fee deltas from
74102 # prioritisetransaction
75103 self .nodes [0 ].prioritisetransaction (chain [- 1 ], 0 , 1000 )
0 commit comments