cleanups and fixing odd casting
This commit is contained in:
parent
b2752948c0
commit
3eb6512b78
|
@ -47,7 +47,7 @@ OVERWINTER_PROTO_VERSION = 170003
|
|||
SAPLING_PROTO_VERSION = 170006
|
||||
BLOSSOM_PROTO_VERSION = 170008
|
||||
|
||||
MY_SUBVERSION = b"/python-mininode-tester:0.0.3"
|
||||
MY_SUBVERSION = b"/python-mininode-tester:0.0.1/"
|
||||
|
||||
SPROUT_VERSION_GROUP_ID = 0x00000000
|
||||
OVERWINTER_VERSION_GROUP_ID = 0x03C48270
|
||||
|
@ -314,9 +314,9 @@ class CAddress(object):
|
|||
|
||||
class CInv(object):
|
||||
typemap = {
|
||||
0: "Error",
|
||||
1: "TX",
|
||||
2: "Block"}
|
||||
0: b"Error",
|
||||
1: b"TX",
|
||||
2: b"Block"}
|
||||
|
||||
def __init__(self, t=0, h=0):
|
||||
self.type = t
|
||||
|
@ -746,8 +746,9 @@ class CTransaction(object):
|
|||
self.calc_sha256()
|
||||
|
||||
def calc_sha256(self):
|
||||
serialized = self.serialize()
|
||||
if self.sha256 is None:
|
||||
self.sha256 = uint256_from_str(hash256(self.serialize()))
|
||||
self.sha256 = uint256_from_str(hash256(serialized))
|
||||
self.hash = hash256(self.serialize())[::-1].hex()
|
||||
|
||||
def is_valid(self):
|
||||
|
@ -926,7 +927,7 @@ class CBlock(CBlockHeader):
|
|||
self.nNonce, self.nSolution, self.vtx)
|
||||
|
||||
|
||||
class CUnsignedAlert():
|
||||
class CUnsignedAlert(object):
|
||||
def __init__(self):
|
||||
self.nVersion = 1
|
||||
self.nRelayUntil = 0
|
||||
|
@ -1143,7 +1144,7 @@ class msg_getdata(object):
|
|||
return "msg_getdata(inv=%s)" % (repr(self.inv))
|
||||
|
||||
|
||||
class msg_notfound():
|
||||
class msg_notfound(object):
|
||||
command = b"notfound"
|
||||
|
||||
def __init__(self):
|
||||
|
@ -1159,7 +1160,7 @@ class msg_notfound():
|
|||
return "msg_notfound(inv=%r)" % (self.inv,)
|
||||
|
||||
|
||||
class msg_getblocks():
|
||||
class msg_getblocks(object):
|
||||
command = b"getblocks"
|
||||
|
||||
def __init__(self):
|
||||
|
@ -1382,7 +1383,7 @@ class msg_reject(object):
|
|||
% (self.message, self.code, self.reason, self.data)
|
||||
|
||||
|
||||
class msg_filteradd():
|
||||
class msg_filteradd(object):
|
||||
command = b"filteradd"
|
||||
|
||||
def __init__(self):
|
||||
|
@ -1398,7 +1399,7 @@ class msg_filteradd():
|
|||
return "msg_filteradd(data=%r)" % (self.data,)
|
||||
|
||||
|
||||
class msg_filterclear():
|
||||
class msg_filterclear(object):
|
||||
command = b"filterclear"
|
||||
|
||||
def __init__(self):
|
||||
|
@ -1554,12 +1555,12 @@ class NodeConn(asyncore.dispatcher):
|
|||
|
||||
def handle_connect(self):
|
||||
self.show_debug_msg("MiniNode: Connected & Listening: \n")
|
||||
self.state = "connected"
|
||||
self.state = b"connected"
|
||||
|
||||
def handle_close(self):
|
||||
self.show_debug_msg("MiniNode: Closing Connection to %s:%d... "
|
||||
% (self.dstaddr, self.dstport))
|
||||
self.state = "closed"
|
||||
self.state = b"closed"
|
||||
self.recvbuf = b""
|
||||
self.sendbuf = b""
|
||||
try:
|
||||
|
@ -1634,7 +1635,7 @@ class NodeConn(asyncore.dispatcher):
|
|||
repr(msg))
|
||||
|
||||
def send_message(self, message, pushbuf=False):
|
||||
if self.state != "connected" and not pushbuf:
|
||||
if self.state != b"connected" and not pushbuf:
|
||||
return
|
||||
self.show_debug_msg("Send %s" % repr(message))
|
||||
command = message.command
|
||||
|
|
|
@ -7,7 +7,7 @@ from test_framework.test_framework import BitcoinTestFramework
|
|||
from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
start_node, connect_nodes_bi, sync_blocks, sync_mempools, \
|
||||
wait_and_assert_operationid_status, get_coinbase_address
|
||||
wait_and_assert_operationid_status, get_coinbase_address, fail
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
|
@ -62,44 +62,44 @@ class WalletShieldCoinbaseTest (BitcoinTestFramework):
|
|||
self.nodes[2].importaddress(mytaddr)
|
||||
try:
|
||||
self.nodes[2].z_shieldcoinbase(mytaddr, myzaddr)
|
||||
fail("Expected JSONRPCException not raised!")
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("Could not find any coinbase funds to shield" in errorString, True)
|
||||
assert_equal("Could not find any coinbase funds to shield" in e.error['message'], True)
|
||||
|
||||
# Shielding will fail because fee is negative
|
||||
try:
|
||||
self.nodes[0].z_shieldcoinbase("*", myzaddr, -1)
|
||||
fail("Expected JSONRPCException not raised!")
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("Amount out of range" in errorString, True)
|
||||
|
||||
assert_equal("Amount out of range" in e.error['message'], True)
|
||||
print("tHERE")
|
||||
# Shielding will fail because fee is larger than MAX_MONEY
|
||||
try:
|
||||
self.nodes[0].z_shieldcoinbase("*", myzaddr, Decimal('21000000.00000001'))
|
||||
fail("Expected JSONRPCException not raised!")
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("Amount out of range" in errorString, True)
|
||||
|
||||
assert_equal("Amount out of range" in e.error['message'], True)
|
||||
print("HERE")
|
||||
# Shielding will fail because fee is larger than sum of utxos
|
||||
try:
|
||||
self.nodes[0].z_shieldcoinbase("*", myzaddr, 999)
|
||||
fail("Expected JSONRPCException not raised!")
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("Insufficient coinbase funds" in errorString, True)
|
||||
assert_equal("Insufficient coinbase funds" in e.error['message'], True)
|
||||
|
||||
# Shielding will fail because limit parameter must be at least 0
|
||||
try:
|
||||
self.nodes[0].z_shieldcoinbase("*", myzaddr, Decimal('0.001'), -1)
|
||||
fail("Expected JSONRPCException not raised!")
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("Limit on maximum number of utxos cannot be negative" in errorString, True)
|
||||
assert_equal("Limit on maximum number of utxos cannot be negative" in e.error['message'], True)
|
||||
|
||||
# Shielding will fail because limit parameter is absurdly large
|
||||
try:
|
||||
self.nodes[0].z_shieldcoinbase("*", myzaddr, Decimal('0.001'), 99999999999999)
|
||||
fail("Expected JSONRPCException not raised!")
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("JSON integer out of range" in errorString, True)
|
||||
assert_equal("JSON integer out of range" in e.error['message'], True)
|
||||
|
||||
# Shield coinbase utxos from node 0 of value 40, standard fee of 0.00010000
|
||||
result = self.nodes[0].z_shieldcoinbase(mytaddr, myzaddr)
|
||||
|
|
|
@ -37,8 +37,9 @@ class ZkeyImportExportTest (BitcoinTestFramework):
|
|||
# the sender loses 'amount' plus fee; to_addr receives exactly 'amount'
|
||||
def z_send(from_node, from_addr, to_addr, amount):
|
||||
global fee
|
||||
|
||||
opid = from_node.z_sendmany(from_addr,
|
||||
[{"address": to_addr, "amount": Decimal(amount)}], 1, fee)
|
||||
[{"address": to_addr, "amount": Decimal(amount)}], 1, int(fee))
|
||||
wait_and_assert_operationid_status(from_node, opid)
|
||||
self.sync_all()
|
||||
miner.generate(1)
|
||||
|
@ -145,7 +146,8 @@ class ZkeyImportExportTest (BitcoinTestFramework):
|
|||
z_send(bob, bob_zaddr, alice_zaddr, amount)
|
||||
bob_fee += fee
|
||||
|
||||
bob_balance = sum(amounts[2:]) - bob_fee
|
||||
bob_balance = sum(amounts[2:]) - int(bob_fee)
|
||||
|
||||
assert_equal(bob.z_getbalance(bob_zaddr), bob_balance)
|
||||
|
||||
# z_import onto new node "david" (blockchain rescan, default or True?)
|
||||
|
|
Loading…
Reference in New Issue