mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-18 06:34:19 +01:00
Adds API unit tests and modifies bitcoin_sim to be fixture compatible
- Adds unit tests for API - Updates API to let BlockProcessor deal with block block related JSON-RPC - Fixes BlockProcessor get_potential_matches return - Makes bitcoin_sim runnable via function (instead of a main runnable script) to work with pytests fixture - <3 Fixture
This commit is contained in:
@@ -15,6 +15,15 @@ app = Flask(__name__)
|
||||
HOST = 'localhost'
|
||||
PORT = '18443'
|
||||
|
||||
mining_simulator = ZMQPublisher(topic=b'hashblock', feed_protocol=FEED_PROTOCOL, feed_addr=FEED_ADDR,
|
||||
feed_port=FEED_PORT)
|
||||
|
||||
mempool = []
|
||||
mined_transactions = {}
|
||||
blocks = {}
|
||||
blockchain = []
|
||||
TIME_BETWEEN_BLOCKS = 10
|
||||
|
||||
|
||||
@app.route('/', methods=['POST'])
|
||||
def process_request():
|
||||
@@ -193,18 +202,10 @@ def simulate_mining():
|
||||
print("New block mined: {}".format(block_hash))
|
||||
print("\tTransactions: {}".format(txs_to_mine))
|
||||
|
||||
time.sleep(10)
|
||||
time.sleep(TIME_BETWEEN_BLOCKS)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
mining_simulator = ZMQPublisher(topic=b'hashblock', feed_protocol=FEED_PROTOCOL, feed_addr=FEED_ADDR,
|
||||
feed_port=FEED_PORT)
|
||||
|
||||
mempool = []
|
||||
mined_transactions = {}
|
||||
blocks = {}
|
||||
blockchain = []
|
||||
|
||||
def run_simulator():
|
||||
mining_thread = Thread(target=simulate_mining)
|
||||
mining_thread.start()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user