Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
beem
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
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
hive
beem
Commits
0d61daab
Commit
0d61daab
authored
7 years ago
by
Holger Nahrstaedt
Browse files
Options
Downloads
Patches
Plain Diff
add test_golos
testnet is not reliable, so using golos for testing
parent
4976a12a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
beembase/objects.py
+2
-0
2 additions, 0 deletions
beembase/objects.py
tests/test_golos.py
+34
-52
34 additions, 52 deletions
tests/test_golos.py
with
36 additions
and
52 deletions
beembase/objects.py
+
2
−
0
View file @
0d61daab
...
...
@@ -28,6 +28,8 @@ asset_precision = {
"
STEEM
"
:
3
,
"
VESTS
"
:
6
,
"
SBD
"
:
3
,
"
GBG
"
:
3
,
"
GOLOS
"
:
3
}
...
...
This diff is collapsed.
Click to expand it.
tests/test_
testnet
.py
→
tests/test_
golos
.py
+
34
−
52
View file @
0d61daab
...
...
@@ -22,9 +22,8 @@ from beemgrapheneapi.rpcutils import NumRetriesReached
# Py3 compatibility
import
sys
password
=
"
yfABsiDXWcCVyDC2udXGYD2psFUiQy
"
core_unit
=
"
STX
"
wif
=
"
5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
"
core_unit
=
"
GLS
"
class
Testcases
(
unittest
.
TestCase
):
...
...
@@ -33,44 +32,28 @@ class Testcases(unittest.TestCase):
super
().
__init__
(
*
args
,
**
kwargs
)
set_shared_steem_instance
(
None
)
self
.
bts
=
Steem
(
node
=
[
"
wss://testnet.steem.vc
"
],
node
=
[
"
wss://ws.golos.io
"
],
keys
=
{
"
active
"
:
wif
,
"
owner
"
:
wif
,
"
memo
"
:
wif
},
nobroadcast
=
True
,
)
# from getpass import getpass
# self.bts.wallet.unlock(getpass())
set_shared_steem_instance
(
self
.
bts
)
self
.
bts
.
set_default_account
(
"
beem
"
)
stm
=
self
.
bts
stm
.
wallet
.
wipe
(
True
)
stm
.
wallet
.
create
(
"
123
"
)
stm
.
wallet
.
unlock
(
"
123
"
)
account_name
=
"
beem
"
active_key
=
PasswordKey
(
account_name
,
password
,
role
=
"
active
"
,
prefix
=
stm
.
prefix
)
owner_key
=
PasswordKey
(
account_name
,
password
,
role
=
"
owner
"
,
prefix
=
stm
.
prefix
)
posting_key
=
PasswordKey
(
account_name
,
password
,
role
=
"
posting
"
,
prefix
=
stm
.
prefix
)
memo_key
=
PasswordKey
(
account_name
,
password
,
role
=
"
memo
"
,
prefix
=
stm
.
prefix
)
active_privkey
=
active_key
.
get_private_key
()
posting_privkey
=
posting_key
.
get_private_key
()
owner_privkey
=
owner_key
.
get_private_key
()
memo_privkey
=
memo_key
.
get_private_key
()
stm
.
wallet
.
addPrivateKey
(
owner_privkey
)
stm
.
wallet
.
addPrivateKey
(
active_privkey
)
stm
.
wallet
.
addPrivateKey
(
memo_privkey
)
stm
.
wallet
.
addPrivateKey
(
posting_privkey
)
self
.
bts
.
set_default_account
(
"
test
"
)
def
test_transfer
(
self
):
bts
=
self
.
bts
# bts.prefix ="STX"
acc
=
Account
(
"
beem
"
,
steem_instance
=
bts
)
acc
=
Account
(
"
test
"
,
steem_instance
=
bts
)
tx
=
acc
.
transfer
(
"
test1
"
,
1.33
,
"
SBD
"
,
memo
=
"
Foobar
"
)
"
test1
"
,
1.33
,
"
GBG
"
,
memo
=
"
Foobar
"
)
self
.
assertEqual
(
tx
[
"
operations
"
][
0
][
0
],
"
transfer
"
)
op
=
tx
[
"
operations
"
][
0
][
1
]
self
.
assertIn
(
"
memo
"
,
op
)
self
.
assertEqual
(
op
[
"
from
"
],
"
beem
"
)
self
.
assertEqual
(
op
[
"
from
"
],
"
test
"
)
self
.
assertEqual
(
op
[
"
to
"
],
"
test1
"
)
amount
=
Amount
(
op
[
"
amount
"
])
self
.
assertEqual
(
float
(
amount
),
1.33
)
...
...
@@ -85,7 +68,7 @@ class Testcases(unittest.TestCase):
key5
=
PrivateKey
()
tx
=
bts
.
create_account
(
name
,
creator
=
"
beem
"
,
creator
=
"
test
"
,
owner_key
=
format
(
key1
.
pubkey
,
core_unit
),
active_key
=
format
(
key2
.
pubkey
,
core_unit
),
posting_key
=
format
(
key3
.
pubkey
,
core_unit
),
...
...
@@ -123,15 +106,14 @@ class Testcases(unittest.TestCase):
[
x
[
0
]
for
x
in
op
[
role
][
"
account_auths
"
]])
self
.
assertEqual
(
op
[
"
creator
"
],
"
beem
"
)
"
test
"
)
def
test_connect
(
self
):
self
.
bts
.
connect
(
node
=
[
"
wss://testnet.steem.vc
"
])
bts
=
self
.
bts
self
.
assertEqual
(
bts
.
prefix
,
"
STX
"
)
self
.
assertEqual
(
bts
.
prefix
,
"
GLS
"
)
def
test_set_default_account
(
self
):
self
.
bts
.
set_default_account
(
"
beem
"
)
self
.
bts
.
set_default_account
(
"
test
"
)
def
test_info
(
self
):
info
=
self
.
bts
.
info
()
...
...
@@ -150,10 +132,10 @@ class Testcases(unittest.TestCase):
tx1
=
bts
.
new_tx
()
tx2
=
bts
.
new_tx
()
acc
=
Account
(
"
beem
"
,
steem_instance
=
bts
)
acc
.
transfer
(
"
test1
"
,
1
,
"
STEEM
"
,
append_to
=
tx1
)
acc
.
transfer
(
"
test1
"
,
2
,
"
STEEM
"
,
append_to
=
tx2
)
acc
.
transfer
(
"
test1
"
,
3
,
"
STEEM
"
,
append_to
=
tx1
)
acc
=
Account
(
"
test
"
,
steem_instance
=
bts
)
acc
.
transfer
(
"
test1
"
,
1
,
"
GOLOS
"
,
append_to
=
tx1
)
acc
.
transfer
(
"
test1
"
,
2
,
"
GOLOS
"
,
append_to
=
tx2
)
acc
.
transfer
(
"
test1
"
,
3
,
"
GOLOS
"
,
append_to
=
tx1
)
tx1
=
tx1
.
json
()
tx2
=
tx2
.
json
()
ops1
=
tx1
[
"
operations
"
]
...
...
@@ -166,15 +148,15 @@ class Testcases(unittest.TestCase):
auth
=
{
'
account_auths
'
:
[[
'
test
'
,
1
]],
'
extensions
'
:
[],
'
key_auths
'
:
[
[
'
STX
55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n
'
,
1
],
[
'
STX
7GM9YXcsoAJAgKbqW2oVj7bnNXFNL4pk9NugqKWPmuhoEDbkDv
'
,
1
]],
[
'
GLS
55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n
'
,
1
],
[
'
GLS
7GM9YXcsoAJAgKbqW2oVj7bnNXFNL4pk9NugqKWPmuhoEDbkDv
'
,
1
]],
'
weight_threshold
'
:
3
}
# threshold fine
bts
.
_test_weights_treshold
(
auth
)
auth
=
{
'
account_auths
'
:
[[
'
test
'
,
1
]],
'
extensions
'
:
[],
'
key_auths
'
:
[
[
'
STX
55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n
'
,
1
],
[
'
STX
7GM9YXcsoAJAgKbqW2oVj7bnNXFNL4pk9NugqKWPmuhoEDbkDv
'
,
1
]],
[
'
GLS
55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n
'
,
1
],
[
'
GLS
7GM9YXcsoAJAgKbqW2oVj7bnNXFNL4pk9NugqKWPmuhoEDbkDv
'
,
1
]],
'
weight_threshold
'
:
4
}
# too high
with
self
.
assertRaises
(
ValueError
):
...
...
@@ -182,12 +164,12 @@ class Testcases(unittest.TestCase):
def
test_allow
(
self
):
bts
=
self
.
bts
self
.
assertIn
(
bts
.
prefix
,
"
STX
"
)
acc
=
Account
(
"
beem
"
,
steem_instance
=
bts
)
self
.
assertIn
(
acc
.
steem
.
prefix
,
"
STX
"
)
self
.
assertIn
(
bts
.
prefix
,
"
GLS
"
)
acc
=
Account
(
"
test
"
,
steem_instance
=
bts
)
self
.
assertIn
(
acc
.
steem
.
prefix
,
"
GLS
"
)
tx
=
acc
.
allow
(
"
STX
55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n
"
,
account
=
"
beem
"
,
"
GLS
55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n
"
,
account
=
"
test
"
,
weight
=
1
,
threshold
=
1
,
permission
=
"
owner
"
,
...
...
@@ -199,27 +181,27 @@ class Testcases(unittest.TestCase):
op
=
tx
[
"
operations
"
][
0
][
1
]
self
.
assertIn
(
"
owner
"
,
op
)
self
.
assertIn
(
[
"
STX
55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n
"
,
'
1
'
],
[
"
GLS
55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n
"
,
'
1
'
],
op
[
"
owner
"
][
"
key_auths
"
])
self
.
assertEqual
(
op
[
"
owner
"
][
"
weight_threshold
"
],
1
)
def
test_disallow
(
self
):
bts
=
self
.
bts
acc
=
Account
(
"
beem
"
,
steem_instance
=
bts
)
acc
=
Account
(
"
test
"
,
steem_instance
=
bts
)
if
sys
.
version
>
'
3
'
:
_assertRaisesRegex
=
self
.
assertRaisesRegex
else
:
_assertRaisesRegex
=
self
.
assertRaisesRegexp
with
_assertRaisesRegex
(
ValueError
,
"
.*Changes nothing.*
"
):
acc
.
disallow
(
"
STX
55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n
"
,
"
GLS
55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n
"
,
weight
=
1
,
threshold
=
1
,
permission
=
"
owner
"
)
with
_assertRaisesRegex
(
ValueError
,
"
.*Changes nothing!.*
"
):
acc
.
disallow
(
"
STX
6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
"
,
"
GLS
6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
"
,
weight
=
1
,
threshold
=
1
,
permission
=
"
owner
"
...
...
@@ -227,9 +209,9 @@ class Testcases(unittest.TestCase):
def
test_update_memo_key
(
self
):
bts
=
self
.
bts
self
.
assertEqual
(
bts
.
prefix
,
"
STX
"
)
acc
=
Account
(
"
beem
"
,
steem_instance
=
bts
)
tx
=
acc
.
update_memo_key
(
"
STX
55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n
"
)
self
.
assertEqual
(
bts
.
prefix
,
"
GLS
"
)
acc
=
Account
(
"
test
"
,
steem_instance
=
bts
)
tx
=
acc
.
update_memo_key
(
"
GLS
55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n
"
)
self
.
assertEqual
(
(
tx
[
"
operations
"
][
0
][
0
]),
"
account_update
"
...
...
@@ -237,11 +219,11 @@ class Testcases(unittest.TestCase):
op
=
tx
[
"
operations
"
][
0
][
1
]
self
.
assertEqual
(
op
[
"
memo_key
"
],
"
STX
55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n
"
)
"
GLS
55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n
"
)
def
test_approvewitness
(
self
):
bts
=
self
.
bts
w
=
Account
(
"
beem
"
,
steem_instance
=
bts
)
w
=
Account
(
"
test
"
,
steem_instance
=
bts
)
tx
=
w
.
approvewitness
(
"
test1
"
)
self
.
assertEqual
(
(
tx
[
"
operations
"
][
0
][
0
]),
...
...
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