Skip to content

Commit

Permalink
Merge branch 'release/1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
xeroc committed Oct 4, 2019
2 parents 3de5bd6 + a677806 commit 08cb456
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 48 deletions.
6 changes: 6 additions & 0 deletions .changes/1.2.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"description": "Use the last irreversible block for tapos ref params",
"type": "minor"
}
]
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,3 @@ target/
.ropeproject/
.pytest_cache/
.scannerwork/

.changes/next-release
10 changes: 5 additions & 5 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
699 Fabian Schuh <[email protected]>
735 Fabian Schuh <[email protected]>
154 Fabian Schuh <[email protected]>
77 Fabian Schuh <[email protected]>
24 pyup-bot <[email protected]>
90 Fabian Schuh <[email protected]>
48 pyup-bot <[email protected]>
20 gileadmcgee <[email protected]>
10 jhtitor <[email protected]>
10 user name <[email protected]>
9 jhtitor <[email protected]>
8 Maurits <[email protected]>
5 Vladimir Kamarzin <[email protected]>
4 bitcrab <[email protected]>
3 Boombastic <[email protected]>
3 Holger Nahrstaedt <[email protected]>
3 Vladimir Kamarzin <[email protected]>
3 abitmore <[email protected]>
2 Nicolas Wack <[email protected]>
2 Scott Howard <[email protected]>
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
Note: version releases in the 0.x.y range may introduce breaking changes.

## 1.2.0

- minor: Use the last irreversible block for tapos ref params

## 1.1.20

- patch: updates from pyup
Expand Down
20 changes: 14 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,30 @@ docs:
sphinx-apidoc -d 6 -e -f -o docs . *.py tests
make -C docs clean html

docs_store:
git add docs
-git commit -m "Updating docs/"

authors:
git shortlog -e -s -n > AUTHORS

authors_store:
git add AUTHORS
-git commit -m "Updating Authors"

semver: semver-release semver-updates

semver-release:
semversioner release
-semversioner release

semver-updates:
semversioner changelog > CHANGELOG.md
$(eval CURRENT_VERSION = $(shell semversioner current-version))
sed -i "s/^__version__.*/__version__ = \"$(CURRENT_VERSION)\"/" setup.py
git add .changes setup.py CHANGELOG.md
git commit -m "semverioner release updates" --no-verify
git flow release start $(CURRENT_VERSION)
-git add .changes setup.py CHANGELOG.md
-git commit -m "semverioner release updates" --no-verify
-git flow release start $(CURRENT_VERSION)
git flow release finish $(CURRENT_VERSION)

prerelease: test docs authors
release: semver clean check dist upload git
prerelease: test docs docs_store authors authors_store
release: prerelease semver clean build check dist upload git
4 changes: 2 additions & 2 deletions docs/modules.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
python-graphenelib
==================
python-graphene
===============

.. toctree::
:maxdepth: 6
Expand Down
8 changes: 7 additions & 1 deletion grapheneapi/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ def parse_response(self, query):
if "detail" in ret["error"]:
raise RPCError(ret["error"]["detail"])
else:
raise RPCError(ret["error"]["message"])
if ret["error"]["message"] == "Execution error":
text = ret["error"]["data"]["stack"][0]["format"]
data = ret["error"]["data"]["stack"][0]["data"]
text = text.replace("${", "{")
raise RPCError(text.format(**data))
else:
raise RPCError(ret["error"]["message"])
else:
return ret["result"]

Expand Down
12 changes: 5 additions & 7 deletions graphenebase/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@
timeformat = "%Y-%m-%dT%H:%M:%S%Z"


