Skip to content
Snippets Groups Projects
Commit 1ff3f2f4 authored by Holger Nahrstaedt's avatar Holger Nahrstaedt
Browse files

Bug fixes, use_condenser is set to False again

parent 6e64c2d3
No related branches found
No related tags found
No related merge requests found
...@@ -464,10 +464,10 @@ class Blockchain(object): ...@@ -464,10 +464,10 @@ class Blockchain(object):
if len(op_type) > 10 and op_type[len(op_type) - 10:] == "_operation": if len(op_type) > 10 and op_type[len(op_type) - 10:] == "_operation":
op_type = op_type[:-10] op_type = op_type[:-10]
op = event["value"] op = event["value"]
trx_id = event.get("trx_id") trx_id = block["transaction_ids"][trx_nr]
block_num = event.get("block") block_num = block.get("id")
_id = self.hash_op(event) _id = self.hash_op(event)
timestamp = formatTimeString(event.get("timestamp")) timestamp = formatTimeString(block.get("timestamp"))
else: else:
op_type, op = event["op"] op_type, op = event["op"]
trx_id = event.get("trx_id") trx_id = event.get("trx_id")
......
...@@ -482,7 +482,7 @@ class Comment(BlockchainObject): ...@@ -482,7 +482,7 @@ class Comment(BlockchainObject):
""" """
if self.get('net_rshares', None) is None: if self.get('net_rshares', None) is None:
raise VotingInvalidOnArchivedPost raise VotingInvalidOnArchivedPost
return self.vote(weight, voter=voter) return self.vote(weight, account=voter)
def downvote(self, weight=-100, voter=None): def downvote(self, weight=-100, voter=None):
""" Downvote the post """ Downvote the post
...@@ -494,7 +494,7 @@ class Comment(BlockchainObject): ...@@ -494,7 +494,7 @@ class Comment(BlockchainObject):
""" """
if self.get('net_rshares', None) is None: if self.get('net_rshares', None) is None:
raise VotingInvalidOnArchivedPost raise VotingInvalidOnArchivedPost
return self.vote(weight, voter=voter) return self.vote(weight, account=voter)
def vote(self, weight, account=None, identifier=None, **kwargs): def vote(self, weight, account=None, identifier=None, **kwargs):
""" Vote for a post """ Vote for a post
......
...@@ -148,7 +148,7 @@ class GrapheneRPC(object): ...@@ -148,7 +148,7 @@ class GrapheneRPC(object):
self.rpc_queue = [] self.rpc_queue = []
self.timeout = kwargs.get('timeout', 60) self.timeout = kwargs.get('timeout', 60)
self.num_retries = kwargs.get("num_retries", -1) self.num_retries = kwargs.get("num_retries", -1)
self.use_condenser = kwargs.get("use_condenser", True) self.use_condenser = kwargs.get("use_condenser", False)
self.error_cnt = {} self.error_cnt = {}
self.num_retries_call = kwargs.get("num_retries_call", 5) self.num_retries_call = kwargs.get("num_retries_call", 5)
self.error_cnt_call = 0 self.error_cnt_call = 0
...@@ -275,7 +275,9 @@ class GrapheneRPC(object): ...@@ -275,7 +275,9 @@ class GrapheneRPC(object):
if v["chain_id"] == chain_id and v["min_version"] <= network_version: if v["chain_id"] == chain_id and v["min_version"] <= network_version:
if highest_version_chain is None: if highest_version_chain is None:
highest_version_chain = v highest_version_chain = v
elif v["min_version"] > highest_version_chain["min_version"]: elif v["min_version"] == '0.0.0' and self.use_condenser:
highest_version_chain = v
elif v["min_version"] > highest_version_chain["min_version"] and not self.use_condenser:
highest_version_chain = v highest_version_chain = v
if highest_version_chain is None: if highest_version_chain is None:
raise("Connecting to unknown network!") raise("Connecting to unknown network!")
......
...@@ -442,11 +442,12 @@ class Testcases(unittest.TestCase): ...@@ -442,11 +442,12 @@ class Testcases(unittest.TestCase):
def test_json_export(self, node_param): def test_json_export(self, node_param):
if node_param == "non_appbase": if node_param == "non_appbase":
account = self.account account = self.account
content = self.bts.rpc.get_accounts([account["name"]])[0]
else: else:
account = self.account_appbase account = self.account_appbase
if account.steem.rpc.get_use_appbase():
content = self.appbase.rpc.find_accounts({'accounts': [account["name"]]}, api="database")["accounts"][0] content = self.appbase.rpc.find_accounts({'accounts': [account["name"]]}, api="database")["accounts"][0]
else:
content = self.bts.rpc.get_accounts([account["name"]])[0]
keys = list(content.keys()) keys = list(content.keys())
json_content = account.json() json_content = account.json()
......
...@@ -23,6 +23,7 @@ class Testcases(unittest.TestCase): ...@@ -23,6 +23,7 @@ class Testcases(unittest.TestCase):
cls.appbase = Steem( cls.appbase = Steem(
node=get_node_list(appbase=True), node=get_node_list(appbase=True),
nobroadcast=True, nobroadcast=True,
use_condenser=False,
num_retries=10 num_retries=10
) )
set_shared_steem_instance(cls.bts) set_shared_steem_instance(cls.bts)
......
...@@ -202,8 +202,14 @@ class Testcases(unittest.TestCase): ...@@ -202,8 +202,14 @@ class Testcases(unittest.TestCase):
for block in ops_blocks: for block in ops_blocks:
for tran in block["transactions"]: for tran in block["transactions"]:
for op in tran['operations']: for op in tran['operations']:
if op[0] in opNames: if isinstance(op, list) and op[0] in opNames:
op_stat4[op[0]] += 1 op_stat4[op[0]] += 1
elif isinstance(op, dict):
op_type = op["type"]
if len(op_type) > 10 and op_type[len(op_type) - 10:] == "_operation":
op_type = op_type[:-10]
if op_type in opNames:
op_stat4[op_type] += 1
self.assertTrue(block.identifier >= self.start) self.assertTrue(block.identifier >= self.start)
self.assertTrue(block.identifier <= self.stop) self.assertTrue(block.identifier <= self.stop)
self.assertEqual(op_stat["transfer"], op_stat4["transfer"]) self.assertEqual(op_stat["transfer"], op_stat4["transfer"])
......
...@@ -22,9 +22,10 @@ class Testcases(unittest.TestCase): ...@@ -22,9 +22,10 @@ class Testcases(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.bts = Steem( cls.bts = Steem(
node=get_node_list(appbase=True, testing=False), node=get_node_list(appbase=True, testing=True),
nobroadcast=True, nobroadcast=True,
num_retries=10, num_retries=10,
use_condenser=False,
keys={"active": wif}, keys={"active": wif},
) )
# from getpass import getpass # from getpass import getpass
...@@ -55,7 +56,13 @@ class Testcases(unittest.TestCase): ...@@ -55,7 +56,13 @@ class Testcases(unittest.TestCase):
for block in ops_blocks: for block in ops_blocks:
for tran in block["transactions"]: for tran in block["transactions"]:
for op in tran['operations']: for op in tran['operations']:
if op[0] in opNames: if isinstance(op, dict) and "type" in op and "value" in op:
op_type = op["type"]
if len(op_type) > 10 and op_type[len(op_type) - 10:] == "_operation":
op_type = op_type[:-10]
if op_type in opNames:
op_stat4[op_type] += 1
elif op[0] in opNames:
op_stat4[op[0]] += 1 op_stat4[op[0]] += 1
self.assertTrue(block.identifier >= self.start) self.assertTrue(block.identifier >= self.start)
self.assertTrue(block.identifier <= self.stop) self.assertTrue(block.identifier <= self.stop)
......
...@@ -138,10 +138,13 @@ class Testcases(unittest.TestCase): ...@@ -138,10 +138,13 @@ class Testcases(unittest.TestCase):
def test_export(self, node_param): def test_export(self, node_param):
if node_param == "non_appbase": if node_param == "non_appbase":
bts = self.bts bts = self.bts
content = bts.rpc.get_content(self.author, self.permlink)
else: else:
bts = self.appbase bts = self.appbase
if bts.rpc.get_use_appbase():
content = bts.rpc.get_discussion({'author': self.author, 'permlink': self.permlink}, api="tags") content = bts.rpc.get_discussion({'author': self.author, 'permlink': self.permlink}, api="tags")
else:
content = bts.rpc.get_content(self.author, self.permlink)
c = Comment(self.authorperm, steem_instance=bts) c = Comment(self.authorperm, steem_instance=bts)
keys = list(content.keys()) keys = list(content.keys())
......
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from builtins import range
from builtins import super
import mock
import string
import unittest
import random
from pprint import pprint
from beem import Steem
from beem.amount import Amount
from beem.witness import Witness
from beem.account import Account
from beem.instance import set_shared_steem_instance
from beem.blockchain import Blockchain
from beem.block import Block
from beem.wallet import Wallet
from beemgraphenebase.account import PasswordKey, PrivateKey, PublicKey
from beem.utils import parse_time, formatTimedelta, get_node_list
from beemgrapheneapi.rpcutils import NumRetriesReached
# Py3 compatibility
import sys
wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
core_unit = "GLS"
class Testcases(unittest.TestCase):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
set_shared_steem_instance(None)
self.stm = Steem(
node=get_node_list(appbase=False),
nobroadcast=True,
bundle=False,
# Overwrite wallet to use this list of wifs only
wif={"active": wif},
num_retries=10
)
self.bts = Steem(
node=["wss://ws.golos.io"],
keys={"active": wif, "owner": wif, "posting": wif},
nobroadcast=True,
num_retries=10
)
# from getpass import getpass
# self.bts.wallet.unlock(getpass())
def test_connect(self):
bts = self.bts
self.assertEqual(bts.prefix, "GLS")
def test_weight_threshold(self):
bts = self.bts
auth = {'account_auths': [['test', 1]],
'extensions': [],
'key_auths': [
['GLS55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n', 1],
['GLS7GM9YXcsoAJAgKbqW2oVj7bnNXFNL4pk9NugqKWPmuhoEDbkDv', 1]],
'weight_threshold': 3} # threshold fine
bts._test_weights_treshold(auth)
auth = {'account_auths': [['test', 1]],
'extensions': [],
'key_auths': [
['GLS55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n', 1],
['GLS7GM9YXcsoAJAgKbqW2oVj7bnNXFNL4pk9NugqKWPmuhoEDbkDv', 1]],
'weight_threshold': 4} # too high
with self.assertRaises(ValueError):
bts._test_weights_treshold(auth)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment