Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
silkaj
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
silkaj
Commits
415d829b
Commit
415d829b
authored
4 years ago
by
matograine
Browse files
Options
Downloads
Patches
Plain Diff
[mod]
#301
: create function display_pubkey_and_checksum()
and related tests
parent
c919f8f7
No related branches found
No related tags found
2 merge requests
!146
Merge dev into master branch to complete v0.8.0 development cycle
,
!143
#301: Generalize pubkey checksum display and check
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
silkaj/constants.py
+1
-0
1 addition, 0 deletions
silkaj/constants.py
silkaj/tui.py
+12
-0
12 additions, 0 deletions
silkaj/tui.py
tests/test_tui.py
+19
-2
19 additions, 2 deletions
tests/test_tui.py
tests/test_unit_tx.py
+5
-1
5 additions, 1 deletion
tests/test_unit_tx.py
with
37 additions
and
3 deletions
silkaj/constants.py
+
1
−
0
View file @
415d829b
...
...
@@ -29,3 +29,4 @@ BMA_MAX_BLOCKS_CHUNK_SIZE = 5000
PUBKEY_PATTERN
=
"
[1-9A-HJ-NP-Za-km-z]{43,44}
"
MINIMAL_TX_AMOUNT
=
0.01
CENT_MULT_TO_UNIT
=
100
SHORT_PUBKEY_SIZE
=
8
This diff is collapsed.
Click to expand it.
silkaj/tui.py
+
12
−
0
View file @
415d829b
...
...
@@ -18,6 +18,8 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
from
datetime
import
datetime
from
silkaj
import
wot
from
silkaj
import
crypto_tools
as
ct
from
silkaj.constants
import
SHORT_PUBKEY_SIZE
def
display_amount
(
tx
,
message
,
amount
,
ud_value
,
currency_symbol
):
...
...
@@ -47,6 +49,16 @@ async def display_pubkey(tx, message, pubkey):
tx
.
append
([
message
+
"
(id)
"
,
id
[
"
uid
"
]])
def
display_pubkey_and_checksum
(
pubkey
,
short
=
False
,
length
=
SHORT_PUBKEY_SIZE
):
"""
Returns
"
<pubkey>:<checksum>
"
in full form.
returns `length` first chars of pubkey and checksum in short form.
`length` defaults to SHORT_PUBKEY_SIZE.
"""
short_pubkey
=
pubkey
[:
length
]
+
"
…
"
if
short
else
pubkey
return
short_pubkey
+
"
:
"
+
ct
.
gen_checksum
(
pubkey
)
def
convert_time
(
timestamp
,
kind
):
ts
=
int
(
timestamp
)
date
=
"
%Y-%m-%d
"
...
...
This diff is collapsed.
Click to expand it.
tests/test_tui.py
+
19
−
2
View file @
415d829b
...
...
@@ -16,8 +16,8 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
"""
import
pytest
from
silkaj.tui
import
display_pubkey
,
display_amount
from
silkaj.constants
import
G1_SYMBOL
from
silkaj.tui
import
display_pubkey
,
display_amount
,
display_pubkey_and_checksum
from
silkaj.constants
import
G1_SYMBOL
,
SHORT_PUBKEY_SIZE
import
patched
...
...
@@ -63,3 +63,20 @@ async def test_display_pubkey(message, pubkey, id, monkeypatch):
tx
=
list
()
await
display_pubkey
(
tx
,
message
,
pubkey
)
assert
tx
==
expected
# display_pubkey_and_checksum
@pytest.mark.parametrize
(
"
pubkey, checksum
"
,
[
(
"
J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX
"
,
"
KAv
"
),
],
)
def
test_display_pubkey_and_checksum
(
pubkey
,
checksum
):
assert
pubkey
+
"
:
"
+
checksum
==
display_pubkey_and_checksum
(
pubkey
)
assert
pubkey
[:
SHORT_PUBKEY_SIZE
]
+
"
…:
"
+
checksum
==
display_pubkey_and_checksum
(
pubkey
,
short
=
True
)
assert
pubkey
[:
14
]
+
"
…:
"
+
checksum
==
display_pubkey_and_checksum
(
pubkey
,
short
=
True
,
length
=
14
)
This diff is collapsed.
Click to expand it.
tests/test_unit_tx.py
+
5
−
1
View file @
415d829b
...
...
@@ -26,7 +26,11 @@ from silkaj.tx import (
)
from
silkaj.tui
import
display_pubkey
,
display_amount
from
silkaj.money
import
UDValue
from
silkaj.constants
import
G1_SYMBOL
,
CENT_MULT_TO_UNIT
,
MINIMAL_TX_AMOUNT
from
silkaj.constants
import
(
G1_SYMBOL
,
CENT_MULT_TO_UNIT
,
MINIMAL_TX_AMOUNT
,
)
from
duniterpy.documents.transaction
import
(
InputSource
,
Transaction
,
...
...
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