[qa] rpc-tests: Properly use integers, floats

This commit is contained in:
MarcoFalke 2016-03-20 18:18:32 +01:00
parent fa524d9ddb
commit fa2cea163b
15 changed files with 45 additions and 45 deletions

View file

@ -70,7 +70,7 @@ class BIP65Test(ComparisonTestFramework):
height = 3 # height of the next block to build height = 3 # height of the next block to build
self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0) self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
self.nodeaddress = self.nodes[0].getnewaddress() self.nodeaddress = self.nodes[0].getnewaddress()
self.last_block_time = time.time() self.last_block_time = int(time.time())
''' 98 more version 3 blocks ''' ''' 98 more version 3 blocks '''
test_blocks = [] test_blocks = []

View file

@ -61,7 +61,7 @@ class BIP68Test(BitcoinTestFramework):
utxo = utxos[0] utxo = utxos[0]
tx1 = CTransaction() tx1 = CTransaction()
value = satoshi_round(utxo["amount"] - self.relayfee)*COIN value = int(satoshi_round(utxo["amount"] - self.relayfee)*COIN)
# Check that the disable flag disables relative locktime. # Check that the disable flag disables relative locktime.
# If sequence locks were used, this would require 1 block for the # If sequence locks were used, this would require 1 block for the
@ -179,8 +179,8 @@ class BIP68Test(BitcoinTestFramework):
tx.vin.append(CTxIn(COutPoint(int(utxos[j]["txid"], 16), utxos[j]["vout"]), nSequence=sequence_value)) tx.vin.append(CTxIn(COutPoint(int(utxos[j]["txid"], 16), utxos[j]["vout"]), nSequence=sequence_value))
value += utxos[j]["amount"]*COIN value += utxos[j]["amount"]*COIN
# Overestimate the size of the tx - signatures should be less than 120 bytes, and leave 50 for the output # Overestimate the size of the tx - signatures should be less than 120 bytes, and leave 50 for the output
tx_size = len(ToHex(tx))/2 + 120*num_inputs + 50 tx_size = len(ToHex(tx))//2 + 120*num_inputs + 50
tx.vout.append(CTxOut(value-self.relayfee*tx_size*COIN/1000, CScript([b'a']))) tx.vout.append(CTxOut(int(value-self.relayfee*tx_size*COIN/1000), CScript([b'a'])))
rawtx = self.nodes[0].signrawtransaction(ToHex(tx))["hex"] rawtx = self.nodes[0].signrawtransaction(ToHex(tx))["hex"]
try: try:

View file

@ -91,7 +91,7 @@ class BIP9SoftForksTest(ComparisonTestFramework):
self.height = 3 # height of the next block to build self.height = 3 # height of the next block to build
self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0) self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
self.nodeaddress = self.nodes[0].getnewaddress() self.nodeaddress = self.nodes[0].getnewaddress()
self.last_block_time = time.time() self.last_block_time = int(time.time())
assert_equal(self.get_bip9_status(bipName)['status'], 'defined') assert_equal(self.get_bip9_status(bipName)['status'], 'defined')

View file

@ -78,7 +78,7 @@ class BIP66Test(ComparisonTestFramework):
height = 3 # height of the next block to build height = 3 # height of the next block to build
self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0) self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
self.nodeaddress = self.nodes[0].getnewaddress() self.nodeaddress = self.nodes[0].getnewaddress()
self.last_block_time = time.time() self.last_block_time = int(time.time())
''' 98 more version 2 blocks ''' ''' 98 more version 2 blocks '''
test_blocks = [] test_blocks = []

View file

@ -48,7 +48,7 @@ class RawTransactionsTest(BitcoinTestFramework):
watchonly_address = self.nodes[0].getnewaddress() watchonly_address = self.nodes[0].getnewaddress()
watchonly_pubkey = self.nodes[0].validateaddress(watchonly_address)["pubkey"] watchonly_pubkey = self.nodes[0].validateaddress(watchonly_address)["pubkey"]
watchonly_amount = 200 watchonly_amount = Decimal(200)
self.nodes[3].importpubkey(watchonly_pubkey, "", True) self.nodes[3].importpubkey(watchonly_pubkey, "", True)
watchonly_txid = self.nodes[0].sendtoaddress(watchonly_address, watchonly_amount) watchonly_txid = self.nodes[0].sendtoaddress(watchonly_address, watchonly_amount)
self.nodes[0].sendtoaddress(self.nodes[3].getnewaddress(), watchonly_amount / 10) self.nodes[0].sendtoaddress(self.nodes[3].getnewaddress(), watchonly_amount / 10)

View file

@ -192,7 +192,7 @@ class ListTransactionsTest(BitcoinTestFramework):
# Replace tx3, and check that tx4 becomes unknown # Replace tx3, and check that tx4 becomes unknown
tx3_b = tx3_modified tx3_b = tx3_modified
tx3_b.vout[0].nValue -= 0.004 * COIN # bump the fee tx3_b.vout[0].nValue -= int(Decimal("0.004") * COIN) # bump the fee
tx3_b = binascii.hexlify(tx3_b.serialize()).decode('utf-8') tx3_b = binascii.hexlify(tx3_b.serialize()).decode('utf-8')
tx3_b_signed = self.nodes[0].signrawtransaction(tx3_b)['hex'] tx3_b_signed = self.nodes[0].signrawtransaction(tx3_b)['hex']
txid_3b = self.nodes[0].sendrawtransaction(tx3_b_signed, True) txid_3b = self.nodes[0].sendrawtransaction(tx3_b_signed, True)

View file

@ -177,7 +177,7 @@ class MaxUploadTest(BitcoinTestFramework):
max_bytes_per_day = 200*1024*1024 max_bytes_per_day = 200*1024*1024
daily_buffer = 144 * MAX_BLOCK_SIZE daily_buffer = 144 * MAX_BLOCK_SIZE
max_bytes_available = max_bytes_per_day - daily_buffer max_bytes_available = max_bytes_per_day - daily_buffer
success_count = max_bytes_available / old_block_size success_count = max_bytes_available // old_block_size
# 144MB will be reserved for relaying new blocks, so expect this to # 144MB will be reserved for relaying new blocks, so expect this to
# succeed for ~70 tries. # succeed for ~70 tries.

View file

@ -150,7 +150,7 @@ class AcceptBlockTest(BitcoinTestFramework):
# 2. Send one block that builds on each tip. # 2. Send one block that builds on each tip.
# This should be accepted. # This should be accepted.
blocks_h2 = [] # the height 2 blocks on each node's chain blocks_h2 = [] # the height 2 blocks on each node's chain
block_time = time.time() + 1 block_time = int(time.time()) + 1
for i in xrange(2): for i in xrange(2):
blocks_h2.append(create_block(tips[i], create_coinbase(2), block_time)) blocks_h2.append(create_block(tips[i], create_coinbase(2), block_time))
blocks_h2[i].solve() blocks_h2[i].solve()

View file

@ -269,7 +269,7 @@ class FullBlockTest(ComparisonTestFramework):
# \-> b3 (1) -> b4 (2) # \-> b3 (1) -> b4 (2)
# Test that a block with a lot of checksigs is okay # Test that a block with a lot of checksigs is okay
lots_of_checksigs = CScript([OP_CHECKSIG] * (1000000 / 50 - 1)) lots_of_checksigs = CScript([OP_CHECKSIG] * (1000000 // 50 - 1))
tip(13) tip(13)
block(15, spend=out5, script=lots_of_checksigs) block(15, spend=out5, script=lots_of_checksigs)
yield accepted() yield accepted()
@ -277,7 +277,7 @@ class FullBlockTest(ComparisonTestFramework):
# Test that a block with too many checksigs is rejected # Test that a block with too many checksigs is rejected
out6 = get_spendable_output() out6 = get_spendable_output()
too_many_checksigs = CScript([OP_CHECKSIG] * (1000000 / 50)) too_many_checksigs = CScript([OP_CHECKSIG] * (1000000 // 50))
block(16, spend=out6, script=too_many_checksigs) block(16, spend=out6, script=too_many_checksigs)
yield rejected(RejectResult(16, 'bad-blk-sigops')) yield rejected(RejectResult(16, 'bad-blk-sigops'))

View file

@ -15,7 +15,7 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.util import *
def calc_usage(blockdir): def calc_usage(blockdir):
return sum(os.path.getsize(blockdir+f) for f in os.listdir(blockdir) if os.path.isfile(blockdir+f))/(1024*1024) return sum(os.path.getsize(blockdir+f) for f in os.listdir(blockdir) if os.path.isfile(blockdir+f)) / (1024. * 1024.)
class PruneTest(BitcoinTestFramework): class PruneTest(BitcoinTestFramework):
@ -56,7 +56,7 @@ class PruneTest(BitcoinTestFramework):
self.nodes[1].generate(200) self.nodes[1].generate(200)
sync_blocks(self.nodes[0:2]) sync_blocks(self.nodes[0:2])
self.nodes[0].generate(150) self.nodes[0].generate(150)
# Then mine enough full blocks to create more than 550MB of data # Then mine enough full blocks to create more than 550MiB of data
for i in xrange(645): for i in xrange(645):
self.mine_full_block(self.nodes[0], self.address[0]) self.mine_full_block(self.nodes[0], self.address[0])
@ -66,7 +66,7 @@ class PruneTest(BitcoinTestFramework):
if not os.path.isfile(self.prunedir+"blk00000.dat"): if not os.path.isfile(self.prunedir+"blk00000.dat"):
raise AssertionError("blk00000.dat is missing, pruning too early") raise AssertionError("blk00000.dat is missing, pruning too early")
print "Success" print "Success"
print "Though we're already using more than 550MB, current usage:", calc_usage(self.prunedir) print "Though we're already using more than 550MiB, current usage:", calc_usage(self.prunedir)
print "Mining 25 more blocks should cause the first block file to be pruned" print "Mining 25 more blocks should cause the first block file to be pruned"
# Pruning doesn't run until we're allocating another chunk, 20 full blocks past the height cutoff will ensure this # Pruning doesn't run until we're allocating another chunk, 20 full blocks past the height cutoff will ensure this
for i in xrange(25): for i in xrange(25):

View file

@ -119,7 +119,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
def test_simple_doublespend(self): def test_simple_doublespend(self):
"""Simple doublespend""" """Simple doublespend"""
tx0_outpoint = make_utxo(self.nodes[0], 1.1*COIN) tx0_outpoint = make_utxo(self.nodes[0], int(1.1*COIN))
tx1a = CTransaction() tx1a = CTransaction()
tx1a.vin = [CTxIn(tx0_outpoint, nSequence=0)] tx1a.vin = [CTxIn(tx0_outpoint, nSequence=0)]
@ -143,7 +143,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
# Extra 0.1 BTC fee # Extra 0.1 BTC fee
tx1b = CTransaction() tx1b = CTransaction()
tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)] tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)]
tx1b.vout = [CTxOut(0.9*COIN, CScript([b'b']))] tx1b.vout = [CTxOut(int(0.9*COIN), CScript([b'b']))]
tx1b_hex = txToHex(tx1b) tx1b_hex = txToHex(tx1b)
tx1b_txid = self.nodes[0].sendrawtransaction(tx1b_hex, True) tx1b_txid = self.nodes[0].sendrawtransaction(tx1b_hex, True)
@ -235,7 +235,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
_total_txs=_total_txs): _total_txs=_total_txs):
yield x yield x
fee = 0.0001*COIN fee = int(0.0001*COIN)
n = MAX_REPLACEMENT_LIMIT n = MAX_REPLACEMENT_LIMIT
tree_txs = list(branch(tx0_outpoint, initial_nValue, n, fee=fee)) tree_txs = list(branch(tx0_outpoint, initial_nValue, n, fee=fee))
assert_equal(len(tree_txs), n) assert_equal(len(tree_txs), n)
@ -268,7 +268,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
# Try again, but with more total transactions than the "max txs # Try again, but with more total transactions than the "max txs
# double-spent at once" anti-DoS limit. # double-spent at once" anti-DoS limit.
for n in (MAX_REPLACEMENT_LIMIT+1, MAX_REPLACEMENT_LIMIT*2): for n in (MAX_REPLACEMENT_LIMIT+1, MAX_REPLACEMENT_LIMIT*2):
fee = 0.0001*COIN fee = int(0.0001*COIN)
tx0_outpoint = make_utxo(self.nodes[0], initial_nValue) tx0_outpoint = make_utxo(self.nodes[0], initial_nValue)
tree_txs = list(branch(tx0_outpoint, initial_nValue, n, fee=fee)) tree_txs = list(branch(tx0_outpoint, initial_nValue, n, fee=fee))
assert_equal(len(tree_txs), n) assert_equal(len(tree_txs), n)
@ -291,7 +291,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
def test_replacement_feeperkb(self): def test_replacement_feeperkb(self):
"""Replacement requires fee-per-KB to be higher""" """Replacement requires fee-per-KB to be higher"""
tx0_outpoint = make_utxo(self.nodes[0], 1.1*COIN) tx0_outpoint = make_utxo(self.nodes[0], int(1.1*COIN))
tx1a = CTransaction() tx1a = CTransaction()
tx1a.vin = [CTxIn(tx0_outpoint, nSequence=0)] tx1a.vin = [CTxIn(tx0_outpoint, nSequence=0)]
@ -303,7 +303,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
# rejected. # rejected.
tx1b = CTransaction() tx1b = CTransaction()
tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)] tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)]
tx1b.vout = [CTxOut(0.001*COIN, CScript([b'a'*999000]))] tx1b.vout = [CTxOut(int(0.001*COIN), CScript([b'a'*999000]))]
tx1b_hex = txToHex(tx1b) tx1b_hex = txToHex(tx1b)
try: try:
@ -315,12 +315,12 @@ class ReplaceByFeeTest(BitcoinTestFramework):
def test_spends_of_conflicting_outputs(self): def test_spends_of_conflicting_outputs(self):
"""Replacements that spend conflicting tx outputs are rejected""" """Replacements that spend conflicting tx outputs are rejected"""
utxo1 = make_utxo(self.nodes[0], 1.2*COIN) utxo1 = make_utxo(self.nodes[0], int(1.2*COIN))
utxo2 = make_utxo(self.nodes[0], 3.0*COIN) utxo2 = make_utxo(self.nodes[0], 3*COIN)
tx1a = CTransaction() tx1a = CTransaction()
tx1a.vin = [CTxIn(utxo1, nSequence=0)] tx1a.vin = [CTxIn(utxo1, nSequence=0)]
tx1a.vout = [CTxOut(1.1*COIN, CScript([b'a']))] tx1a.vout = [CTxOut(int(1.1*COIN), CScript([b'a']))]
tx1a_hex = txToHex(tx1a) tx1a_hex = txToHex(tx1a)
tx1a_txid = self.nodes[0].sendrawtransaction(tx1a_hex, True) tx1a_txid = self.nodes[0].sendrawtransaction(tx1a_hex, True)
@ -343,7 +343,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
# Spend tx1a's output to test the indirect case. # Spend tx1a's output to test the indirect case.
tx1b = CTransaction() tx1b = CTransaction()
tx1b.vin = [CTxIn(COutPoint(tx1a_txid, 0), nSequence=0)] tx1b.vin = [CTxIn(COutPoint(tx1a_txid, 0), nSequence=0)]
tx1b.vout = [CTxOut(1.0*COIN, CScript([b'a']))] tx1b.vout = [CTxOut(1*COIN, CScript([b'a']))]
tx1b_hex = txToHex(tx1b) tx1b_hex = txToHex(tx1b)
tx1b_txid = self.nodes[0].sendrawtransaction(tx1b_hex, True) tx1b_txid = self.nodes[0].sendrawtransaction(tx1b_hex, True)
tx1b_txid = int(tx1b_txid, 16) tx1b_txid = int(tx1b_txid, 16)
@ -363,12 +363,12 @@ class ReplaceByFeeTest(BitcoinTestFramework):
def test_new_unconfirmed_inputs(self): def test_new_unconfirmed_inputs(self):
"""Replacements that add new unconfirmed inputs are rejected""" """Replacements that add new unconfirmed inputs are rejected"""
confirmed_utxo = make_utxo(self.nodes[0], 1.1*COIN) confirmed_utxo = make_utxo(self.nodes[0], int(1.1*COIN))
unconfirmed_utxo = make_utxo(self.nodes[0], 0.1*COIN, False) unconfirmed_utxo = make_utxo(self.nodes[0], int(0.1*COIN), False)
tx1 = CTransaction() tx1 = CTransaction()
tx1.vin = [CTxIn(confirmed_utxo)] tx1.vin = [CTxIn(confirmed_utxo)]
tx1.vout = [CTxOut(1.0*COIN, CScript([b'a']))] tx1.vout = [CTxOut(1*COIN, CScript([b'a']))]
tx1_hex = txToHex(tx1) tx1_hex = txToHex(tx1)
tx1_txid = self.nodes[0].sendrawtransaction(tx1_hex, True) tx1_txid = self.nodes[0].sendrawtransaction(tx1_hex, True)
@ -392,7 +392,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
# Start by creating a single transaction with many outputs # Start by creating a single transaction with many outputs
initial_nValue = 10*COIN initial_nValue = 10*COIN
utxo = make_utxo(self.nodes[0], initial_nValue) utxo = make_utxo(self.nodes[0], initial_nValue)
fee = 0.0001*COIN fee = int(0.0001*COIN)
split_value = int((initial_nValue-fee)/(MAX_REPLACEMENT_LIMIT+1)) split_value = int((initial_nValue-fee)/(MAX_REPLACEMENT_LIMIT+1))
actual_fee = initial_nValue - split_value*(MAX_REPLACEMENT_LIMIT+1) actual_fee = initial_nValue - split_value*(MAX_REPLACEMENT_LIMIT+1)
@ -445,7 +445,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
def test_opt_in(self): def test_opt_in(self):
""" Replacing should only work if orig tx opted in """ """ Replacing should only work if orig tx opted in """
tx0_outpoint = make_utxo(self.nodes[0], 1.1*COIN) tx0_outpoint = make_utxo(self.nodes[0], int(1.1*COIN))
# Create a non-opting in transaction # Create a non-opting in transaction
tx1a = CTransaction() tx1a = CTransaction()
@ -457,7 +457,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
# Shouldn't be able to double-spend # Shouldn't be able to double-spend
tx1b = CTransaction() tx1b = CTransaction()
tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)] tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)]
tx1b.vout = [CTxOut(0.9*COIN, CScript([b'b']))] tx1b.vout = [CTxOut(int(0.9*COIN), CScript([b'b']))]
tx1b_hex = txToHex(tx1b) tx1b_hex = txToHex(tx1b)
try: try:
@ -468,7 +468,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
print tx1b_txid print tx1b_txid
assert(False) assert(False)
tx1_outpoint = make_utxo(self.nodes[0], 1.1*COIN) tx1_outpoint = make_utxo(self.nodes[0], int(1.1*COIN))
# Create a different non-opting in transaction # Create a different non-opting in transaction
tx2a = CTransaction() tx2a = CTransaction()
@ -480,7 +480,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
# Still shouldn't be able to double-spend # Still shouldn't be able to double-spend
tx2b = CTransaction() tx2b = CTransaction()
tx2b.vin = [CTxIn(tx1_outpoint, nSequence=0)] tx2b.vin = [CTxIn(tx1_outpoint, nSequence=0)]
tx2b.vout = [CTxOut(0.9*COIN, CScript([b'b']))] tx2b.vout = [CTxOut(int(0.9*COIN), CScript([b'b']))]
tx2b_hex = txToHex(tx2b) tx2b_hex = txToHex(tx2b)
try: try:
@ -500,19 +500,19 @@ class ReplaceByFeeTest(BitcoinTestFramework):
tx3a = CTransaction() tx3a = CTransaction()
tx3a.vin = [CTxIn(COutPoint(tx1a_txid, 0), nSequence=0xffffffff), tx3a.vin = [CTxIn(COutPoint(tx1a_txid, 0), nSequence=0xffffffff),
CTxIn(COutPoint(tx2a_txid, 0), nSequence=0xfffffffd)] CTxIn(COutPoint(tx2a_txid, 0), nSequence=0xfffffffd)]
tx3a.vout = [CTxOut(0.9*COIN, CScript([b'c'])), CTxOut(0.9*COIN, CScript([b'd']))] tx3a.vout = [CTxOut(int(0.9*COIN), CScript([b'c'])), CTxOut(int(0.9*COIN), CScript([b'd']))]
tx3a_hex = txToHex(tx3a) tx3a_hex = txToHex(tx3a)
self.nodes[0].sendrawtransaction(tx3a_hex, True) self.nodes[0].sendrawtransaction(tx3a_hex, True)
tx3b = CTransaction() tx3b = CTransaction()
tx3b.vin = [CTxIn(COutPoint(tx1a_txid, 0), nSequence=0)] tx3b.vin = [CTxIn(COutPoint(tx1a_txid, 0), nSequence=0)]
tx3b.vout = [CTxOut(0.5*COIN, CScript([b'e']))] tx3b.vout = [CTxOut(int(0.5*COIN), CScript([b'e']))]
tx3b_hex = txToHex(tx3b) tx3b_hex = txToHex(tx3b)
tx3c = CTransaction() tx3c = CTransaction()
tx3c.vin = [CTxIn(COutPoint(tx2a_txid, 0), nSequence=0)] tx3c.vin = [CTxIn(COutPoint(tx2a_txid, 0), nSequence=0)]
tx3c.vout = [CTxOut(0.5*COIN, CScript([b'f']))] tx3c.vout = [CTxOut(int(0.5*COIN), CScript([b'f']))]
tx3c_hex = txToHex(tx3c) tx3c_hex = txToHex(tx3c)
self.nodes[0].sendrawtransaction(tx3b_hex, True) self.nodes[0].sendrawtransaction(tx3b_hex, True)
@ -525,7 +525,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
# correctly used by replacement logic # correctly used by replacement logic
# 1. Check that feeperkb uses modified fees # 1. Check that feeperkb uses modified fees
tx0_outpoint = make_utxo(self.nodes[0], 1.1*COIN) tx0_outpoint = make_utxo(self.nodes[0], int(1.1*COIN))
tx1a = CTransaction() tx1a = CTransaction()
tx1a.vin = [CTxIn(tx0_outpoint, nSequence=0)] tx1a.vin = [CTxIn(tx0_outpoint, nSequence=0)]
@ -536,7 +536,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
# Higher fee, but the actual fee per KB is much lower. # Higher fee, but the actual fee per KB is much lower.
tx1b = CTransaction() tx1b = CTransaction()
tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)] tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)]
tx1b.vout = [CTxOut(0.001*COIN, CScript([b'a'*740000]))] tx1b.vout = [CTxOut(int(0.001*COIN), CScript([b'a'*740000]))]
tx1b_hex = txToHex(tx1b) tx1b_hex = txToHex(tx1b)
# Verify tx1b cannot replace tx1a. # Verify tx1b cannot replace tx1a.
@ -556,7 +556,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
assert(tx1b_txid in self.nodes[0].getrawmempool()) assert(tx1b_txid in self.nodes[0].getrawmempool())
# 2. Check that absolute fee checks use modified fee. # 2. Check that absolute fee checks use modified fee.
tx1_outpoint = make_utxo(self.nodes[0], 1.1*COIN) tx1_outpoint = make_utxo(self.nodes[0], int(1.1*COIN))
tx2a = CTransaction() tx2a = CTransaction()
tx2a.vin = [CTxIn(tx1_outpoint, nSequence=0)] tx2a.vin = [CTxIn(tx1_outpoint, nSequence=0)]
@ -567,7 +567,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
# Lower fee, but we'll prioritise it # Lower fee, but we'll prioritise it
tx2b = CTransaction() tx2b = CTransaction()
tx2b.vin = [CTxIn(tx1_outpoint, nSequence=0)] tx2b.vin = [CTxIn(tx1_outpoint, nSequence=0)]
tx2b.vout = [CTxOut(1.01*COIN, CScript([b'a']))] tx2b.vout = [CTxOut(int(1.01*COIN), CScript([b'a']))]
tx2b.rehash() tx2b.rehash()
tx2b_hex = txToHex(tx2b) tx2b_hex = txToHex(tx2b)

View file

@ -219,7 +219,7 @@ class EstimateFeeTest(BitcoinTestFramework):
from_index = random.randint(1,2) from_index = random.randint(1,2)
(txhex, fee) = small_txpuzzle_randfee(self.nodes[from_index], self.confutxo, (txhex, fee) = small_txpuzzle_randfee(self.nodes[from_index], self.confutxo,
self.memutxo, Decimal("0.005"), min_fee, min_fee) self.memutxo, Decimal("0.005"), min_fee, min_fee)
tx_kbytes = (len(txhex)/2)/1000.0 tx_kbytes = (len(txhex) // 2) / 1000.0
self.fees_per_kb.append(float(fee)/tx_kbytes) self.fees_per_kb.append(float(fee)/tx_kbytes)
sync_mempools(self.nodes[0:3],.1) sync_mempools(self.nodes[0:3],.1)
mined = mining_node.getblock(mining_node.generate(1)[0],True)["tx"] mined = mining_node.getblock(mining_node.generate(1)[0],True)["tx"]

View file

@ -29,7 +29,7 @@ def serialize_script_num(value):
neg = value < 0 neg = value < 0
absvalue = -value if neg else value absvalue = -value if neg else value
while (absvalue): while (absvalue):
r.append(chr(absvalue & 0xff)) r.append(int(absvalue & 0xff))
absvalue >>= 8 absvalue >>= 8
if r[-1] & 0x80: if r[-1] & 0x80:
r.append(0x80 if neg else 0) r.append(0x80 if neg else 0)

View file

@ -641,7 +641,7 @@ class msg_version(object):
def __init__(self): def __init__(self):
self.nVersion = MY_VERSION self.nVersion = MY_VERSION
self.nServices = 1 self.nServices = 1
self.nTime = time.time() self.nTime = int(time.time())
self.addrTo = CAddress() self.addrTo = CAddress()
self.addrFrom = CAddress() self.addrFrom = CAddress()
self.nNonce = random.getrandbits(64) self.nNonce = random.getrandbits(64)
@ -986,7 +986,7 @@ class msg_reject(object):
def __init__(self): def __init__(self):
self.message = "" self.message = ""
self.code = "" self.code = 0
self.reason = "" self.reason = ""
self.data = 0L self.data = 0L

View file

@ -45,7 +45,7 @@ def _convert_ip_port(array):
# convert host from mangled-per-four-bytes form as used by kernel # convert host from mangled-per-four-bytes form as used by kernel
host = binascii.unhexlify(host) host = binascii.unhexlify(host)
host_out = '' host_out = ''
for x in range(0, len(host)/4): for x in range(0, len(host) // 4):
(val,) = struct.unpack('=I', host[x*4:(x+1)*4]) (val,) = struct.unpack('=I', host[x*4:(x+1)*4])
host_out += '%08x' % val host_out += '%08x' % val