def test_A(self): tmpdbfile = os.path.join(self.datadir, '_tmp.db') bref = MemBlock.read(333931) proxy.set_rawmempool(333931) proxy.blockcount = 333930 proxy.on = False mempool = TxMempool(dbfile=tmpdbfile) print("*** Proxy is OFF ***") with mempool.context_start(): sleep(50) proxy.on = True print("*** Proxy is ON ***") sleep(20) proxy.blockcount = 333931 sleep(10) btest = MemBlock.read(333931, dbfile=tmpdbfile) # They're not equal because their times don't match. self.assertNotEqual(btest, bref) btest.time = bref.time for entry in bref.entries.values(): entry.leadtime = int(entry.leadtime) for entry in btest.entries.values(): entry.leadtime = btest.time - entry.time self.assertEqual(btest, bref)
def test_B(self): # Test the setting of rawmempool proxy.set_rawmempool(333931) rawmempool = proxy.getrawmempool() b = MemBlock.read(333931, dbfile=dbfile) self.assertEqual(set(b.entries), set(rawmempool)) for txid, rawentry in rawmempool.items(): for key, val in rawentry.items(): self.assertEqual(val, getattr(b.entries[txid], key))
def test_B(self): """No memblocks.""" config.set("app", "pools_minblocks", "432") sim = SimOnline() proxy.blockcount = 333930 proxy.set_rawmempool(333931) print("Starting test B thread.") with sim.context_start(): sleep(5) proxy.set_rawmempool(333932) sleep(5) pprint(sim.get_txstats())
def test_A(self): """Basic tests.""" config.set("app", "pools_minblocks", "1") sim = SimOnline() print("Starting test A thread.") with sim.context_start(): while not sim.txonline.tx_estimator: sleep(0.1) while not sim.transient.stats: sleep(0.1) transient_stats = sim.transient.stats print(transient_stats.expectedwaits) lowest_feerate = transient_stats.feepoints[0] print("*** Setting rawmempool to 333931 ***") proxy.set_rawmempool(333953) sleep(poll_period) for txid, predict in sim.prediction.predicts.items(): if predict is not None: predict.entrytime = self.time() - 600 else: entry = sim.state.entries[txid] self.assertTrue( entry.is_high_priority() or entry.depends or entry.feerate < lowest_feerate) print("*** Incrementing blockcount ***") proxy.blockcount += 1 proxy.rawmempool = {} sleep(poll_period*2) predictstats = sim.get_predictstats() pprint(zip(*predictstats['pval_ecdf'])) print("p-distance is {}".format(predictstats['pdistance'])) pred_db = Prediction.from_db( config.getint("app", "predict_block_halflife")) self.assertEqual(pred_db.pval_ecdf, sim.prediction.pval_ecdf) self.assertEqual(sum(sim.prediction.pvalcounts), 76) poolsref = sim.poolsonline.get_pools() predictionref = sim.prediction # Test loading of predicts and pools # config.set("app", "pools_minblocks", "432") sim = SimOnline() with sim.context_start(): sleep(1) self.assertTrue(sim.poolsonline.poolsestimate) self.assertEqual(poolsref, sim.poolsonline.get_pools()) self.assertEqual(predictionref, sim.prediction)
def proxyschedule(self): proxy.blockcount = 333952 proxy.set_rawmempool(333953) sleep(10) print("*** Incrementing block count ***") proxy.blockcount += 1
def __init__(self): proxy.set_rawmempool(333931) proxy.blockcount = 333930 self.state = MempoolState(*proxy.poll_mempool())
def setUp(self): proxy.set_rawmempool(333931) proxy.blockcount = 333930