committed by
Neil
9 changed files with 402 additions and 39 deletions
@ -0,0 +1,15 @@ |
|||
{ |
|||
"hash": "0000000000017dd91008ec7c0ea63749b81d9a5188d9efc8d2d8cc0bdcff4d2a", |
|||
"size": 382, |
|||
"height": 100, |
|||
"merkleroot": "5c49629cefa3d5eb640a3236f6e970386e0b0826a5d33d566de36aec534fa93d", |
|||
"stakeroot": "0000000000000000000000000000000000000000000000000000000000000000", |
|||
"tx": [ |
|||
"c813acfcad624ccf19e6240358b95cbbb1b728ee94557556dc373cceae1a7e4b" |
|||
], |
|||
"time": 1454961067, |
|||
"nonce": 3396292691, |
|||
"bits": "1b01ffff", |
|||
"previousblockhash": "000000000000dcecdf2c1ae9bb3e2e3135e7765b1902938ff67e2be489ab8131", |
|||
"block": "010000003181ab89e42b7ef68f9302195b76e735312e3ebbe91a2cdfecdc0000000000003da94f53ec6ae36d563dd3a526080b6e3870e9f636320a64ebd5a3ef9c62495c000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000ffff011b00c2eb0b00000000640000007e010000abf1b85653506fca9885f1c26941ecf1010000000000000000000000000000000000000000000000000000000101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff00ffffffff03fa1a981200000000000017a914f5916158e3e2c4551c1796708db8367207ed13bb8700000000000000000000266a2464000000000000000000000000000000000000000000000000000000733ea5b290c04d1fdea1906f0000000000001976a9145b98376242c78de2003e7940d7e44270c39b83eb88ac000000000000000001d8bc28820000000000000000ffffffff0800002f646372642f00" |
|||
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1,60 @@ |
|||
# Copyright (c) 2018, John L. Jegutanis |
|||
# |
|||
# All rights reserved. |
|||
# |
|||
# See the file "LICENCE" for information about the copyright |
|||
# and warranty status of this software. |
|||
|
|||
import json |
|||
import os |
|||
from binascii import unhexlify |
|||
|
|||
import pytest |
|||
|
|||
from electrumx.lib.coins import Coin |
|||
from electrumx.lib.hash import hash_to_hex_str |
|||
|
|||
TRANSACTION_DIR = os.path.join( |
|||
os.path.dirname(os.path.realpath(__file__)), 'transactions') |
|||
|
|||
# Find out which db engines to test |
|||
# Those that are not installed will be skipped |
|||
transactions = [] |
|||
|
|||
for name in os.listdir(TRANSACTION_DIR): |
|||
try: |
|||
name_parts = name.split("_") |
|||
coinFound = Coin.lookup_coin_class(name_parts[0], name_parts[1]) |
|||
with open(os.path.join(TRANSACTION_DIR, name)) as f: |
|||
transactions.append((coinFound, json.load(f))) |
|||
except Exception as e: |
|||
transactions.append(pytest.fail(name)) |
|||
|
|||
|
|||
@pytest.fixture(params=transactions) |
|||
def transaction_details(request): |
|||
return request.param |
|||
|
|||
|
|||
def test_transaction(transaction_details): |
|||
coin, tx_info = transaction_details |
|||
|
|||
raw_tx = unhexlify(tx_info['hex']) |
|||
tx, tx_hash = coin.DESERIALIZER(raw_tx, 0).read_tx_and_hash() |
|||
assert tx_info['txid'] == hash_to_hex_str(tx_hash) |
|||
|
|||
vin = tx_info['vin'] |
|||
for i in range(len(vin)): |
|||
assert vin[i]['txid'] == hash_to_hex_str(tx.inputs[i].prev_hash) |
|||
assert vin[i]['vout'] == tx.inputs[i].prev_idx |
|||
|
|||
vout = tx_info['vout'] |
|||
for i in range(len(vout)): |
|||
# value pk_script |
|||
assert vout[i]['value'] == tx.outputs[i].value |
|||
spk = vout[i]['scriptPubKey'] |
|||
tx_pks = tx.outputs[i].pk_script |
|||
assert spk['hex'] == tx_pks.hex() |
|||
assert spk['address'] == coin.address_from_script(tx_pks) |
|||
assert coin.address_to_hashX(spk['address']) == \ |
|||
coin.hashX_from_script(tx_pks) |
@ -0,0 +1,79 @@ |
|||
{ |
|||
"hex": "01000000022b7a5d0b09429a430ee2d465ff4ec1cec8080f66c59989ef03680dcb26a817460400000000ffffffff4d1bb7488ea38c16542cb80f505cc3d0d1757e3887ba25c8256619ec9ab1c5c00000000000ffffffff09eb3334030000000000001976a914ea9ab497c58159b8b0bf23becd179c076f8fbb9188ac78d0f4020000000000001976a9144820daabe97c3efcd3b34dfa51caf432d68d6a4d88ac541965340000000000001976a91495880e8c485ee28349d9885aa0fe448aa96e237488acb42f94000000000000001976a914a0d1579a51dbb6f26469944711d7e3f2f7a0b26088ac2a01fa020000000000001976a91444386bacdf3d7a353dabb2b334db9506791e83f288ac5c3be50b0000000000001976a9149f66566103e93e3cc29bebfed48450c3869e9a7688acc6fc91000000000000001976a91492ebcb796c918f5db19540726f91ca06a3b7640a88acd2b1c23c0000000000001976a9148806f0ae0b862006e39835d8cf91ac7f9d1c97d588ac6790f5020000000000001976a91418f82896bef63e67e125951bc464362eefdb00bb88ac0000000000000000021ee5573600000000bfd40100010000006a473044022051876acd9f0b716eaf383873db604cd7f39d659db2e909701dcbd655b469121e022036c165ab21c16865bab81696b41b3dcb85eb802867490b034f4cce2ac643b7640121026ea7725f46b9ab3931dd789907e80380eb91771cc681a1711c4468b71589d390ea20fe5300000000bad40100010000006a4730440220401007a7c4ba4b982babb08120b62f260484f61491e557f0a0d7d9c4484acf0e022041288a676750d421c63e09e7c11787a49bfec49e5490202220ddeb3406e2d3da01210371f6b9914081c10adfbac8fde9c9731c29fdb1bb235ba70f28cb0cf5f7268b2e", |
|||
"txid": "9cde4a9685fa9e38ccf4da4bda1c1a123b3f2ed2c418f6bc128d7f5fbbee413d", |
|||
"vin": [ |
|||
{ |
|||
"txid": "4617a826cb0d6803ef8999c5660f08c8cec14eff65d4e20e439a42090b5d7a2b", |
|||
"vout": 4 |
|||
}, |
|||
{ |
|||
"txid": "c0c5b19aec196625c825ba87387e75d1d0c35c500fb82c54168ca38e48b71b4d", |
|||
"vout": 0 |
|||
} |
|||
], |
|||
"vout": [ |
|||
{ |
|||
"value": 53752811, |
|||
"scriptPubKey": { |
|||
"hex": "76a914ea9ab497c58159b8b0bf23becd179c076f8fbb9188ac", |
|||
"address": "DsnMNwSYjwgks3c1kWVbaB6npxv8LXnGc8U" |
|||
} |
|||
}, |
|||
{ |
|||
"value": 49598584, |
|||
"scriptPubKey": { |
|||
"hex": "76a9144820daabe97c3efcd3b34dfa51caf432d68d6a4d88ac", |
|||
"address": "DsXYHVzSPfo4jrYAkLJN7yFuAfY3mxA4JGy" |
|||
} |
|||
}, |
|||
{ |
|||
"value": 879040852, |
|||
"scriptPubKey": { |
|||
"hex": "76a91495880e8c485ee28349d9885aa0fe448aa96e237488ac", |
|||
"address": "DsebZAQadwBurUCowGbsbgYTpMETHBibZLf" |
|||
} |
|||
}, |
|||
{ |
|||
"value": 9711540, |
|||
"scriptPubKey": { |
|||
"hex": "76a914a0d1579a51dbb6f26469944711d7e3f2f7a0b26088ac", |
|||
"address": "DsfdEPUTpsCBJjjS8ovgp65uYwws18FQpas" |
|||
} |
|||
}, |
|||
{ |
|||
"value": 49938730, |
|||
"scriptPubKey": { |
|||
"hex": "76a91444386bacdf3d7a353dabb2b334db9506791e83f288ac", |
|||
"address": "DsXBd2eWDHujo7wjYTsUwRw7wHoiYN5Ynhg" |
|||
} |
|||
}, |
|||
{ |
|||
"value": 199572316, |
|||
"scriptPubKey": { |
|||
"hex": "76a9149f66566103e93e3cc29bebfed48450c3869e9a7688ac", |
|||
"address": "DsfVjXTdcisQ6j5c5ZrhLFfJC56ZMCCwkr2" |
|||
} |
|||
}, |
|||
{ |
|||
"value": 9567430, |
|||
"scriptPubKey": { |
|||
"hex": "76a91492ebcb796c918f5db19540726f91ca06a3b7640a88ac", |
|||
"address": "DseMkckQQVxjEu6t2bTD65gW4EY2GiGuhNk" |
|||
} |
|||
}, |
|||
{ |
|||
"value": 1019392466, |
|||
"scriptPubKey": { |
|||
"hex": "76a9148806f0ae0b862006e39835d8cf91ac7f9d1c97d588ac", |
|||
"address": "DsdN9hjHeY8FiDYdEpesfTy215sdN5Ly74v" |
|||
} |
|||
}, |
|||
{ |
|||
"value": 49647719, |
|||
"scriptPubKey": { |
|||
"hex": "76a91418f82896bef63e67e125951bc464362eefdb00bb88ac", |
|||
"address": "DsTEvzPjXppZGYkLXZdZN16FwGaeMEjudpe" |
|||
} |
|||
} |
|||
] |
|||
} |
Loading…
Reference in new issue