def getBlockParams(ws):
def getBlockParams(ws, use_head_block=False):
""" Auxiliary method to obtain ``ref_block_num`` and
``ref_block_prefix``. Requires a websocket connection to a
witness node!
"""
dynBCParams = ws.get_dynamic_global_properties()
ref_block_num = dynBCParams["head_block_number"] & 0xFFFF
ref_block_prefix = struct.unpack_from(
"<I", unhexlify(dynBCParams["head_block_id"]), 4
)[0]
return ref_block_num, ref_block_prefix
raise DeprecationWarning(
"This method shouldn't be called anymore. It is part of "
"transactionbuilder now"
)


def formatTimeFromNow(secs=0):
Expand Down
18 changes: 13 additions & 5 deletions graphenecommon/transactionbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,17 +405,25 @@ def constructTx(self):
dict.update(self, self.tx.json())
self._unset_require_reconstruction()

def get_block_params(self):
def get_block_params(self, use_head_block=False):
""" Auxiliary method to obtain ``ref_block_num`` and
``ref_block_prefix``. Requires a websocket connection to a
witness node!
"""
ws = self.blockchain.rpc
dynBCParams = ws.get_dynamic_global_properties()
ref_block_num = dynBCParams["head_block_number"] & 0xFFFF
ref_block_prefix = struct.unpack_from(
"<I", unhexlify(dynBCParams["head_block_id"]), 4
)[0]
if use_head_block:
ref_block_num = dynBCParams["head_block_number"] & 0xFFFF
ref_block_prefix = struct.unpack_from(
"<I", unhexlify(dynBCParams["head_block_id"]), 4
)[0]
else:
# need to get subsequent block because block head doesn't return 'id' - stupid
block = ws.get_block_header(int(dynBCParams["last_irreversible_block_num"])+1)
ref_block_num = dynBCParams["last_irreversible_block_num"] & 0xFFFF
ref_block_prefix = struct.unpack_from(
"<I", unhexlify(block["previous"]), 4
)[0]
return ref_block_num, ref_block_prefix

def sign(self):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from setuptools import setup

__version__ = "1.1.20"
__version__ = "1.2.0"
URL = "https://github.com/xeroc/python-graphenelib"

setup(
Expand Down
14 changes: 7 additions & 7 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ def test_cconnection_exceptions(self):
api.get_objects(["2.8.0"])

def test_raise_rpc_error_wss(self):
api = Api(urls[0], num_retries=-1)
api = Api(urls[0], num_retries=1)
with self.assertRaises(exceptions.RPCError):
api.get_SOMETHING(["2.8.0"])
api.connection.disconnect()
api.connection.disconnect()

def test_raise_rpc_error_https(self):
api = Api(urls[1], num_retries=-1)
with self.assertRaises(exceptions.RPCError):
api.get_SOMETHING(["2.8.0"])
#def test_raise_rpc_error_https(self):
# api = Api(urls[1], num_retries=1)
# with self.assertRaises(exceptions.RPCError):
# api.get_SOMETHING(["2.8.0"])

def test_login(self):
Api(urls[0], "User", "password", num_retries=-1)
Api(urls[0], None, None, num_retries=-1)
Api(urls[0], "User", "password", num_retries=1)
Api(urls[0], None, None, num_retries=1)

def test_rollover(self):
api = Api(["http://error.example.com", "wss://node.bitshares.eu"])
Expand Down
24 changes: 12 additions & 12 deletions tests/test_tapos_params.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
import unittest
from .fixtures import Chain
from datetime import datetime
from graphenebase.transactions import getBlockParams


class Testcases(unittest.TestCase):
def test_checkparamformating(self):
chain = Chain()
params = getBlockParams(chain.rpc)
self.assertEqual(params, (53066, 3847813018))
# # -*- coding: utf-8 -*-
# import unittest
# from .fixtures import Chain
# from datetime import datetime
# from graphenebase.transactions import getBlockParams
#
#
# class Testcases(unittest.TestCase):
# def test_checkparamformating(self):
# chain = Chain()
# params = getBlockParams(chain.rpc)
# self.assertEqual(params, (53066, 3847813018))

0 comments on commit 08cb456

Please sign in to comment.