def run_test(self):
    self.log.info('Mining blocks...')
    self.nodes[0].generate(1)
    self.sync_all()
    self.nodes[1].generate(100)
    self.sync_all()
    txid1 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 10)
    self.nodes[0].generate(1)
    self.sync_all()
    txid2 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 20)
    assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1)
    assert_equal(self.nodes[0].gettransaction(txid2)['txid'], txid2)
    self.stop_node(0)
    self.start_node(0)
    assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1)
    assert_equal(self.nodes[0].gettransaction(txid2)['txid'], txid2)
    self.stop_node(0)
    self.start_node(0, ['-persistmempool=1', '-zapwallettxes=2'])
    wait_until((lambda : (self.nodes[0].getmempoolinfo()['size'] == 1)), timeout=3)
    self.nodes[0].syncwithvalidationinterfacequeue()
    assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1)
    assert_equal(self.nodes[0].gettransaction(txid2)['txid'], txid2)
    self.stop_node(0)
    self.start_node(0, ['-zapwallettxes=2'])
    assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1)
    assert_raises_rpc_error((- 5), 'Invalid or non-wallet transaction id', self.nodes[0].gettransaction, txid2)
def run_test(self):
    self.log.info('Mining blocks...')
    self.nodes[0].generate(1)
    self.sync_all()
    self.nodes[1].generate(100)
    self.sync_all()
    txid1 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 10)
    self.nodes[0].generate(1)
    self.sync_all()
    txid2 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 20)
    assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1)
    assert_equal(self.nodes[0].gettransaction(txid2)['txid'], txid2)
    self.stop_node(0)
    self.start_node(0)
    assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1)
    assert_equal(self.nodes[0].gettransaction(txid2)['txid'], txid2)
    self.stop_node(0)
    self.start_node(0, ['-persistmempool=1', '-zapwallettxes=2'])
    wait_until((lambda : (self.nodes[0].getmempoolinfo()['size'] == 1)), timeout=3)
    self.nodes[0].syncwithvalidationinterfacequeue()
    assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1)
    assert_equal(self.nodes[0].gettransaction(txid2)['txid'], txid2)
    self.stop_node(0)
    self.start_node(0, ['-zapwallettxes=2'])
    assert_equal(self.nodes[0].gettransaction(txid1)['txid'], txid1)
    assert_raises_rpc_error((- 5), 'Invalid or non-wallet transaction id', self.nodes[0].gettransaction, txid2)