Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DuniterPy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
DuniterPy
Commits
66259e0e
Commit
66259e0e
authored
5 years ago
by
Vincent Texier
Browse files
Options
Downloads
Patches
Plain Diff
[fix]
#112
fix Unlock.from_inline error on a newly created Unlock
Removed newline at the end of the regexp
parent
c05e7d38
No related branches found
No related tags found
No related merge requests found
Pipeline
#7412
passed
5 years ago
Stage: format
Stage: test
Stage: build
Stage: release
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
duniterpy/documents/transaction.py
+8
-6
8 additions, 6 deletions
duniterpy/documents/transaction.py
tests/documents/test_transaction.py
+5
-0
5 additions, 0 deletions
tests/documents/test_transaction.py
with
13 additions
and
6 deletions
duniterpy/documents/transaction.py
+
8
−
6
View file @
66259e0e
...
...
@@ -254,7 +254,7 @@ class SIGParameter:
return
self
.
index
==
other
.
index
def
__hash__
(
self
)
->
int
:
return
hash
(
(
self
.
index
)
)
return
hash
(
self
.
index
)
@classmethod
def
from_parameter
(
...
...
@@ -310,7 +310,7 @@ class XHXParameter:
return
self
.
integer
==
other
.
integer
def
__hash__
(
self
)
->
int
:
return
hash
(
(
self
.
integer
)
)
return
hash
(
self
.
integer
)
@classmethod
def
from_parameter
(
...
...
@@ -380,7 +380,7 @@ class Unlock:
A Transaction UNLOCK
"""
re_inline
=
re
.
compile
(
"
([0-9]+):((?:SIG
\\
([0-9]+
\\
)|XHX
\\
([0-9]+
\\
)|
\\
s)+)
\n
"
)
re_inline
=
re
.
compile
(
"
([0-9]+):((?:SIG
\\
([0-9]+
\\
)|XHX
\\
([0-9]+
\\
)|
\\
s)+)
"
)
def
__init__
(
self
,
index
:
int
,
parameters
:
List
[
Union
[
SIGParameter
,
XHXParameter
]]
...
...
@@ -425,8 +425,8 @@ class Unlock:
index
=
int
(
data
.
group
(
1
))
parameters_str
=
data
.
group
(
2
).
split
(
"
"
)
parameters
=
[]
for
p
in
parameters_str
:
param
=
UnlockParameter
.
from_parameter
(
p
)
for
p
arameter
in
parameters_str
:
param
=
UnlockParameter
.
from_parameter
(
p
arameter
)
if
param
:
parameters
.
append
(
param
)
return
cls
(
index
,
parameters
)
...
...
@@ -437,7 +437,9 @@ class Unlock:
:return:
"""
return
"
{0}:{1}
"
.
format
(
self
.
index
,
"
"
.
join
([
str
(
p
)
for
p
in
self
.
parameters
]))
return
"
{0}:{1}
"
.
format
(
self
.
index
,
"
"
.
join
([
str
(
parameter
)
for
parameter
in
self
.
parameters
])
)
# required to type hint cls in classmethod
...
...
This diff is collapsed.
Click to expand it.
tests/documents/test_transaction.py
+
5
−
0
View file @
66259e0e
...
...
@@ -436,3 +436,8 @@ class TestTransaction(unittest.TestCase):
self
.
assertTrue
(
transaction
.
time
is
None
)
self
.
assertTrue
(
transaction
.
currency
==
"
gtest
"
)
self
.
assertTrue
(
transaction
.
inputs
[
0
].
amount
==
30
)
def
test_unlock
(
self
):
unlock1
=
Unlock
(
0
,
[
SIGParameter
(
0
)])
unlock2
=
Unlock
.
from_inline
(
unlock1
.
inline
())
self
.
assertEqual
(
unlock1
.
inline
(),
unlock2
.
inline
())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment