Skip to content

Commit

Permalink
Remove unused variables and/or function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
practicalswift committed Aug 28, 2017
1 parent 9b94054 commit 2e6080b
Show file tree
Hide file tree
Showing 18 changed files with 29 additions and 360 deletions.
2 changes: 1 addition & 1 deletion test/functional/bip68-sequence.py
Expand Up @@ -387,7 +387,7 @@ def test_version2_relay(self):
tx = FromHex(CTransaction(), rawtxfund)
tx.nVersion = 2
tx_signed = self.nodes[1].signrawtransaction(ToHex(tx))["hex"]
tx_id = self.nodes[1].sendrawtransaction(tx_signed)
self.nodes[1].sendrawtransaction(tx_signed)

if __name__ == '__main__':
BIP68Test().main()
2 changes: 1 addition & 1 deletion test/functional/bumpfee.py
Expand Up @@ -167,7 +167,7 @@ def test_bumpfee_with_descendant_fails(rbf_node, rbf_node_address, dest_address)
parent_id = spend_one_input(rbf_node, rbf_node_address)
tx = rbf_node.createrawtransaction([{"txid": parent_id, "vout": 0}], {dest_address: 0.00020000})
tx = rbf_node.signrawtransaction(tx)
txid = rbf_node.sendrawtransaction(tx["hex"])
rbf_node.sendrawtransaction(tx["hex"])
assert_raises_jsonrpc(-8, "Transaction has descendants in the wallet", rbf_node.bumpfee, parent_id)


Expand Down
1 change: 0 additions & 1 deletion test/functional/fundrawtransaction.py
Expand Up @@ -312,7 +312,6 @@ def run_test(self):
##############################################
# test a fundrawtransaction with invalid vin #
##############################################
listunspent = self.nodes[2].listunspent()
inputs = [ {'txid' : "1c7f966dab21119bac53213a2bc7532bff1fa844c124fd750a7d0b1332440bd1", 'vout' : 0} ] #invalid vin!
outputs = { self.nodes[0].getnewaddress() : 1.0}
rawtx = self.nodes[2].createrawtransaction(inputs, outputs)
Expand Down
1 change: 0 additions & 1 deletion test/functional/import-rescan.py
Expand Up @@ -161,7 +161,6 @@ def run_test(self):
variant.check()

# Create new transactions sending to each address.
fee = self.nodes[0].getnetworkinfo()["relayfee"]
for i, variant in enumerate(IMPORT_VARIANTS):
variant.sent_amount = 10 - (2 * i + 1) / 8.0
variant.sent_txid = self.nodes[0].sendtoaddress(variant.address["address"], variant.sent_amount)
Expand Down
13 changes: 0 additions & 13 deletions test/functional/importmulti.py
Expand Up @@ -21,16 +21,7 @@ def run_test (self):
self.nodes[1].generate(1)
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']

# keyword definition
PRIV_KEY = 'privkey'
PUB_KEY = 'pubkey'
ADDRESS_KEY = 'address'
SCRIPT_KEY = 'script'


node0_address1 = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
node0_address2 = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
node0_address3 = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())

#Check only one address
assert_equal(node0_address1['ismine'], True)
Expand Down Expand Up @@ -230,7 +221,6 @@ def run_test (self):
transactionid = self.nodes[1].sendtoaddress(multi_sig_script['address'], 10.00)
self.nodes[1].generate(1)
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
transaction = self.nodes[1].gettransaction(transactionid)

