diff --git a/beem/comment.py b/beem/comment.py index 570dc893afc04279b4385efae693eed65f0070ee..51f88c628f9097ffd4c39d6d9bdf1220030c0b93 100644 --- a/beem/comment.py +++ b/beem/comment.py @@ -599,6 +599,8 @@ class Comment(BlockchainObject): :param str voter: (optional) Voting account """ + if weight < 0: + raise ValueError("Weight must be >= 0.") last_payout = self.get('last_payout', None) if last_payout is not None: if formatToTimeStamp(last_payout) > 0: @@ -613,6 +615,8 @@ class Comment(BlockchainObject): :param str voter: (optional) Voting account """ + if weight < 0: + raise ValueError("Weight must be >= 0.") last_payout = self.get('last_payout', None) if last_payout is not None: if formatToTimeStamp(last_payout) > 0: diff --git a/tests/beem/test_comment.py b/tests/beem/test_comment.py index 4fad9f72f385f94096557c601c95389346178e8d..35043b80a108fe2b3daea1aef53401d3e148854a 100644 --- a/tests/beem/test_comment.py +++ b/tests/beem/test_comment.py @@ -134,12 +134,13 @@ class Testcases(unittest.TestCase): tx = c.upvote(weight=99.9, voter="test") op = tx["operations"][0][1] self.assertEqual(op["weight"], 9990) + c.steem.txbuffer.clear() - tx = c.downvote(weight=-150, voter="test") + tx = c.downvote(weight=150, voter="test") op = tx["operations"][0][1] self.assertEqual(op["weight"], -10000) c.steem.txbuffer.clear() - tx = c.downvote(weight=-99.9, voter="test") + tx = c.downvote(weight=99.9, voter="test") op = tx["operations"][0][1] self.assertEqual(op["weight"], -9990) diff --git a/tests/beem/test_nodelist.py b/tests/beem/test_nodelist.py index e888f0629990f95c595b71f5b46bb286f84c1674..bac38449d3813584971f829c4e5998a114a12b07 100644 --- a/tests/beem/test_nodelist.py +++ b/tests/beem/test_nodelist.py @@ -24,7 +24,7 @@ class Testcases(unittest.TestCase): def test_get_nodes(self): nodelist = NodeList() all_nodes = nodelist.get_nodes(exclude_limited=False, dev=True, testnet=True, testnetdev=True) - self.assertEqual(len(nodelist) - 15, len(all_nodes)) + self.assertEqual(len(nodelist) - 22, len(all_nodes)) https_nodes = nodelist.get_nodes(wss=False) self.assertEqual(https_nodes[0][:5], 'https')