[test] Fix flake8 warnings in tests
Fix all flake8 warnings in tests that are about to be updated to remove addwitnessaddress
This commit is contained in:
parent
920c090f63
commit
67d7d67cf3
5 changed files with 82 additions and 92 deletions
|
@ -12,6 +12,7 @@ Generate 427 more blocks.
|
|||
[Consensus] Check that the new NULLDUMMY rules are not enforced on the 431st block.
|
||||
[Policy/Consensus] Check that the new NULLDUMMY rules are enforced on the 432nd block.
|
||||
"""
|
||||
import time
|
||||
|
||||
from test_framework.blocktools import create_coinbase, create_block, create_transaction, add_witness_commitment
|
||||
from test_framework.messages import CTransaction
|
||||
|
@ -19,8 +20,6 @@ from test_framework.script import CScript
|
|||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_raises_rpc_error, bytes_to_hex_str
|
||||
|
||||
import time
|
||||
|
||||
NULLDUMMY_ERROR = "non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argument must be zero) (code 64)"
|
||||
|
||||
def trueDummy(tx):
|
||||
|
@ -99,7 +98,6 @@ class NULLDUMMYTest(BitcoinTestFramework):
|
|||
self.nodes[0].sendrawtransaction(bytes_to_hex_str(i.serialize_with_witness()), True)
|
||||
self.block_submit(self.nodes[0], test6txs, True, True)
|
||||
|
||||
|
||||
def block_submit(self, node, txs, witness=False, accept=False):
|
||||
block = create_block(self.tip, create_coinbase(self.lastblockheight + 1), self.lastblocktime + 1)
|
||||
block.nVersion = 4
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
"""Test the SegWit changeover logic."""
|
||||
|
||||
from decimal import Decimal
|
||||
from io import BytesIO
|
||||
|
||||
from test_framework.address import (
|
||||
key_to_p2pkh,
|
||||
|
@ -21,8 +22,6 @@ from test_framework.script import CScript, OP_HASH160, OP_CHECKSIG, OP_0, hash16
|
|||
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
|
||||
|
||||
from io import BytesIO
|
||||
|
||||
NODE_0 = 0
|
||||
NODE_2 = 2
|
||||
WIT_V0 = 0
|
||||
|
@ -91,7 +90,6 @@ class SegWitTest(BitcoinTestFramework):
|
|||
def fail_accept(self, node, error_msg, txid, sign, redeem_script=""):
|
||||
assert_raises_rpc_error(-26, error_msg, send_to_witness, use_p2wsh=1, node=node, utxo=getutxo(txid), pubkey=self.pubkey[0], encode_p2sh=False, amount=Decimal("49.998"), sign=sign, insert_redeem_script=redeem_script)
|
||||
|
||||
|
||||
def run_test(self):
|
||||
self.nodes[0].generate(161) # block 161
|
||||
|
||||
|
@ -282,8 +280,8 @@ class SegWitTest(BitcoinTestFramework):
|
|||
uncompressed_spendable_address = ["mvozP4UwyGD2mGZU4D2eMvMLPB9WkMmMQu"]
|
||||
self.nodes[0].importprivkey("cNC8eQ5dg3mFAVePDX4ddmPYpPbw41r9bm2jd1nLJT77e6RrzTRR")
|
||||
compressed_spendable_address = ["mmWQubrDomqpgSYekvsU7HWEVjLFHAakLe"]
|
||||
assert ((self.nodes[0].getaddressinfo(uncompressed_spendable_address[0])['iscompressed'] == False))
|
||||
assert ((self.nodes[0].getaddressinfo(compressed_spendable_address[0])['iscompressed'] == True))
|
||||
assert not self.nodes[0].getaddressinfo(uncompressed_spendable_address[0])['iscompressed']
|
||||
assert self.nodes[0].getaddressinfo(compressed_spendable_address[0])['iscompressed']
|
||||
|
||||
self.nodes[0].importpubkey(pubkeys[0])
|
||||
compressed_solvable_address = [key_to_p2pkh(pubkeys[0])]
|
||||
|
@ -599,7 +597,7 @@ class SegWitTest(BitcoinTestFramework):
|
|||
for i in self.nodes[0].listunspent():
|
||||
if (i['txid'] == txid):
|
||||
watchcount += 1
|
||||
if (i['spendable'] == True):
|
||||
if i['spendable']:
|
||||
spendcount += 1
|
||||
if (ismine == 2):
|
||||
assert_equal(spendcount, len(script_list))
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
Version 1 compact blocks are pre-segwit (txids)
|
||||
Version 2 compact blocks are post-segwit (wtxids)
|
||||
"""
|
||||
|
||||
from decimal import Decimal
|
||||
import random
|
||||
|
||||
|
@ -279,7 +278,7 @@ class CompactBlocksTest(BitcoinTestFramework):
|
|||
segwit_tx_generated = True
|
||||
|
||||
if use_witness_address:
|
||||
assert(segwit_tx_generated) # check that our test is not broken
|
||||
assert segwit_tx_generated # check that our test is not broken
|
||||
|
||||
# Wait until we've seen the block announcement for the resulting tip
|
||||
tip = int(node.getbestblockhash(), 16)
|
||||
|
@ -403,8 +402,7 @@ class CompactBlocksTest(BitcoinTestFramework):
|
|||
coinbase_hash = block.vtx[0].sha256
|
||||
if version == 2:
|
||||
coinbase_hash = block.vtx[0].calc_sha256(True)
|
||||
comp_block.shortids = [
|
||||
calculate_shortid(k0, k1, coinbase_hash) ]
|
||||
comp_block.shortids = [calculate_shortid(k0, k1, coinbase_hash)]
|
||||
test_node.send_and_ping(msg_cmpctblock(comp_block.to_p2p()))
|
||||
assert_equal(int(node.getbestblockhash(), 16), block.hashPrevBlock)
|
||||
# Expect a getblocktxn message.
|
||||
|
|
|
@ -13,20 +13,17 @@ can be disabled or reordered if needed for debugging. If new test cases are
|
|||
added in the future, they should try to follow the same convention and not
|
||||
make assumptions about execution order.
|
||||
"""
|
||||
|
||||
from decimal import Decimal
|
||||
import io
|
||||
|
||||
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
|
||||
|
||||
import io
|
||||
|
||||
WALLET_PASSPHRASE = "test"
|
||||
WALLET_PASSPHRASE_TIMEOUT = 3600
|
||||
|
||||
|
||||
class BumpFeeTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 2
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
"""Test the dumpwallet RPC."""
|
||||
|
||||
import os
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
|
@ -155,13 +154,13 @@ class WalletDumpTest(BitcoinTestFramework):
|
|||
|
||||
# Make sure the address is not IsMine before import
|
||||
result = self.nodes[0].getaddressinfo(multisig_addr)
|
||||
assert(result['ismine'] == False)
|
||||
assert not result['ismine']
|
||||
|
||||
self.nodes[0].importwallet(wallet_unenc_dump)
|
||||
|
||||
# Now check IsMine is true
|
||||
result = self.nodes[0].getaddressinfo(multisig_addr)
|
||||
assert(result['ismine'] == True)
|
||||
assert result['ismine']
|
||||
|
||||
if __name__ == '__main__':
|
||||
WalletDumpTest().main()
|
||||
|
|
Loading…
Reference in a new issue