forked from pantos-io/validatornode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pantos-io#22 from levonyak/PAN-1979-1980-secondary…
…-node-validator-nonce-updates-and-transfer-submission-task [PAN-1979/-1980] Secondary node validator nonce updates and transfer submission task
- Loading branch information
Showing
11 changed files
with
270 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
tests/business/transfers/test_submit_transfer_to_primary_node.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import unittest.mock | ||
|
||
import celery.exceptions # type: ignore | ||
import pytest | ||
|
||
from pantos.validatornode.business.transfers import TransferInteractorError | ||
from pantos.validatornode.business.transfers import \ | ||
submit_transfer_to_primary_node_task | ||
|
||
|
||
@pytest.mark.parametrize('submission_completed', [True, False]) | ||
@unittest.mock.patch( | ||
'pantos.validatornode.business.transfers.config', { | ||
'tasks': { | ||
'submit_transfer_to_primary_node': { | ||
'retry_interval_in_seconds': 120 | ||
} | ||
} | ||
}) | ||
@unittest.mock.patch( | ||
'pantos.validatornode.business.transfers.TransferInteractor') | ||
def test_submit_transfer_to_primary_node_task_correct( | ||
mock_transfer_interactor, submission_completed, internal_transfer_id, | ||
cross_chain_transfer, cross_chain_transfer_dict): | ||
mock_transfer_interactor().submit_transfer_to_primary_node.return_value = \ | ||
submission_completed | ||
if submission_completed: | ||
submit_transfer_to_primary_node_task(internal_transfer_id, | ||
cross_chain_transfer_dict) | ||
else: | ||
with pytest.raises(celery.exceptions.Retry): | ||
submit_transfer_to_primary_node_task(internal_transfer_id, | ||
cross_chain_transfer_dict) | ||
mock_transfer_interactor().submit_transfer_to_primary_node.\ | ||
assert_called_once_with(internal_transfer_id, cross_chain_transfer) | ||
|
||
|
||
@unittest.mock.patch( | ||
'pantos.validatornode.business.transfers.config', { | ||
'tasks': { | ||
'submit_transfer_to_primary_node': { | ||
'retry_interval_after_error_in_seconds': 300 | ||
} | ||
} | ||
}) | ||
@unittest.mock.patch( | ||
'pantos.validatornode.business.transfers.TransferInteractor') | ||
def test_submit_transfer_to_primary_node_task_error(mock_transfer_interactor, | ||
internal_transfer_id, | ||
cross_chain_transfer, | ||
cross_chain_transfer_dict): | ||
mock_transfer_interactor().submit_transfer_to_primary_node.side_effect = \ | ||
TransferInteractorError('') | ||
with pytest.raises(TransferInteractorError): | ||
submit_transfer_to_primary_node_task(internal_transfer_id, | ||
cross_chain_transfer_dict) | ||
mock_transfer_interactor().submit_transfer_to_primary_node.\ | ||
assert_called_once_with(internal_transfer_id, cross_chain_transfer) |
Oops, something went wrong.