aboutsummaryrefslogtreecommitdiff
path: root/test/functional/wallet_import_rescan.py
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-07-25 17:14:47 -0400
committerMarcoFalke <falke.marco@gmail.com>2019-08-14 17:19:48 -0400
commitfa79af298917d501cee26370fdf9d44d05133d15 (patch)
tree0e2cb503e5c27d759053986213b89fb55a32d390 /test/functional/wallet_import_rescan.py
parentfac3dcf7d052586548f2100a0d576618a85741f9 (diff)
test: Replace fragile "rng" with call to random()
Diffstat (limited to 'test/functional/wallet_import_rescan.py')
-rwxr-xr-xtest/functional/wallet_import_rescan.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/test/functional/wallet_import_rescan.py b/test/functional/wallet_import_rescan.py
index 0578f2c3b2..6ae585b3be 100755
--- a/test/functional/wallet_import_rescan.py
+++ b/test/functional/wallet_import_rescan.py
@@ -27,8 +27,10 @@ from test_framework.util import (
)
import collections
+from decimal import Decimal
import enum
import itertools
+import random
Call = enum.Enum("Call", "single multiaddress multiscript")
Data = enum.Enum("Data", "address pub priv")
@@ -117,6 +119,13 @@ IMPORT_NODES = [ImportNode(*fields) for fields in itertools.product((False, True
# Rescans start at the earliest block up to 2 hours before the key timestamp.
TIMESTAMP_WINDOW = 2 * 60 * 60
+AMOUNT_DUST = 0.00000546
+
+
+def get_rand_amount():
+ r = random.uniform(AMOUNT_DUST, 1)
+ return Decimal(str(round(r, 8)))
+
class ImportRescanTest(BitcoinTestFramework):
def set_test_params(self):
@@ -150,7 +159,7 @@ class ImportRescanTest(BitcoinTestFramework):
variant.label = "label {} {}".format(i, variant)
variant.address = self.nodes[1].getaddressinfo(self.nodes[1].getnewaddress(variant.label))
variant.key = self.nodes[1].dumpprivkey(variant.address["address"])
- variant.initial_amount = 1 - (i + 1) / 64
+ variant.initial_amount = get_rand_amount()
variant.initial_txid = self.nodes[0].sendtoaddress(variant.address["address"], variant.initial_amount)
self.nodes[0].generate(1) # Generate one block for each send
variant.confirmation_height = self.nodes[0].getblockcount()
@@ -183,7 +192,7 @@ class ImportRescanTest(BitcoinTestFramework):
# Create new transactions sending to each address.
for i, variant in enumerate(IMPORT_VARIANTS):
- variant.sent_amount = 1 - (2 * i + 1) / 128
+ variant.sent_amount = get_rand_amount()
variant.sent_txid = self.nodes[0].sendtoaddress(variant.address["address"], variant.sent_amount)
self.nodes[0].generate(1) # Generate one block for each send
variant.confirmation_height = self.nodes[0].getblockcount()