Skip to content
Snippets Groups Projects
Commit 78281e72 authored by Holger's avatar Holger
Browse files

Fix unit tests and adapt mvest/vest relation for vests_to_rshares

parent 0e23e1a5
No related branches found
No related tags found
No related merge requests found
......@@ -163,6 +163,7 @@ Changelog
* bug fixed in allow and disallow for CLI
* Issue #52 closed thanks to crokkon
* Issue #64 fixed
* Issue #66 fixed thanks to flugschwein
0.19.52
-------
......
......@@ -558,7 +558,7 @@ class Steem(object):
"""
# calculate our account voting shares (from vests)
vesting_shares = int(self.sp_to_vests(steem_power, use_stored_data=use_stored_data) * 1e6)
vesting_shares = int(self.sp_to_vests(steem_power, use_stored_data=use_stored_data))
return self.vests_to_rshares(vesting_shares, voting_power=voting_power, vote_pct=vote_pct, use_stored_data=use_stored_data)
def vests_to_rshares(self, vests, voting_power=STEEM_100_PERCENT, vote_pct=STEEM_100_PERCENT, use_stored_data=True):
......
......@@ -11,6 +11,7 @@ import time
from pprint import pprint
from beem import Steem
from beem.blockchain import Blockchain
from beem.exceptions import BlockWaitTimeExceeded
from beem.block import Block
from beem.instance import set_shared_steem_instance
from beem.nodelist import NodeList
......@@ -234,15 +235,24 @@ class Testcases(unittest.TestCase):
bts = self.bts
else:
bts = self.appbase
b = Blockchain(steem_instance=bts, max_block_wait_repetition=6)
b = Blockchain(steem_instance=bts, max_block_wait_repetition=18)
start_num = b.get_current_block_num()
blocknum = start_num
last_fetched_block_num = None
for i in range(3):
block = b.wait_for_and_get_block(blocknum)
last_fetched_block_num = block.block_num
blocknum = last_fetched_block_num + 2
self.assertEqual(last_fetched_block_num, start_num + 4)
blocknum = last_fetched_block_num + 1
self.assertEqual(last_fetched_block_num, start_num + 2)
b2 = Blockchain(steem_instance=bts, max_block_wait_repetition=1)
with self.assertRaises(
BlockWaitTimeExceeded
):
for i in range(300):
block = b2.wait_for_and_get_block(blocknum)
last_fetched_block_num = block.block_num
blocknum = last_fetched_block_num + 2
def test_hash_op(self):
bts = self.bts
......
......@@ -24,7 +24,7 @@ class Testcases(unittest.TestCase):
def test_get_nodes(self):
nodelist = NodeList()
all_nodes = nodelist.get_nodes(normal=True, appbase=True, dev=True, testnet=True, testnetdev=True)
self.assertEqual(len(nodelist) - 2, len(all_nodes))
self.assertEqual(len(nodelist) - 6, len(all_nodes))
https_nodes = nodelist.get_nodes(wss=False)
self.assertEqual(https_nodes[0][:5], 'https')
......
......@@ -576,6 +576,12 @@ class Testcases(unittest.TestCase):
rshares = stm.sp_to_rshares(stm.vests_to_sp(1e6))
self.assertTrue(abs(rshares - 20000000000.0) < 2)
def test_rshares_to_vests(self):
stm = self.bts
rshares = stm.sp_to_rshares(stm.vests_to_sp(1e6))
rshares2 = stm.vests_to_rshares(1e6)
self.assertTrue(abs(rshares - rshares2) < 2)
def test_sp_to_sbd(self):
stm = self.bts
sp = 500
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment