Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wax
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
wax
Commits
0f99e1a4
Commit
0f99e1a4
authored
1 month ago
by
Michał Kudela
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for calculate functions
parent
39971e7c
No related branches found
No related tags found
2 merge requests
!262
Duplicate typeScript tests to python
,
!230
Implementation of the python wax interface
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/tests/base_api/test_calculation.py
+73
-0
73 additions, 0 deletions
python/tests/base_api/test_calculation.py
with
73 additions
and
0 deletions
python/tests/base_api/test_calculation.py
0 → 100644
+
73
−
0
View file @
0f99e1a4
from
__future__
import
annotations
from
datetime
import
datetime
,
timezone
from
decimal
import
Decimal
from
typing
import
TYPE_CHECKING
import
pytest
if
TYPE_CHECKING
:
from
wax.interfaces
import
IWaxBaseInterface
@pytest.mark.describe
(
"
Should be able to calculate current manabar value using hive chain interface
"
)
def
test_current_manabar_calculation
(
wax
:
IWaxBaseInterface
)
->
None
:
manabar
=
wax
.
calculate_current_manabar_value
(
head_block_time
=
datetime
.
fromtimestamp
(
1702548351
,
tz
=
timezone
.
utc
),
max_mana
=
2196088774870643
,
current_mana
=
1952744111294225
,
last_update_time
=
1702548249
,
)
assert
manabar
.
current_mana
==
1953262632254958
assert
manabar
.
max_mana
==
2196088774870643
assert
manabar
.
percent
==
Decimal
(
"
88.94
"
)
@pytest.mark.describe
(
"
Should be able to calculate witness votes HP
"
)
def
test_calculate_witness_votes_hp_0
(
wax
:
IWaxBaseInterface
)
->
None
:
# real input data for 5 million node
calculated_votes
=
wax
.
calculate_witness_votes_hp
(
number
=
147408633689698596
,
total_vesting_fund_hive
=
wax
.
hive
.
satoshis
(
180520335089
),
total_vesting_shares
=
wax
.
vests
.
satoshis
(
304505804867506145
),
)
assert
calculated_votes
==
wax
.
hive
.
satoshis
(
87388337178
)
@pytest.mark.describe
(
"
Should be able to calculate witness votes HP with mixed params
"
)
def
test_calculate_witness_votes_hp_1
(
wax
:
IWaxBaseInterface
)
->
None
:
# real input data for 5 million node
calculated_votes
=
wax
.
calculate_witness_votes_hp
(
number
=
147408633689698596
,
total_vesting_fund_hive
=
wax
.
hive
.
satoshis
(
180520335089
),
total_vesting_shares
=
wax
.
vests
.
coins
(
304505804867.506145
),
)
assert
calculated_votes
==
wax
.
hive
.
coins
(
87388337.178
)
@pytest.mark.parametrize
(
"
unit_amount
"
,
[
"
coins
"
,
"
satoshis
"
])
@pytest.mark.describe
(
"
Should be able to calculate account HP - coins/satoshis
"
)
def
test_calculate_account_hp_0
(
wax
:
IWaxBaseInterface
,
unit_amount
:
str
)
->
None
:
hive_unit
=
getattr
(
wax
.
hive
,
unit_amount
)
vests_unit
=
getattr
(
wax
.
vests
,
unit_amount
)
calculated_hp
=
wax
.
calculate_account_hp
(
vests
=
vests_unit
(
10
),
total_vesting_fund_hive
=
hive_unit
(
10
),
total_vesting_shares
=
vests_unit
(
10
),
)
assert
calculated_hp
==
hive_unit
(
10
)
@pytest.mark.describe
(
"
Should be able to calculate account HP with mixed params
"
)
def
test_calculate_account_hp_1
(
wax
:
IWaxBaseInterface
)
->
None
:
calculated_hp
=
wax
.
calculate_account_hp
(
vests
=
wax
.
vests
.
coins
(
10
),
total_vesting_fund_hive
=
wax
.
hive
.
satoshis
(
10
),
total_vesting_shares
=
wax
.
vests
.
satoshis
(
10
),
)
assert
calculated_hp
==
wax
.
hive
.
coins
(
10_000
)
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