Skip to content

Commit

Permalink
peercoin changes for functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
backpacker69 committed May 28, 2019
1 parent 03b5eda commit ba71fb7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions test/functional/test_framework/mininode.py
Expand Up @@ -50,8 +50,8 @@
}

MAGIC_BYTES = {
"mainnet": b"\xf9\xbe\xb4\xd9", # mainnet
"testnet3": b"\x0b\x11\x09\x07", # testnet3
"mainnet": b"\xe6\xe8\xe9\xe5", # mainnet
"testnet3": b"\xcb\xf2\xc0\xef", # testnet3
"regtest": b"\xcb\xf2\xc0\xef", # regtest
}

Expand Down
10 changes: 5 additions & 5 deletions test/functional/test_framework/util.py
Expand Up @@ -173,9 +173,9 @@ def assert_array_result(object_array, to_match, expected, should_not_find=False)

def check_json_precision():
"""Make sure json library being used does not lose precision converting BTC values"""
n = Decimal("20000000.00000003")
satoshis = int(json.loads(json.dumps(float(n))) * 1.0e8)
if satoshis != 2000000000000003:
n = Decimal("20000000.000003")
satoshis = int(json.loads(json.dumps(float(n))) * 1.0e6)
if satoshis != 20000000000003:
raise RuntimeError("JSON encode/decode loses precision")

def count_bytes(hex_string):
Expand All @@ -198,7 +198,7 @@ def str_to_b64str(string):
return b64encode(string.encode('utf-8')).decode('ascii')

def satoshi_round(amount):
return Decimal(amount).quantize(Decimal('0.00000001'), rounding=ROUND_DOWN)
return Decimal(amount).quantize(Decimal('0.000001'), rounding=ROUND_DOWN)

def wait_until(predicate, *, attempts=float('inf'), timeout=float('inf'), lock=None):
if attempts == float('inf') and timeout == float('inf'):
Expand Down Expand Up @@ -457,7 +457,7 @@ def make_change(from_node, amount_in, amount_out, fee):
# Create an extra change output to break up big inputs
change_address = from_node.getnewaddress()
# Split change in two, being careful of rounding:
outputs[change_address] = Decimal(change / 2).quantize(Decimal('0.00000001'), rounding=ROUND_DOWN)
outputs[change_address] = Decimal(change / 2).quantize(Decimal('0.000001'), rounding=ROUND_DOWN)
change = amount_in - amount - outputs[change_address]
if change > 0:
outputs[from_node.getnewaddress()] = change
Expand Down

0 comments on commit ba71fb7

Please sign in to comment.