Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions test/functional/feature_restricted_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,23 +514,20 @@ def global_freezing(self):

assert_raises_rpc_error(None, "Invalid Raven change address", n0.freezerestrictedasset, asset_name, "garbagechangeaddress")

n0.freezerestrictedasset(asset_name, rvn_change_address)
n0.freezerestrictedasset(asset_name, rvn_change_address) # redundant freezing ok if consistent
n0.freezerestrictedasset(asset_name, rvn_change_address) # Can only freeze once!
assert_raises_rpc_error(-26, "Freezing transaction already in mempool", n0.freezerestrictedasset, asset_name, rvn_change_address)
n0.generate(1)

assert_raises_rpc_error(None, "global-freeze-when-already-frozen", n0.freezerestrictedasset, asset_name, rvn_change_address)

# post-freeze validation
assert_contains(asset_name, n0.listglobalrestrictions())
assert n0.checkglobalrestriction(asset_name)
assert_raises_rpc_error(-8, "restricted asset has been globally frozen", n0.transferfromaddress, asset_name, address, 1000, n1.getnewaddress())

assert_raises_rpc_error(None, "Invalid Raven change address", n0.unfreezerestrictedasset, asset_name, "garbagechangeaddress")

n0.unfreezerestrictedasset(asset_name, rvn_change_address)
n0.unfreezerestrictedasset(asset_name, rvn_change_address) # redundant unfreezing ok if consistent
n0.unfreezerestrictedasset(asset_name, rvn_change_address) # Can only un-freeze once!
assert_raises_rpc_error(-26, "Unfreezing transaction already in mempool", n0.unfreezerestrictedasset, asset_name, rvn_change_address)
n0.generate(1)

assert_raises_rpc_error(None, "global-unfreeze-when-not-frozen", n0.unfreezerestrictedasset, asset_name, rvn_change_address)

# post-unfreeze validation
Expand Down
11 changes: 10 additions & 1 deletion test/functional/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""Base class for RPC testing."""

from enum import Enum
from random import randint
import logging
import optparse
import os
Expand Down Expand Up @@ -86,9 +87,17 @@ def main(self):
self.options.cachedir = os.path.abspath(self.options.cachedir)

# Set up temp directory and start logging
# When looping tests using the --loop=n argument, when a test fails the tmpdir will not be deleted.
# This will cause that specific test to fail on every loop after since this directory will exist.
# Now when it fails to create the tmpdir it will try to create a new directory with a random int
# appended to the path. This will allow looped tests to pass and keep the log and state data from the previous failure.
if self.options.tmpdir:
self.options.tmpdir = os.path.abspath(self.options.tmpdir)
os.makedirs(self.options.tmpdir, exist_ok=False)
try:
os.makedirs(self.options.tmpdir, exist_ok=False)
except OSError as e:
self.options.tmpdir = os.path.abspath(self.options.tmpdir + str(randint(0,48)))
os.makedirs(self.options.tmpdir, exist_ok=False)
else:
self.options.tmpdir = tempfile.mkdtemp(prefix="test")
self._start_logging()
Expand Down