set up testrunner
This commit is contained in:
parent
f65641a2c7
commit
95a709e819
|
@ -1,4 +1,14 @@
|
||||||
*.pyc
|
# xcat
|
||||||
xcat.egg-info/
|
|
||||||
.tmp/
|
.tmp/
|
||||||
|
|
||||||
|
# Python
|
||||||
|
*.pyc
|
||||||
|
*.egg-info/
|
||||||
|
|
||||||
|
# Virtual environment
|
||||||
venv/
|
venv/
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
.tox/
|
||||||
|
coverage/
|
||||||
|
.coverage
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
flake8
|
||||||
|
pytest
|
||||||
|
pytest-cov
|
|
@ -0,0 +1,26 @@
|
||||||
|
[tox]
|
||||||
|
envlist =
|
||||||
|
py3{5}
|
||||||
|
|
||||||
|
[pytest]
|
||||||
|
nonrecursedirs = .git .tox venv coverage
|
||||||
|
|
||||||
|
[testenv]
|
||||||
|
usedevelop = True
|
||||||
|
deps =
|
||||||
|
-rrequirements.txt
|
||||||
|
-rrequirements-test.txt
|
||||||
|
|
||||||
|
commands =
|
||||||
|
flake8 \
|
||||||
|
--ignore=E501,E266 \
|
||||||
|
--exclude test.py \
|
||||||
|
xcat
|
||||||
|
pytest \
|
||||||
|
-q \
|
||||||
|
--junitxml=coverage/unit.xml \
|
||||||
|
--cov xcat \
|
||||||
|
--cov-report xml:coverage/coverage.xml \
|
||||||
|
--cov-report html:coverage/html/ \
|
||||||
|
--cov-report term-missing \
|
||||||
|
{posargs}
|
|
@ -14,7 +14,7 @@ from bitcoin.core.scripteval import VerifyScript, SCRIPT_VERIFY_P2SH
|
||||||
from bitcoin.wallet import CBitcoinAddress, P2SHBitcoinAddress
|
from bitcoin.wallet import CBitcoinAddress, P2SHBitcoinAddress
|
||||||
from bitcoin.wallet import P2PKHBitcoinAddress
|
from bitcoin.wallet import P2PKHBitcoinAddress
|
||||||
|
|
||||||
import xcat.utils as utils
|
# import xcat.utils as utils
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
if sys.version_info.major < 3:
|
if sys.version_info.major < 3:
|
||||||
|
@ -52,15 +52,15 @@ class bitcoinProxy():
|
||||||
print("Redeem transaction with secret not found")
|
print("Redeem transaction with secret not found")
|
||||||
return
|
return
|
||||||
|
|
||||||
def parse_secret(self, txid):
|
# def parse_secret(self, txid):
|
||||||
raw = zcashd.gettransaction(txid, True)['hex']
|
# raw = zcashd.gettransaction(txid, True)['hex']
|
||||||
decoded = zcashd.call('decoderawtransaction', raw)
|
# decoded = zcashd.call('decoderawtransaction', raw)
|
||||||
scriptSig = decoded['vin'][0]['scriptSig']
|
# scriptSig = decoded['vin'][0]['scriptSig']
|
||||||
asm = scriptSig['asm'].split(" ")
|
# asm = scriptSig['asm'].split(" ")
|
||||||
# pubkey = asm[1]
|
# # pubkey = asm[1]
|
||||||
secret = utils.x2s(asm[2])
|
# secret = utils.x2s(asm[2])
|
||||||
# redeemPubkey = P2PKHBitcoinAddress.from_pubkey(x(pubkey))
|
# # redeemPubkey = P2PKHBitcoinAddress.from_pubkey(x(pubkey))
|
||||||
return secret
|
# return secret
|
||||||
|
|
||||||
def get_keys(self, funder_address, redeemer_address):
|
def get_keys(self, funder_address, redeemer_address):
|
||||||
fundpubkey = CBitcoinAddress(funder_address)
|
fundpubkey = CBitcoinAddress(funder_address)
|
||||||
|
@ -131,27 +131,27 @@ class bitcoinProxy():
|
||||||
return 'empty'
|
return 'empty'
|
||||||
|
|
||||||
# TODO: FIX search for p2sh in block
|
# TODO: FIX search for p2sh in block
|
||||||
def search_p2sh(self, block, p2sh):
|
# def search_p2sh(self, block, p2sh):
|
||||||
print("Fetching block...")
|
# print("Fetching block...")
|
||||||
blockdata = self.bitcoind.getblock(lx(block))
|
# blockdata = self.bitcoind.getblock(lx(block))
|
||||||
print("done fetching block")
|
# print("done fetching block")
|
||||||
txs = blockdata.vtx
|
# txs = blockdata.vtx
|
||||||
print("txs", txs)
|
# print("txs", txs)
|
||||||
for tx in txs:
|
# for tx in txs:
|
||||||
txhex = b2x(tx.serialize())
|
# txhex = b2x(tx.serialize())
|
||||||
# Using my fork of python-zcashlib to get result of decoderawtransaction
|
# # Using my fork of python-zcashlib to get result of decoderawtransaction
|
||||||
txhex = txhex + '00'
|
# txhex = txhex + '00'
|
||||||
rawtx = zcashd.decoderawtransaction(txhex)
|
# rawtx = zcashd.decoderawtransaction(txhex)
|
||||||
# print('rawtx', rawtx)
|
# # print('rawtx', rawtx)
|
||||||
print(rawtx)
|
# print(rawtx)
|
||||||
for vout in rawtx['vout']:
|
# for vout in rawtx['vout']:
|
||||||
if 'addresses' in vout['scriptPubKey']:
|
# if 'addresses' in vout['scriptPubKey']:
|
||||||
for addr in vout['scriptPubKey']['addresses']:
|
# for addr in vout['scriptPubKey']['addresses']:
|
||||||
print("Sent to address:", addr)
|
# print("Sent to address:", addr)
|
||||||
if addr == p2sh:
|
# if addr == p2sh:
|
||||||
print("Address to p2sh found in transaction! ",
|
# print("Address to p2sh found in transaction! ",
|
||||||
addr)
|
# addr)
|
||||||
print("Returning from search_p2sh")
|
# print("Returning from search_p2sh")
|
||||||
|
|
||||||
def get_tx_details(self, txid):
|
def get_tx_details(self, txid):
|
||||||
# must convert txid string to bytes x(txid)
|
# must convert txid string to bytes x(txid)
|
||||||
|
|
Loading…
Reference in New Issue