From 0148024dd84edf0f7eafc7c77e0fc988709a14ff Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Wed, 20 Mar 2019 10:48:41 -0400 Subject: [PATCH] Functional test linting --- test/functional/feature_assetsdir.py | 7 +-- test/functional/feature_blocksign.py | 2 +- .../feature_confidential_transactions.py | 14 +++--- test/functional/feature_default_asset_name.py | 4 +- .../feature_initial_reissuance_token.py | 3 -- test/functional/feature_issuance.py | 7 ++- test/functional/feature_pak.py | 2 +- test/functional/feature_rbf.py | 2 +- test/functional/feature_segwit.py | 2 +- test/functional/interface_rest.py | 1 - test/functional/mempool_persist.py | 2 +- test/functional/p2p_compactblocks.py | 2 +- test/functional/p2p_segwit.py | 12 +++-- test/functional/rpc_createmultisig.py | 1 - test/functional/rpc_fundrawtransaction.py | 1 - test/functional/rpc_rawtransaction.py | 2 +- test/functional/rpc_tweakfedpeg.py | 4 +- test/functional/rpc_txoutproof.py | 2 +- test/functional/test_framework/blocktools.py | 2 - test/functional/test_framework/messages.py | 48 ++++++++++++------- test/functional/wallet_abandonconflict.py | 2 +- test/functional/wallet_address_types.py | 1 - test/functional/wallet_backup.py | 2 +- test/functional/wallet_basic.py | 5 +- test/functional/wallet_bumpfee.py | 2 +- test/functional/wallet_groups.py | 1 - test/functional/wallet_hd.py | 1 - test/functional/wallet_importprunedfunds.py | 1 - test/functional/wallet_keypool_topup.py | 1 - test/functional/wallet_labels.py | 2 +- test/functional/wallet_multiwallet.py | 1 - test/functional/wallet_txn_clone.py | 1 - test/functional/wallet_txn_doublespend.py | 1 - 33 files changed, 69 insertions(+), 72 deletions(-) diff --git a/test/functional/feature_assetsdir.py b/test/functional/feature_assetsdir.py index 4d96d54f45..4510914889 100755 --- a/test/functional/feature_assetsdir.py +++ b/test/functional/feature_assetsdir.py @@ -8,11 +8,8 @@ # Test listissuances returns a list of all issuances or specific issuances based on asset hex or asset label. # -from decimal import Decimal from test_framework.test_framework import BitcoinTestFramework -from test_framework.authproxy import JSONRPCException from test_framework.util import assert_equal, assert_greater_than -from test_framework.util import * class AssetdirTests(BitcoinTestFramework): """ @@ -45,13 +42,13 @@ class AssetdirTests(BitcoinTestFramework): #Check that listissuances return all issuances issuances = self.nodes[0].listissuances() assert_equal(len(issuances), 2) - + #Check all asset labels have been set: 'asset1', 'asset2' #We can not be sure they will always be returned in the same order so will loop each one label = "" for issue in issuances: label += issue["assetlabel"] - + assert_greater_than(label.find("asset1"), -1) assert_greater_than(label.find("asset2"), -1) diff --git a/test/functional/feature_blocksign.py b/test/functional/feature_blocksign.py index 0019ef44ea..260892dfd9 100755 --- a/test/functional/feature_blocksign.py +++ b/test/functional/feature_blocksign.py @@ -5,7 +5,7 @@ import hashlib import random from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import (assert_raises_rpc_error, assert_equal, connect_nodes_bi, BITCOIN_ASSET) +from test_framework.util import (assert_raises_rpc_error, assert_equal, connect_nodes_bi) from test_framework import ( address, key, diff --git a/test/functional/feature_confidential_transactions.py b/test/functional/feature_confidential_transactions.py index 5b5b80ce11..1c1d77a101 100755 --- a/test/functional/feature_confidential_transactions.py +++ b/test/functional/feature_confidential_transactions.py @@ -148,7 +148,7 @@ class CTTest (BitcoinTestFramework): tx = self.nodes[0].createrawtransaction([{"txid": unspent[0]["txid"], "vout": unspent[0]["vout"], "nValue": unspent[0]["amount"]}], - {unconfidential_address: unspent[0]["amount"] - fee, "fee":fee}); + {unconfidential_address: unspent[0]["amount"] - fee, "fee":fee}) # Test that blindrawtransaction adds an OP_RETURN output to balance blinders temptx = self.nodes[0].blindrawtransaction(tx) @@ -164,7 +164,7 @@ class CTTest (BitcoinTestFramework): "vout": unspent[0]["vout"], "nValue": unspent[0]["amount"]}], {unconfidential_address: value4, - change_address: unspent[0]["amount"] - value4 - fee, "fee":fee}); + change_address: unspent[0]["amount"] - value4 - fee, "fee":fee}) tx = self.nodes[0].blindrawtransaction(tx) tx_signed = self.nodes[0].signrawtransactionwithwallet(tx) txid = self.nodes[0].sendrawtransaction(tx_signed['hex']) @@ -222,7 +222,7 @@ class CTTest (BitcoinTestFramework): # therefore result will be same even though we change blinding keys assert_equal(len(self.nodes[0].listunspent(0, 0, [new_validated["unconfidential"]])), 1) - #### Confidential Assets Tests #### + # Confidential Assets Tests print("Assets tests...") @@ -295,8 +295,8 @@ class CTTest (BitcoinTestFramework): self.nodes[2].generate(1) self.sync_all() - redata1 = self.nodes[1].reissueasset(issuancedata["asset"], Decimal('0.05')) - redata2 = self.nodes[2].reissueasset(issuancedata["asset"], Decimal('0.025')) + self.nodes[1].reissueasset(issuancedata["asset"], Decimal('0.05')) + self.nodes[2].reissueasset(issuancedata["asset"], Decimal('0.025')) self.nodes[1].generate(1) self.sync_all() @@ -349,8 +349,8 @@ class CTTest (BitcoinTestFramework): # Basic checks of rawblindrawtransaction functionality blinded_addr = self.nodes[0].getnewaddress() addr = self.nodes[0].validateaddress(blinded_addr)["unconfidential"] - txid1 = self.nodes[0].sendtoaddress(blinded_addr, 1) - txid2 = self.nodes[0].sendtoaddress(blinded_addr, 3) + self.nodes[0].sendtoaddress(blinded_addr, 1) + self.nodes[0].sendtoaddress(blinded_addr, 3) unspent = self.nodes[0].listunspent(0, 0) assert_equal(len(unspent), 4) rawtx = self.nodes[0].createrawtransaction([{"txid":unspent[0]["txid"], "vout":unspent[0]["vout"]}, {"txid":unspent[1]["txid"], "vout":unspent[1]["vout"]}], {addr:unspent[0]["amount"]+unspent[1]["amount"]-Decimal("0.2"), "fee":Decimal("0.2")}) diff --git a/test/functional/feature_default_asset_name.py b/test/functional/feature_default_asset_name.py index a56eb5a2fc..7e772f3c1f 100755 --- a/test/functional/feature_default_asset_name.py +++ b/test/functional/feature_default_asset_name.py @@ -7,9 +7,7 @@ # Test chain initialisation when specifying default asset name. # -from decimal import Decimal from test_framework.test_framework import BitcoinTestFramework -from test_framework.authproxy import JSONRPCException from test_framework.util import assert_equal, connect_nodes_bi class NamedDefaultAssetTest(BitcoinTestFramework): @@ -42,7 +40,7 @@ class NamedDefaultAssetTest(BitcoinTestFramework): assert_equal(walletinfo1["balance"]["testasset"], 21000000) #Send some of the default asset to the second node - self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1, "", "", False) + self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1, "", "", False) self.nodes[0].generate(101) self.sync_all() diff --git a/test/functional/feature_initial_reissuance_token.py b/test/functional/feature_initial_reissuance_token.py index c048d6a553..7b1336217c 100755 --- a/test/functional/feature_initial_reissuance_token.py +++ b/test/functional/feature_initial_reissuance_token.py @@ -7,11 +7,8 @@ # Test chain initialisation when specifying number of reissuance tokens to issue. # -from decimal import Decimal from test_framework.test_framework import BitcoinTestFramework -from test_framework.authproxy import JSONRPCException from test_framework.util import connect_nodes_bi, assert_equal -from test_framework.util import * class InitialReissuanceTokenTest(BitcoinTestFramework): """ diff --git a/test/functional/feature_issuance.py b/test/functional/feature_issuance.py index f2fbaf2549..8e12f93cb7 100755 --- a/test/functional/feature_issuance.py +++ b/test/functional/feature_issuance.py @@ -79,8 +79,7 @@ def process_raw_issuance(node, issuance_list): if "asset" in output and output["asset"] == issuance_details[issuance_type]: if issuance_type+"_address" not in issuance_req: raise Exception("Found asset type not requested") - if "value" in output and \ - output["value"] == issuance_req[issuance_type+"_amount"]: + if "value" in output and output["value"] == issuance_req[issuance_type+"_amount"]: asset_found = True # Find the asset type if it was created @@ -105,7 +104,7 @@ class IssuanceTest(BitcoinTestFramework): def run_test(self): self.nodes[0].generate(105) # Make sure test starts with no initial issuance. - assert_equal(len(self.nodes[0].listissuances()), 0); + assert_equal(len(self.nodes[0].listissuances()), 0) # Unblinded issuance of asset issued = self.nodes[0].issueasset(1, 1, False) @@ -211,7 +210,7 @@ class IssuanceTest(BitcoinTestFramework): addr2 = txdet2[len(txdet2)-1]["address"] addr3 = txdet3[len(txdet3)-1]["address"] - assert_equal(len(self.nodes[0].listissuances()), 5); + assert_equal(len(self.nodes[0].listissuances()), 5) self.nodes[0].importaddress(addr1) self.nodes[0].importaddress(addr2) self.nodes[0].importaddress(addr3) diff --git a/test/functional/feature_pak.py b/test/functional/feature_pak.py index 38f12d66fd..6b19ab0aa6 100755 --- a/test/functional/feature_pak.py +++ b/test/functional/feature_pak.py @@ -3,7 +3,7 @@ # Distributed under the MIT/X11 software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes_bi, sync_blocks, Decimal, BITCOIN_ASSET +from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes_bi, sync_blocks, Decimal import copy import time diff --git a/test/functional/feature_rbf.py b/test/functional/feature_rbf.py index fb97cb6df0..cd7e3e6b9d 100755 --- a/test/functional/feature_rbf.py +++ b/test/functional/feature_rbf.py @@ -9,7 +9,7 @@ from decimal import Decimal from test_framework.messages import COIN, COutPoint, CTransaction, CTxIn, CTxOut, CTxOutValue from test_framework.script import CScript, OP_DROP from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, assert_raises_rpc_error, bytes_to_hex_str, hex_str_to_bytes, satoshi_round, BITCOIN_ASSET +from test_framework.util import assert_equal, assert_raises_rpc_error, bytes_to_hex_str, hex_str_to_bytes, satoshi_round from io import BytesIO diff --git a/test/functional/feature_segwit.py b/test/functional/feature_segwit.py index 92fec76d36..7fda5aef69 100755 --- a/test/functional/feature_segwit.py +++ b/test/functional/feature_segwit.py @@ -19,7 +19,7 @@ from test_framework.blocktools import witness_script, send_to_witness from test_framework.messages import COIN, COutPoint, CTransaction, CTxIn, CTxOut, FromHex, sha256, ToHex from test_framework.script import CScript, OP_HASH160, OP_CHECKSIG, OP_0, hash160, OP_EQUAL, OP_DUP, OP_EQUALVERIFY, OP_1, OP_2, OP_CHECKMULTISIG, OP_TRUE, OP_DROP, OP_RETURN from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, assert_raises_rpc_error, bytes_to_hex_str, connect_nodes, hex_str_to_bytes, sync_blocks, try_rpc, BITCOIN_ASSET +from test_framework.util import assert_equal, assert_raises_rpc_error, bytes_to_hex_str, connect_nodes, hex_str_to_bytes, sync_blocks, try_rpc from io import BytesIO diff --git a/test/functional/interface_rest.py b/test/functional/interface_rest.py index dfc7a41696..e9127755c7 100755 --- a/test/functional/interface_rest.py +++ b/test/functional/interface_rest.py @@ -20,7 +20,6 @@ from test_framework.util import ( assert_greater_than, assert_greater_than_or_equal, hex_str_to_bytes, - BITCOIN_ASSET, ) class ReqType(Enum): diff --git a/test/functional/mempool_persist.py b/test/functional/mempool_persist.py index 33c98bfeb4..1739e8abd8 100755 --- a/test/functional/mempool_persist.py +++ b/test/functional/mempool_persist.py @@ -40,7 +40,7 @@ import os import time from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, assert_raises_rpc_error, wait_until, BITCOIN_ASSET +from test_framework.util import assert_equal, assert_raises_rpc_error, wait_until class MempoolPersistTest(BitcoinTestFramework): def set_test_params(self): diff --git a/test/functional/p2p_compactblocks.py b/test/functional/p2p_compactblocks.py index 9119d5919d..55f63e4324 100755 --- a/test/functional/p2p_compactblocks.py +++ b/test/functional/p2p_compactblocks.py @@ -16,7 +16,7 @@ from test_framework.messages import BlockTransactions, BlockTransactionsRequest, from test_framework.mininode import mininode_lock, P2PInterface from test_framework.script import CScript, OP_TRUE, OP_DROP from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, get_bip9_status, satoshi_round, sync_blocks, wait_until, BITCOIN_ASSET +from test_framework.util import assert_equal, get_bip9_status, satoshi_round, sync_blocks, wait_until from test_framework import util # TestP2PConn: A peer we use to send messages to bitcoind, and store responses. diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py index cc9f1419b9..191a9b5db5 100755 --- a/test/functional/p2p_segwit.py +++ b/test/functional/p2p_segwit.py @@ -487,7 +487,8 @@ class SegWitTest(BitcoinTestFramework): tx.vin = [CTxIn(COutPoint(self.utxo[0].sha256, self.utxo[0].n), b'')] tx.vout = [CTxOut(value, script_pubkey), CTxOut(value, p2sh_script_pubkey)] tx.vout.append(CTxOut(value, CScript([OP_TRUE]))) - if self.utxo[0].nValue % 3 > 0: tx.vout.append(CTxOut(self.utxo[0].nValue - 3*value)) + if self.utxo[0].nValue % 3 > 0: + tx.vout.append(CTxOut(self.utxo[0].nValue - 3*value)) tx.rehash() txid = tx.sha256 @@ -1742,7 +1743,8 @@ class SegWitTest(BitcoinTestFramework): split_value = total_value // num_outputs for i in range(num_outputs): tx.vout.append(CTxOut(split_value, script_pubkey)) - if total_value % num_outputs > 0: tx.vout.append(CTxOut(total_value - num_outputs*split_value)) # fee + if total_value % num_outputs > 0: + tx.vout.append(CTxOut(total_value - num_outputs*split_value)) # fee for i in range(num_inputs): # Now try to sign each input, using a random hashtype. anyonecanpay = 0 @@ -1815,7 +1817,8 @@ class SegWitTest(BitcoinTestFramework): # Just spend to our usual anyone-can-spend output tx.vout = [CTxOut(output_value, CScript([OP_TRUE]))] * 2 total_in = sum(i.nValue for i in temp_utxos) - if total_in - 2*output_value > 0: tx.vout.append(CTxOut(total_in - 2*output_value)) # fee + if total_in - 2*output_value > 0: + tx.vout.append(CTxOut(total_in - 2*output_value)) # fee for i in temp_utxos: # Use SIGHASH_ALL|SIGHASH_ANYONECANPAY so we can build up # the signatures as we go. @@ -2054,7 +2057,8 @@ class SegWitTest(BitcoinTestFramework): tx.vout.append(CTxOut(split_value, script_pubkey)) tx.vout[-2].scriptPubKey = script_pubkey_toomany tx.vout[-1].scriptPubKey = script_pubkey_justright - if self.utxo[0].nValue % outputs > 0: tx.vout.append(CTxOut(self.utxo[0].nValue - outputs*split_value)) # fee + if self.utxo[0].nValue % outputs > 0: + tx.vout.append(CTxOut(self.utxo[0].nValue - outputs*split_value)) # fee tx.rehash() block_1 = self.build_next_block() diff --git a/test/functional/rpc_createmultisig.py b/test/functional/rpc_createmultisig.py index 9daff3c18c..582260b83a 100755 --- a/test/functional/rpc_createmultisig.py +++ b/test/functional/rpc_createmultisig.py @@ -5,7 +5,6 @@ """Test transaction signing using the signrawtransaction* RPCs.""" from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import BITCOIN_ASSET import decimal class RpcCreateMultiSigTest(BitcoinTestFramework): diff --git a/test/functional/rpc_fundrawtransaction.py b/test/functional/rpc_fundrawtransaction.py index 247c245384..139916de49 100755 --- a/test/functional/rpc_fundrawtransaction.py +++ b/test/functional/rpc_fundrawtransaction.py @@ -15,7 +15,6 @@ from test_framework.util import ( connect_nodes_bi, count_bytes, find_vout_for_address, - BITCOIN_ASSET, ) diff --git a/test/functional/rpc_rawtransaction.py b/test/functional/rpc_rawtransaction.py index bcfcdb9bfb..731fc2ea96 100755 --- a/test/functional/rpc_rawtransaction.py +++ b/test/functional/rpc_rawtransaction.py @@ -17,7 +17,7 @@ from decimal import Decimal from io import BytesIO from test_framework.messages import CTransaction, ToHex from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, assert_raises_rpc_error, bytes_to_hex_str, connect_nodes_bi, hex_str_to_bytes, BITCOIN_ASSET +from test_framework.util import assert_equal, assert_raises_rpc_error, bytes_to_hex_str, connect_nodes_bi, hex_str_to_bytes class multidict(dict): """Dictionary that allows duplicate keys. diff --git a/test/functional/rpc_tweakfedpeg.py b/test/functional/rpc_tweakfedpeg.py index eccb722173..4d33342b5d 100755 --- a/test/functional/rpc_tweakfedpeg.py +++ b/test/functional/rpc_tweakfedpeg.py @@ -50,7 +50,7 @@ class TweakFedpegTest(BitcoinTestFramework): assert_equal(tweak, nontweak) # Elements 0.14 Daemon example - assert_equal(self.nodes[1].tweakfedpegscript("0014008b1fdbaec5a82a9322af1640e871727245bce1")["script"], \ + assert_equal(self.nodes[1].tweakfedpegscript("0014008b1fdbaec5a82a9322af1640e871727245bce1")["script"], "522102f5bc6bc407187d06854005c366b84b411534757f4503587cf335645a620f896a2102fd90164e4e7d53417e4eacfa3f86fd39fe40594791758739e8af31eeea4e79c552ae") # Test Liquid-style fedpegscript with CSV emergency keys(which don't get tweaked!) @@ -72,7 +72,7 @@ class TweakFedpegTest(BitcoinTestFramework): # Liquid Deamon example: - assert_equal(self.nodes[2].tweakfedpegscript("0014008b1fdbaec5a82a9322af1640e871727245bce1")["script"], \ + assert_equal(self.nodes[2].tweakfedpegscript("0014008b1fdbaec5a82a9322af1640e871727245bce1")["script"], "745c87635b2103258857ed88024e5296436f851337451d3d68522fbb21dc5a047b965cd2f790932103ab43d77e8706a799cee3c14678574bccaca98c101217369cee987073cd2546492102ee5c8dfdf742bcc2b08386a6a3ec4b6087d39a6fd7e6f0fdeb82ecc30b11d0342102b104b6a469d8b3ccf0a671198e5f7d7010dbf2eb5587733b168f6e0d3be75760210207fc37d4877529fb0d63b1de352689627400a43f18717fa182fe0eea283bdd7921025d8724d82c61708458bc1a08ec9a7fcaf0ab6747ccf0a7d378faea07a261ab3e2102af6859d48d0a4518a4811f12adb974bbd051931e3f96f0b6ae16142c43ae6fd12102458215967f7977effc21b964bd92d870ae7eca98f343801031639150139e63ed2102cdef66bf4b5d26d0be22cabd5761970cfa84be905dc0137ad08ab634f104cb9e210297fb764f808c126f46ce0444124213bdc6a18f2904e75c9144f53bed4c19376e2103c631e77d14a5eb2fc61496ee3e9ea19d1e56e7e65a07aaa786f25ffc2921efde210270addb9011a4b41987b0848a8dc52e5442964fe5188c6a4c9320fbb9016390772103bf9aa75444d0013c46dcf10d70831b75b46a25d901fb7c6360beb2f6cac9c503210278f303dbaad1410a26d99e4dca8925fae4c90532a156c29e8ab1abf5ccaa663d210394cc0983add2dc60aa988c9faedebdc5463106184d72dd430ef24d215daf8b935f6702c00fb275522103aab896d53a8e7d6433137bbba940f9c521e085dd07e60994579b64a6d992cf79210291b7d0b1b692f8f524516ed950872e5da10fb1b808b5a526dedc6fed1cf29807210386aa9372fbab374593466bc5451dc59954e90787f08060964d95c87ef34ca5bb5368ae") diff --git a/test/functional/rpc_txoutproof.py b/test/functional/rpc_txoutproof.py index 4e9c0e3432..2c6246eed9 100755 --- a/test/functional/rpc_txoutproof.py +++ b/test/functional/rpc_txoutproof.py @@ -6,7 +6,7 @@ from test_framework.messages import CMerkleBlock, FromHex, ToHex from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes, BITCOIN_ASSET +from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes class MerkleBlockTest(BitcoinTestFramework): def set_test_params(self): diff --git a/test/functional/test_framework/blocktools.py b/test/functional/test_framework/blocktools.py index 27f9c571c0..3d898df3a1 100644 --- a/test/functional/test_framework/blocktools.py +++ b/test/functional/test_framework/blocktools.py @@ -18,7 +18,6 @@ from .messages import ( CTxIn, CTxInWitness, CTxOut, - CTxOutAsset, CTxOutValue, FromHex, ToHex, @@ -30,7 +29,6 @@ from .messages import ( sha256, uint256_from_str, CProof, - BITCOIN_ASSET_OUT, ) from .script import ( CScript, diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index b296a91764..f6ed8bc83e 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -322,11 +322,16 @@ class CTxOutAsset(object): def deserialize(self, f): version = ord(f.read(1)) - if version == 0: self.vchCommitment = b'\x00' - elif version == 1: self.vchCommitment = b'\x01' + f.read(32) - elif version == 0xff: self.vchCommitment = b'\xff' + f.read(32) - elif version == 10 or version == 11: self.vchCommitment = bytes([version]) + f.read(32) - else: raise 'invalid CTxOutAsset in deserialize' + if version == 0: + self.vchCommitment = b'\x00' + elif version == 1: + self.vchCommitment = b'\x01' + f.read(32) + elif version == 0xff: + self.vchCommitment = b'\xff' + f.read(32) + elif version == 10 or version == 11: + self.vchCommitment = bytes([version]) + f.read(32) + else: + raise 'invalid CTxOutAsset in deserialize' def serialize(self): r = b"" @@ -353,15 +358,21 @@ class CTxOutValue(object): def deserialize(self, f): version = ord(f.read(1)) - if version == 0: self.vchCommitment = b'\x00' - elif version == 1: self.vchCommitment = b'\x01' + f.read(8) - elif version == 0xff: self.vchCommitment = b'\xff' + f.read(8) - elif version == 8 or version == 9: self.vchCommitment = bytes([version]) + f.read(32) - else: raise Exception('invalid CTxOutValue in deserialize. version %d' % version) + if version == 0: + self.vchCommitment = b'\x00' + elif version == 1: + self.vchCommitment = b'\x01' + f.read(8) + elif version == 0xff: + self.vchCommitment = b'\xff' + f.read(8) + elif version == 8 or version == 9: + self.vchCommitment = bytes([version]) + f.read(32) + else: + raise Exception('invalid CTxOutValue in deserialize. version %d' % version) def serialize(self): r = b"" - if len(self.vchCommitment) < 1: raise ValueError('invalid commitment') + if len(self.vchCommitment) < 1: + raise ValueError('invalid commitment') r += self.vchCommitment return r @@ -392,11 +403,16 @@ class CTxOutNonce(object): def deserialize(self, f): version = ord(f.read(1)) - if version == 0: self.vchCommitment = b'\x00' - elif version == 1: self.vchCommitment = b'\x01' + f.read(32) - elif version == 0xff: self.vchCommitment = b'\xff' + f.read(32) - elif version == 2 or version == 3: self.vchCommitment = bytes([version]) + f.read(32) - else: raise ValueError('invalid CTxOutNonce in deserialize') + if version == 0: + self.vchCommitment = b'\x00' + elif version == 1: + self.vchCommitment = b'\x01' + f.read(32) + elif version == 0xff: + self.vchCommitment = b'\xff' + f.read(32) + elif version == 2 or version == 3: + self.vchCommitment = bytes([version]) + f.read(32) + else: + raise ValueError('invalid CTxOutNonce in deserialize') def serialize(self): r = b"" diff --git a/test/functional/wallet_abandonconflict.py b/test/functional/wallet_abandonconflict.py index 0da869ad5e..63cae4364c 100755 --- a/test/functional/wallet_abandonconflict.py +++ b/test/functional/wallet_abandonconflict.py @@ -13,7 +13,7 @@ from decimal import Decimal from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes, disconnect_nodes, sync_blocks, sync_mempools, BITCOIN_ASSET +from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes, disconnect_nodes, sync_blocks, sync_mempools class AbandonConflictTest(BitcoinTestFramework): def set_test_params(self): diff --git a/test/functional/wallet_address_types.py b/test/functional/wallet_address_types.py index c700d56b75..f2ee2e37cb 100755 --- a/test/functional/wallet_address_types.py +++ b/test/functional/wallet_address_types.py @@ -61,7 +61,6 @@ from test_framework.util import ( connect_nodes_bi, sync_blocks, sync_mempools, - BITCOIN_ASSET, ) diff --git a/test/functional/wallet_backup.py b/test/functional/wallet_backup.py index ce6fb3e35b..cf613cf1c3 100755 --- a/test/functional/wallet_backup.py +++ b/test/functional/wallet_backup.py @@ -36,7 +36,7 @@ from random import randint import shutil from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes, sync_blocks, sync_mempools, BITCOIN_ASSET +from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes, sync_blocks, sync_mempools class WalletBackupTest(BitcoinTestFramework): def set_test_params(self): diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py index ff6213c99d..8044caa7d4 100755 --- a/test/functional/wallet_basic.py +++ b/test/functional/wallet_basic.py @@ -16,7 +16,6 @@ from test_framework.util import ( sync_blocks, sync_mempools, wait_until, - BITCOIN_ASSET, ) class WalletTest(BitcoinTestFramework): @@ -269,10 +268,10 @@ class WalletTest(BitcoinTestFramework): self.sync_all() unspent_txs = self.nodes[0].listunspent() # zero value tx must be in listunspents output - found = False + #found = False for uTx in unspent_txs: if uTx['txid'] == zero_value_txid: - found = True + #found = True assert_equal(uTx['amount'], Decimal('0')) # ELEMENTS: this test doesn't make sense #assert(found) diff --git a/test/functional/wallet_bumpfee.py b/test/functional/wallet_bumpfee.py index 4880fd2b72..0c3758bf35 100755 --- a/test/functional/wallet_bumpfee.py +++ b/test/functional/wallet_bumpfee.py @@ -19,7 +19,7 @@ from decimal import Decimal from test_framework.blocktools import add_witness_commitment, create_block, create_coinbase, send_to_witness from test_framework.messages import BIP125_SEQUENCE_NUMBER, CTransaction from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, assert_greater_than, assert_raises_rpc_error, bytes_to_hex_str, connect_nodes_bi, hex_str_to_bytes, sync_mempools, BITCOIN_ASSET +from test_framework.util import assert_equal, assert_greater_than, assert_raises_rpc_error, bytes_to_hex_str, connect_nodes_bi, hex_str_to_bytes, sync_mempools from test_framework import util import io diff --git a/test/functional/wallet_groups.py b/test/functional/wallet_groups.py index 5b6d65c18f..81bfe6c7e1 100755 --- a/test/functional/wallet_groups.py +++ b/test/functional/wallet_groups.py @@ -8,7 +8,6 @@ from test_framework.test_framework import BitcoinTestFramework from test_framework.messages import CTransaction, FromHex, ToHex from test_framework.util import ( assert_equal, - BITCOIN_ASSET, ) def assert_approx(v, vexp, vspan=0.00001): diff --git a/test/functional/wallet_hd.py b/test/functional/wallet_hd.py index 16ad1d2c5e..6d0f73d3b1 100755 --- a/test/functional/wallet_hd.py +++ b/test/functional/wallet_hd.py @@ -12,7 +12,6 @@ from test_framework.util import ( assert_equal, connect_nodes_bi, assert_raises_rpc_error, - BITCOIN_ASSET, ) diff --git a/test/functional/wallet_importprunedfunds.py b/test/functional/wallet_importprunedfunds.py index ef9ef34550..1d79ff5bec 100755 --- a/test/functional/wallet_importprunedfunds.py +++ b/test/functional/wallet_importprunedfunds.py @@ -9,7 +9,6 @@ from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( assert_equal, assert_raises_rpc_error, - BITCOIN_ASSET, ) class ImportPrunedFundsTest(BitcoinTestFramework): diff --git a/test/functional/wallet_keypool_topup.py b/test/functional/wallet_keypool_topup.py index e3978875d3..24638bea9d 100755 --- a/test/functional/wallet_keypool_topup.py +++ b/test/functional/wallet_keypool_topup.py @@ -18,7 +18,6 @@ from test_framework.util import ( assert_equal, connect_nodes_bi, sync_blocks, - BITCOIN_ASSET, ) diff --git a/test/functional/wallet_labels.py b/test/functional/wallet_labels.py index ecfe5ecb01..8f25d0e2d9 100755 --- a/test/functional/wallet_labels.py +++ b/test/functional/wallet_labels.py @@ -12,7 +12,7 @@ RPCs tested are: from collections import defaultdict from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, assert_raises_rpc_error, BITCOIN_ASSET +from test_framework.util import assert_equal, assert_raises_rpc_error class WalletLabelsTest(BitcoinTestFramework): def set_test_params(self): diff --git a/test/functional/wallet_multiwallet.py b/test/functional/wallet_multiwallet.py index 8a1581e4da..3a3a9274fd 100755 --- a/test/functional/wallet_multiwallet.py +++ b/test/functional/wallet_multiwallet.py @@ -14,7 +14,6 @@ from test_framework.test_node import ErrorMatch from test_framework.util import ( assert_equal, assert_raises_rpc_error, - BITCOIN_ASSET, ) diff --git a/test/functional/wallet_txn_clone.py b/test/functional/wallet_txn_clone.py index 3a9781de27..f0b23cbcfd 100755 --- a/test/functional/wallet_txn_clone.py +++ b/test/functional/wallet_txn_clone.py @@ -12,7 +12,6 @@ from test_framework.util import ( connect_nodes, disconnect_nodes, sync_blocks, - BITCOIN_ASSET, ) class TxnMallTest(BitcoinTestFramework): diff --git a/test/functional/wallet_txn_doublespend.py b/test/functional/wallet_txn_doublespend.py index b99a21506b..941bc849bd 100755 --- a/test/functional/wallet_txn_doublespend.py +++ b/test/functional/wallet_txn_doublespend.py @@ -12,7 +12,6 @@ from test_framework.util import ( disconnect_nodes, find_output, sync_blocks, - BITCOIN_ASSET, ) class TxnMallTest(BitcoinTestFramework):