Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasochem committed Jul 10, 2024
1 parent 1ab9145 commit d975059
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 54 deletions.
5 changes: 1 addition & 4 deletions docs/run.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Options
Show help message and exit.

``-C --initial_cycle <int>``
Cycle to start payment(s) from. Valid range: ``[-1,)``. Default value: ``-1`` (pay rewards that were most recently released). Cycle for which rewards were most recently released is calculated based on the formula: ``current_cycle - 1 + [if --adjusted_payout_timing == True: (preserved_cycles + 1)]``.
Cycle to start payment(s) from. Valid range: ``[-1,)``. Default value: ``-1`` (pay rewards that were most recently released). Cycle for which rewards were most recently released is calculated based on the formula: ``current_cycle - 1``.

``-M --run_mode <int>``
Waiting decision after making pending payments. Valid range: ``[1,4]``. Default value: ``1``. Values description:
Expand All @@ -29,9 +29,6 @@ Options
3. Run for one cycle and exit. Suitable to use with ``-C`` option.
4. Retry failed payments and exit.

``--adjusted_early_payouts``
If provided allows for early, later on adjusted payouts for cycle = current_cycle - 1 + (preserved_cycles + 1). Its default value is ``False`` if not provided as argument. See :ref:`payout_timing`.

``-O --payment_offset <int>``
Number of blocks to wait after a cycle starts before starting payments. This can be useful because cycle beginnings may be busy.

Expand Down
1 change: 1 addition & 0 deletions src/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"MAINNET": {
# General
"NAME": "MAINNET",
"MINIMAL_BLOCK_DELAY": 10,
"BLOCKS_PER_CYCLE": 24576,
},
CURRENT_TESTNET: {
Expand Down
19 changes: 0 additions & 19 deletions src/util/args_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,31 +106,12 @@ def _initial_cycle_validator(self):
)
return True

def _adjusted_early_payouts_validator(self):
try:
self._args.adjusted_early_payouts
except AttributeError:
logger.warn(
"args: adjusted_early_payouts argument does not exist. Default setting to False."
)
self._args.adjusted_early_payouts = False
else:
tmp = self._args.adjusted_early_payouts
if not (isinstance(tmp, bool) or tmp == "True" or tmp == "False"):
self._parser.error(
"adjusted_early_payouts must be True or False. Its default value is False if not provided as argument."
)
if tmp is True:
self._parser.error("adjusted_early_payouts is deprecated")
return True

def run_validation(self):
self._reward_data_provider_validator()
self._network_validator()
self._base_directory_validator()
self._payment_offset_validator()
self._initial_cycle_validator()
self._adjusted_early_payouts_validator()
return self._args


Expand Down
6 changes: 2 additions & 4 deletions tests/regression/test_level_in_cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ def test_levels_in_cycle():
# map is based on current mainnet values

level_positions = [
[1589249, 0], # Granada activation level
[3000000, 1727],
[3268609, 0], # Mumbai activation level
[3333796, 16035],
[5726209, 0], # Paris activation level
[5898888, 647],
]

block = DummyApiImpl()
Expand Down
20 changes: 0 additions & 20 deletions tests/unit/test_args_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,25 +123,6 @@ def test_initial_cycle_validator_throws(caplog, capsys):
)


def test_adjusted_early_payouts_validator_throws(capsys):
argparser = argparse.ArgumentParser()
argparser.add_argument(
"--adjusted_early_payouts",
default=1,
type=int,
)
mock_validator = ArgsValidator(argparser)
with pytest.raises(SystemExit) as pytest_wrapped_e:
mock_validator._adjusted_early_payouts_validator()
out, err = capsys.readouterr()
assert pytest_wrapped_e.type == SystemExit
assert pytest_wrapped_e.value.code == 2
assert (
"adjusted_early_payouts must be True or False. Its default value is False if not provided as argument."
in err
)


def test_base_directory_validator():
argparser = argparse.ArgumentParser()
argparser.add_argument("--base_directory", default="~/TEST_DIR")
Expand All @@ -167,7 +148,6 @@ def test_validate():
assert SUT == argparse.Namespace(
initial_cycle=-1,
run_mode=1,
adjusted_early_payouts=False,
payment_offset=0,
network="MAINNET",
node_endpoint="http://127.0.0.1:8732",
Expand Down
6 changes: 0 additions & 6 deletions tests/unit/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
add_argument_mode,
add_argument_base_directory,
add_argument_node_addr_public,
add_argument_adjusted_early_payouts,
add_argument_payment_offset,
add_argument_network,
add_argument_node_endpoint,
Expand All @@ -30,10 +29,6 @@
[
(add_argument_cycle, argparse.Namespace(initial_cycle=-1)),
(add_argument_mode, argparse.Namespace(run_mode=1)),
(
add_argument_adjusted_early_payouts,
argparse.Namespace(adjusted_early_payouts=False),
),
(add_argument_payment_offset, argparse.Namespace(payment_offset=0)),
(add_argument_network, argparse.Namespace(network="MAINNET")),
(
Expand Down Expand Up @@ -78,7 +73,6 @@ def test_build_parser():
assert value.parse_known_args()[0] == argparse.Namespace(
initial_cycle=-1,
run_mode=1,
adjusted_early_payouts=False,
payment_offset=0,
network="MAINNET",
node_endpoint="http://127.0.0.1:8732",
Expand Down
1 change: 0 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def __init__(
):
self.initial_cycle = initial_cycle
self.run_mode = 3
self.adjusted_early_payouts = False
self.payment_offset = 0
self.network = None
self.node_endpoint = ""
Expand Down

0 comments on commit d975059

Please sign in to comment.