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
23a08a2a
Commit
23a08a2a
authored
9 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
Fix schemas in websockets
parent
c123d9b2
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
_ucoinpy_test/api/bma/test_ws.py
+58
-0
58 additions, 0 deletions
_ucoinpy_test/api/bma/test_ws.py
ucoinpy/api/bma/ws/__init__.py
+24
-4
24 additions, 4 deletions
ucoinpy/api/bma/ws/__init__.py
with
82 additions
and
4 deletions
_ucoinpy_test/api/bma/test_ws.py
0 → 100644
+
58
−
0
View file @
23a08a2a
import
unittest
from
_ucoinpy_test.api.webserver
import
WebFunctionalSetupMixin
from
ucoinpy.api.bma.ws
import
Block
,
Peer
class
Test_BMA_Websocket
(
WebFunctionalSetupMixin
,
unittest
.
TestCase
):
def
test_block_014
(
self
):
json_sample
=
"""
{
"
documentType
"
:
"
block
"
,
"
version
"
:1,
"
currency
"
:
"
meta_brouzouf
"
,
"
nonce
"
:567093,
"
number
"
:49191,
"
parameters
"
:
""
,
"
previousHash
"
:
"
0000084665ABA60118B6D302C9A9BA4BCCA94852
"
,
"
previousIssuer
"
:
"
HBSSmqZjT4UQKsCntTSmZbu7iRP14HYtifLE6mW1PsBD
"
,
"
issuer
"
:
"
HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk
"
,
"
identities
"
:[],
"
joiners
"
:[],
"
actives
"
:[],
"
leavers
"
:[],
"
excluded
"
:[],
"
membersCount
"
:18,
"
certifications
"
:[],
"
transactions
"
:[],
"
powMin
"
:5,
"
medianTime
"
:1454058545,
"
time
"
:1454072945,
"
signature
"
:
"
Bk2lo/MAVgEwCr7pEopMs9DdN3TylwPH45MZg80h/V5IsuYwcVmPOstty6Z8XXqFCSfiCuYPUS7NhxGHOcnxDw==
"
,
"
hash
"
:
"
0000011D7A92E746F9B2D5B7035B98867F4A95A2
"
,
"
fork
"
:false,
"
monetaryMass
"
:15431388469457603000,
"
dividend
"
:0,
"
UDTime
"
:1453979780,
"
wrong
"
:false
}
"""
block
=
Block
(
None
)
block
.
parse_text
(
json_sample
)
def
test_peer
(
self
):
json_sample
=
"""
{
"
version
"
:
"
1
"
,
"
currency
"
:
"
beta_brouzouf
"
,
"
pubkey
"
:
"
HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY
"
,
"
endpoints
"
: [
"
BASIC_MERKLED_API some.dns.name 88.77.66.55 2001:0db8:0000:85a3:0000:0000:ac1f 9001
"
,
"
BASIC_MERKLED_API some.dns.name 88.77.66.55 2001:0db8:0000:85a3:0000:0000:ac1f 9002
"
,
"
OTHER_PROTOCOL 88.77.66.55 9001
"
],
"
signature
"
:
"
42yQm4hGTJYWkPg39hQAUgP6S6EQ4vTfXdJuxKEHL1ih6YHiDL2hcwrFgBHjXLRgxRhj2VNVqqc6b4JayKqTE14r
"
}
"""
peer
=
Peer
(
None
)
data
=
peer
.
parse_text
(
json_sample
)
self
.
assertEqual
(
data
[
"
version
"
],
"
1
"
)
self
.
assertEqual
(
data
[
"
currency
"
],
"
beta_brouzouf
"
)
self
.
assertEqual
(
data
[
"
pubkey
"
],
"
HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY
"
)
self
.
assertEqual
(
len
(
data
[
"
endpoints
"
]),
3
)
self
.
assertEqual
(
data
[
"
signature
"
],
"
42yQm4hGTJYWkPg39hQAUgP6S6EQ4vTfXdJuxKEHL1ih6YHiDL2hcwrFgBHjXLRgxRhj2VNVqqc6b4JayKqTE14r
"
)
This diff is collapsed.
Click to expand it.
ucoinpy/api/bma/ws/__init__.py
+
24
−
4
View file @
23a08a2a
...
@@ -33,17 +33,37 @@ class Block(Websocket):
...
@@ -33,17 +33,37 @@ class Block(Websocket):
schema
=
_Block
.
schema
schema
=
_Block
.
schema
def
connect
(
self
):
def
connect
(
self
):
r
=
self
.
connect_ws
(
'
/block
'
)
r
=
self
.
connect_ws
(
'
/block
'
)
return
r
return
r
class
Peer
(
Websocket
):
class
Peer
(
Websocket
):
"""
Connect to block websocket.
"""
"""
Connect to block websocket.
"""
schema
=
_Peers
.
schema
schema
=
{
"
type
"
:
"
object
"
,
"
properties
"
:
{
"
version
"
:
{
"
type
"
:
"
string
"
},
"
currency
"
:
{
"
type
"
:
"
string
"
},
"
pubkey
"
:
{
"
type
"
:
"
string
"
},
"
endpoints
"
:
{
"
type
"
:
"
array
"
,
"
items
"
:
{
"
type
"
:
"
string
"
}
},
"
signature
"
:
{
"
type
"
:
"
string
"
}
},
"
required
"
:
[
"
version
"
,
"
currency
"
,
"
pubkey
"
,
"
endpoints
"
,
"
signature
"
]
}
def
connect
(
self
):
def
connect
(
self
):
r
=
self
.
connect_ws
(
'
/peer
'
)
r
=
self
.
connect_ws
(
'
/peer
'
)
return
r
return
r
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