-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REM-1312: Get particular Atomic Swap information by its identifier #24
Conversation
4402a5c
to
e2c2a90
Compare
…by swap identifier
e2c2a90
to
a36b469
Compare
Codecov Report
@@ Coverage Diff @@
## develop #24 +/- ##
===========================================
- Coverage 97.43% 97.43% -0.01%
===========================================
Files 29 30 +1
Lines 507 545 +38
===========================================
+ Hits 494 531 +37
- Misses 13 14 +1
Continue to review full report at Codecov.
|
…t-atomic-swap-info-by-its-id
…t-atomic-swap-info-by-its-id
README.md
Outdated
@@ -158,6 +159,36 @@ $ remme atomic-swap get-public-key --node-url=node-6-testnet.remme.io | |||
} | |||
``` | |||
|
|||
Get information about atomic swap by swap identifier — ``remme atomic-swap get-info``: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by swap identifier
> by its identifier
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmytrostriletskyi, done.
cli/atomic_swap/cli.py
Outdated
@@ -18,6 +23,8 @@ | |||
print_result, | |||
) | |||
|
|||
loop = asyncio.get_event_loop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not need a loop in the CLI layer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmytrostriletskyi, done.
cli/generic/forms/fields.py
Outdated
@@ -102,3 +103,23 @@ def _deserialize(self, value, attr, data, **kwargs): | |||
raise ValidationError(f'The following public key address `{public_key_address}` is invalid.') | |||
|
|||
return value | |||
|
|||
|
|||
class SwapIdField(fields.Field): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SwapIdField
> SwapIdentifierField
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmytrostriletskyi, done.
7cd74a7
to
e492667
Compare
class GetAtomicSwapInformationForm(Schema): | ||
""" | ||
Get information about atomic swap of the atomic swap form. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get information about atomic swap by its identifier form.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmytrostriletskyi, done.
…t-atomic-swap-info-by-its-id
e492667
to
a92a23d
Compare
try: | ||
swap_info = loop.run_until_complete(self.service.swap.get_info(swap_id=swap_id)) | ||
|
||
except RpcGenericServerDefinedError as error: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add except RpcGenericServerDefinedError
to method get_public_key
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ticket is not related to get_public_key
. It should be fixed in another ticket.
""" | ||
Validate data (swap identifier) that was passed to field. | ||
""" | ||
swap_identifier = value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is it for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For more detail, variable value
says nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You create a class that named SwapIdentifierField
that have docs that say
Implements validation of the swap identifier.
and you have a method _deserialize
that also have docs:
Validate data (swap identifier) that was passed to field.
Also, you validate one variable and return another, it not logical.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Documentation could lag behind code during the project life.
- Sometimes programmers read the code but not the docs.
These points are the core arguments why we should create the separated explicit (!) variable and return it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmytrostriletskyi, ok, but we don't return swap_identifier
, we validate one argument, but return other value
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Alladin9393, refresh page.
swap_info = json.loads(result.output).get('result').get('information') | ||
|
||
assert PASSED_EXIT_FROM_COMMAND_CODE == result.exit_code | ||
assert re.match(pattern=ADDRESS_REGEXP, string=swap_info.get('sender_address')) is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you check just pattern? Check, please equality swap_id or if swap_id in data. Add/Replace more one checking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Alladin9393, done.
@@ -7,6 +7,7 @@ | |||
PUBLIC_KEY_REGEXP = r'^[0-9a-f]{66}$' | |||
PUBLIC_KEY_ADDRESS_REGEXP = r'^[0-9a-f]{70}$' | |||
HEADER_SIGNATURE_REGEXP = r'^[0-9a-f]{128}$' | |||
SWAP_IDENTIFIER_REGEXP = r'^[a-f0-9]{64}$' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change according to alphabetical order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This constants not in alphabetical order. It should be fixed in another ticket for technical dept.
306e861
to
6be49ab
Compare
cli/atomic_swap/help.py
Outdated
@@ -1,3 +1,4 @@ | |||
""" | |||
Provide help messages for command line interface's atomic swap commands. | |||
""" | |||
SWAP_IDENTIFIER_ARGUMENT_HELP_MESSAGE = 'Swap identifier to get an information about swap by.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get information about swap by.
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Alladin9393, done.
tests/atomic_swap/test_get_info.py
Outdated
def test_get_swap_info(): | ||
""" | ||
Case: get information about atomic swap by its identifier. | ||
Expect: information about swap is returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the swap is returned.
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Alladin9393, done.
tests/atomic_swap/test_get_info.py
Outdated
assert re.match(pattern=ADDRESS_REGEXP, string=swap_info.get('sender_address')) is not None | ||
assert re.match(pattern=ADDRESS_REGEXP, string=swap_info.get('receiver_address')) is not None | ||
assert re.match(pattern=SWAP_IDENTIFIER_REGEXP, string=swap_identifier) is not None | ||
assert isinstance(int(float(swap_info.get('amount'))), int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this test here for? We will always have an int.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Alladin9393, done.
def test_get_swap_info_invalid_swap_id(): | ||
""" | ||
Case: get information about atomic swap by its invalid identifier. | ||
Expect: the following swap identifier is invalid error message. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
swap identifier is an invalid error message.
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6be49ab
to
a5ff6f0
Compare
a5ff6f0
to
cef8365
Compare
…t-atomic-swap-info-by-its-id
|
||
def test_get_swap_info_non_existing_swap_id(): | ||
""" | ||
Case: get information about atomic swap by passing non-existing identifier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Case: get information about atomic swap by passing non-existing identifier. | |
Case: get information about atomic swap by passing a non-existing identifier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jira references
Description
Get information about Atomic Swap command line interface's command implementation.
Example of the usage:
Implemented
— Command line interface's command.
— Service to get particular Atomic Swap information of the atomic swap class.
References