self.log.info("Should import a p2sh")
result = self.nodes[1].importmulti([{
Expand Down Expand Up @@ -258,7 +248,6 @@ def run_test (self):
transactionid = self.nodes[1].sendtoaddress(multi_sig_script['address'], 10.00)
self.nodes[1].generate(1)
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
transaction = self.nodes[1].gettransaction(transactionid)

self.log.info("Should import a p2sh with respective redeem script")
result = self.nodes[1].importmulti([{
Expand Down Expand Up @@ -286,7 +275,6 @@ def run_test (self):
transactionid = self.nodes[1].sendtoaddress(multi_sig_script['address'], 10.00)
self.nodes[1].generate(1)
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
transaction = self.nodes[1].gettransaction(transactionid)

self.log.info("Should import a p2sh with respective redeem script and private keys")
result = self.nodes[1].importmulti([{
Expand Down Expand Up @@ -314,7 +302,6 @@ def run_test (self):
transactionid = self.nodes[1].sendtoaddress(multi_sig_script['address'], 10.00)
self.nodes[1].generate(1)
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
transaction = self.nodes[1].gettransaction(transactionid)

self.log.info("Should import a p2sh with respective redeem script and private keys")
result = self.nodes[1].importmulti([{
Expand Down
5 changes: 2 additions & 3 deletions test/functional/importprunedfunds.py
Expand Up @@ -24,7 +24,6 @@ def run_test(self):
address1 = self.nodes[0].getnewaddress()
# pubkey
address2 = self.nodes[0].getnewaddress()
address2_pubkey = self.nodes[0].validateaddress(address2)['pubkey'] # Using pubkey
# privkey
address3 = self.nodes[0].getnewaddress()
address3_privkey = self.nodes[0].dumpprivkey(address3) # Using privkey
Expand Down Expand Up @@ -77,13 +76,13 @@ def run_test(self):

#Import with affiliated address with no rescan
self.nodes[1].importaddress(address2, "add2", False)
result2 = self.nodes[1].importprunedfunds(rawtxn2, proof2)
self.nodes[1].importprunedfunds(rawtxn2, proof2)
balance2 = self.nodes[1].getbalance("add2", 0, True)
assert_equal(balance2, Decimal('0.05'))

#Import with private key with no rescan
self.nodes[1].importprivkey(address3_privkey, "add3", False)
result3 = self.nodes[1].importprunedfunds(rawtxn3, proof3)
self.nodes[1].importprunedfunds(rawtxn3, proof3)
balance3 = self.nodes[1].getbalance("add3", 0, False)
assert_equal(balance3, Decimal('0.025'))
balance3 = self.nodes[1].getbalance("*", 0, True)
Expand Down
18 changes: 9 additions & 9 deletions test/functional/p2p-fullblocktest.py
Expand Up @@ -397,7 +397,7 @@ def update_block(block_number, new_transactions):
yield rejected(RejectResult(16, b'bad-cb-length'))

# Extend the b26 chain to make sure bitcoind isn't accepting b26
b27 = block(27, spend=out[7])
block(27, spend=out[7])
yield rejected(False)

# Now try a too-large-coinbase script
Expand All @@ -409,7 +409,7 @@ def update_block(block_number, new_transactions):
yield rejected(RejectResult(16, b'bad-cb-length'))

# Extend the b28 chain to make sure bitcoind isn't accepting b28
b29 = block(29, spend=out[7])
block(29, spend=out[7])
yield rejected(False)

# b30 has a max-sized coinbase scriptSig.
Expand Down Expand Up @@ -581,7 +581,7 @@ def update_block(block_number, new_transactions):

# same as b40, but one less sigop
tip(39)
b41 = block(41, spend=None)
block(41, spend=None)
update_block(41, b40.vtx[1:-1])
b41_sigops_to_fill = b40_sigops_to_fill - 1
tx = CTransaction()
Expand Down Expand Up @@ -927,7 +927,7 @@ def update_block(block_number, new_transactions):
# -> b42 (12) -> b43 (13) -> b53 (14) -> b55 (15) -> b57 (16) -> b60 (17) -> b64 (18) -> b65 (19)
#
tip(64)
b65 = block(65)
block(65)
tx1 = create_and_sign_tx(out[19].tx, out[19].n, out[19].tx.vout[0].nValue)
tx2 = create_and_sign_tx(tx1, 0, 0)
update_block(65, [tx1, tx2])
Expand All @@ -939,7 +939,7 @@ def update_block(block_number, new_transactions):
# -> b43 (13) -> b53 (14) -> b55 (15) -> b57 (16) -> b60 (17) -> b64 (18) -> b65 (19)
# \-> b66 (20)
tip(65)
b66 = block(66)
block(66)
tx1 = create_and_sign_tx(out[20].tx, out[20].n, out[20].tx.vout[0].nValue)
tx2 = create_and_sign_tx(tx1, 0, 1)
update_block(66, [tx2, tx1])
Expand All @@ -952,7 +952,7 @@ def update_block(block_number, new_transactions):
#
#
tip(65)
b67 = block(67)
block(67)
tx1 = create_and_sign_tx(out[20].tx, out[20].n, out[20].tx.vout[0].nValue)
tx2 = create_and_sign_tx(tx1, 0, 1)
tx3 = create_and_sign_tx(tx1, 0, 2)
Expand All @@ -972,7 +972,7 @@ def update_block(block_number, new_transactions):
# this succeeds
#
tip(65)
b68 = block(68, additional_coinbase_value=10)
block(68, additional_coinbase_value=10)
tx = create_and_sign_tx(out[20].tx, out[20].n, out[20].tx.vout[0].nValue-9)
update_block(68, [tx])
yield rejected(RejectResult(16, b'bad-cb-amount'))
Expand Down Expand Up @@ -1175,7 +1175,7 @@ def update_block(block_number, new_transactions):
#
# -> b81 (26) -> b82 (27) -> b83 (28)
#
b83 = block(83)
block(83)
op_codes = [OP_IF, OP_INVALIDOPCODE, OP_ELSE, OP_TRUE, OP_ENDIF]
script = CScript(op_codes)
tx1 = create_and_sign_tx(out[28].tx, out[28].n, out[28].tx.vout[0].nValue, script)
Expand All @@ -1195,7 +1195,7 @@ def update_block(block_number, new_transactions):
# \-> b85 (29) -> b86 (30) \-> b89a (32)
#
#
b84 = block(84)
block(84)
tx1 = create_tx(out[29].tx, out[29].n, 0, CScript([OP_RETURN]))
tx1.vout.append(CTxOut(0, CScript([OP_TRUE])))
tx1.vout.append(CTxOut(0, CScript([OP_TRUE])))
Expand Down
1 change: 0 additions & 1 deletion test/functional/p2p-segwit.py
Expand Up @@ -17,7 +17,6 @@
# The versionbit bit used to signal activation of SegWit
VB_WITNESS_BIT = 1
VB_PERIOD = 144
VB_ACTIVATION_THRESHOLD = 108
VB_TOP_BITS = 0x20000000

MAX_SIGOP_COST = 80000
Expand Down
2 changes: 0 additions & 2 deletions test/functional/rawtransactions.py
Expand Up @@ -63,7 +63,6 @@ def run_test(self):
addr2Obj = self.nodes[2].validateaddress(addr2)

mSigObj = self.nodes[2].addmultisigaddress(2, [addr1Obj['pubkey'], addr2Obj['pubkey']])
mSigObjValid = self.nodes[2].validateaddress(mSigObj)

#use balance deltas instead of absolute values
bal = self.nodes[2].getbalance()
Expand All @@ -87,7 +86,6 @@ def run_test(self):
addr3Obj = self.nodes[2].validateaddress(addr3)

mSigObj = self.nodes[2].addmultisigaddress(2, [addr1Obj['pubkey'], addr2Obj['pubkey'], addr3Obj['pubkey']])
mSigObjValid = self.nodes[2].validateaddress(mSigObj)

txId = self.nodes[0].sendtoaddress(mSigObj, 2.2)
decTx = self.nodes[0].gettransaction(txId)
Expand Down
6 changes: 3 additions & 3 deletions test/functional/replace-by-fee.py
Expand Up @@ -270,7 +270,7 @@ def test_replacement_feeperkb(self):
tx1a.vin = [CTxIn(tx0_outpoint, nSequence=0)]
tx1a.vout = [CTxOut(1*COIN, CScript([b'a']))]
tx1a_hex = txToHex(tx1a)
tx1a_txid = self.nodes[0].sendrawtransaction(tx1a_hex, True)
self.nodes[0].sendrawtransaction(tx1a_hex, True)

# Higher fee, but the fee per KB is much lower, so the replacement is
# rejected.
Expand Down Expand Up @@ -331,7 +331,7 @@ def test_new_unconfirmed_inputs(self):
tx1.vin = [CTxIn(confirmed_utxo)]
tx1.vout = [CTxOut(1*COIN, CScript([b'a']))]
tx1_hex = txToHex(tx1)
tx1_txid = self.nodes[0].sendrawtransaction(tx1_hex, True)
self.nodes[0].sendrawtransaction(tx1_hex, True)

tx2 = CTransaction()
tx2.vin = [CTxIn(confirmed_utxo), CTxIn(unconfirmed_utxo)]
Expand Down Expand Up @@ -499,7 +499,7 @@ def test_prioritised_transactions(self):
tx2a.vin = [CTxIn(tx1_outpoint, nSequence=0)]
tx2a.vout = [CTxOut(1*COIN, CScript([b'a']))]
tx2a_hex = txToHex(tx2a)
tx2a_txid = self.nodes[0].sendrawtransaction(tx2a_hex, True)
self.nodes[0].sendrawtransaction(tx2a_hex, True)

# Lower fee, but we'll prioritise it
tx2b = CTransaction()
Expand Down
1 change: 0 additions & 1 deletion test/functional/segwit.py
Expand Up @@ -12,7 +12,6 @@
from io import BytesIO

NODE_0 = 0
NODE_1 = 1
NODE_2 = 2
WIT_V0 = 0
WIT_V1 = 1
Expand Down
10 changes: 0 additions & 10 deletions test/functional/test_framework/address.py
Expand Up @@ -44,16 +44,6 @@ def script_to_p2sh(script, main = False):
script = check_script(script)
return scripthash_to_p2sh(hash160(script), main)

def key_to_p2sh_p2wpkh(key, main = False):
key = check_key(key)
p2shscript = CScript([OP_0, hash160(key)])
return script_to_p2sh(p2shscript, main)

def script_to_p2sh_p2wsh(script, main = False):
script = check_script(script)
p2shscript = CScript([OP_0, sha256(script)])
return script_to_p2sh(p2shscript, main)

def check_key(key):
if (type(key) is str):
key = hex_str_to_bytes(key) # Assuming this is hex string
Expand Down
39 changes: 0 additions & 39 deletions test/functional/test_framework/bignum.py
Expand Up @@ -26,12 +26,6 @@ def bn2bin(v):
i -= 1
return s

def bin2bn(s):
l = 0
for ch in s:
l = (l << 8) | ch
return l

def bn2mpi(v):
have_ext = False
if v.bit_length() > 0:
Expand All @@ -54,30 +48,6 @@ def bn2mpi(v):
v_bin[0] |= 0x80
return s + ext + v_bin

def mpi2bn(s):
if len(s) < 4:
return None
s_size = bytes(s[:4])
v_len = struct.unpack(b">I", s_size)[0]
if len(s) != (v_len + 4):
return None
if v_len == 0:
return 0

v_str = bytearray(s[4:])
neg = False
i = v_str[0]
if i & 0x80:
neg = True
i &= ~0x80
v_str[0] = i

v = bin2bn(v_str)

if neg:
return -v
return v

# bitcoin-specific little endian format, with implicit size
def mpi2vch(s):
r = s[4:] # strip size
Expand All @@ -86,12 +56,3 @@ def mpi2vch(s):

def bn2vch(v):
return bytes(mpi2vch(bn2mpi(v)))

def vch2mpi(s):
r = struct.pack(b">I", len(s)) # size
r += s[::-1] # reverse string, converting LE->BE
return r

def vch2bn(s):
return mpi2bn(vch2mpi(s))

10 changes: 0 additions & 10 deletions test/functional/test_framework/blockstore.py
Expand Up @@ -143,16 +143,6 @@ def get(self, txhash):
return None
return value

def get_transaction(self, txhash):
ret = None
serialized_tx = self.get(txhash)
if serialized_tx is not None:
f = BytesIO(serialized_tx)
ret = CTransaction()
ret.deserialize(f)
ret.calc_sha256()
return ret

def add_transaction(self, tx):
tx.calc_sha256()
try:
Expand Down
11 changes: 2 additions & 9 deletions test/functional/test_framework/mininode.py
Expand Up @@ -48,8 +48,8 @@
COIN = 100000000 # 1 btc in satoshis

NODE_NETWORK = (1 << 0)
NODE_GETUTXO = (1 << 1)
NODE_BLOOM = (1 << 2)
# NODE_GETUTXO = (1 << 1)
# NODE_BLOOM = (1 << 2)
NODE_WITNESS = (1 << 3)
NODE_UNSUPPORTED_SERVICE_BIT_5 = (1 << 5)
NODE_UNSUPPORTED_SERVICE_BIT_7 = (1 << 7)
Expand Down Expand Up @@ -1479,9 +1479,6 @@ def __init__(self):
# before acquiring the global lock and delivering the next message.
self.deliver_sleep_time = None

# Remember the services our peer has advertised
self.peer_services = None

# Message receiving methods

def deliver(self, conn, message):
Expand All @@ -1506,10 +1503,6 @@ def deliver(self, conn, message):
print("ERROR delivering %s (%s)" % (repr(message),
sys.exc_info()[0]))

def set_deliver_sleep_time(self, value):
with mininode_lock:
self.deliver_sleep_time = value

def get_deliver_sleep_time(self):
with mininode_lock:
return self.deliver_sleep_time
Expand Down
20 changes: 10 additions & 10 deletions test/functional/test_framework/netutil.py
Expand Up @@ -15,17 +15,17 @@
import os
from binascii import unhexlify, hexlify

STATE_ESTABLISHED = '01'
STATE_SYN_SENT = '02'
STATE_SYN_RECV = '03'
STATE_FIN_WAIT1 = '04'
STATE_FIN_WAIT2 = '05'
STATE_TIME_WAIT = '06'
STATE_CLOSE = '07'
STATE_CLOSE_WAIT = '08'
STATE_LAST_ACK = '09'
# STATE_ESTABLISHED = '01'
# STATE_SYN_SENT = '02'
# STATE_SYN_RECV = '03'
# STATE_FIN_WAIT1 = '04'
# STATE_FIN_WAIT2 = '05'
# STATE_TIME_WAIT = '06'
# STATE_CLOSE = '07'
# STATE_CLOSE_WAIT = '08'
# STATE_LAST_ACK = '09'
STATE_LISTEN = '0A'
STATE_CLOSING = '0B'
# STATE_CLOSING = '0B'

def get_socket_inodes(pid):
'''
Expand Down

0 comments on commit 2e6080b

Please sign in to comment.