From 72e113ba11298cf97c75bc5ddcee0b9054ed8586 Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Fri, 8 Mar 2019 11:05:40 +0100 Subject: [PATCH 1/4] Unittesting --- grapheneapi/http.py | 2 +- grapheneapi/rpc.py | 4 +-- graphenebase/memo.py | 11 ++------ graphenebase/objects.py | 29 ++++++++----------- graphenebase/operations.py | 12 +------- graphenebase/types.py | 2 +- graphenestorage/masterpassword.py | 2 +- tests/fixtures.py | 6 ++++ tests/test_api.py | 1 + tests/test_tapos_params.py | 12 ++++++++ tests/test_types.py | 47 +++++++++++++++++++++++++++++++ 11 files changed, 86 insertions(+), 42 deletions(-) create mode 100644 tests/test_tapos_params.py diff --git a/grapheneapi/http.py b/grapheneapi/http.py index d6996b4c..74d92591 100644 --- a/grapheneapi/http.py +++ b/grapheneapi/http.py @@ -13,7 +13,7 @@ class Http(Rpc): """ RPC Calls """ - def proxies(self): + def proxies(self): # pragma: no cover proxy_url = self.get_proxy_url() if proxy_url is None: return None diff --git a/grapheneapi/rpc.py b/grapheneapi/rpc.py index 1dfb957c..0b49b96c 100644 --- a/grapheneapi/rpc.py +++ b/grapheneapi/rpc.py @@ -40,7 +40,7 @@ def __init__(self, url, **kwargs): def setup_proxy(self, options): proxy_url = options.pop("proxy", None) - if proxy_url: + if proxy_url: # pragma: no cover url = urllib.parse.urlparse(proxy_url) self.proxy_host = url.hostname self.proxy_port = url.port @@ -64,7 +64,7 @@ def setup_proxy(self, options): "Using proxy %s:%d %s" % (self.proxy_host, self.proxy_port, self.proxy_type) ) - def get_proxy_url(self): + def get_proxy_url(self): # pragma: no cover if not self.proxy_host: return None auth = "" diff --git a/graphenebase/memo.py b/graphenebase/memo.py index f6521047..692b1abb 100644 --- a/graphenebase/memo.py +++ b/graphenebase/memo.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import hashlib import struct import sys @@ -13,9 +14,6 @@ except ImportError: raise ImportError("Missing dependency: pyCryptodome") -" This class and the methods require python3 " -assert sys.version_info[0] == 3, "this library requires python3" - def get_shared_secret(priv, pub): """ Derive the share secret between ``priv`` and ``pub`` @@ -115,12 +113,9 @@ def decode_memo(priv, pub, nonce, message): " Checksum " checksum = cleartext[0:4] message = cleartext[4:] - try: - message = _unpad(message, 16) - except Exception as e: - raise ValueError(message) + message = _unpad(message, 16) " Verify checksum " check = hashlib.sha256(message).digest()[0:4] - if check != checksum: + if check != checksum: # pragma: no cover raise ValueError("checksum verification failure") return message.decode("utf8") diff --git a/graphenebase/objects.py b/graphenebase/objects.py index 1512753d..f7a0f994 100644 --- a/graphenebase/objects.py +++ b/graphenebase/objects.py @@ -135,7 +135,7 @@ def klass(self): @property def ops(self): - if callable(self.operations): + if callable(self.operations): # pragma: no cover # Legacy support return self.operations() else: @@ -180,7 +180,7 @@ def __init__(self, *args, **kwargs): super().__init__(self.detail(*args, **kwargs)) def __bytes__(self): - if len(self) is 0: + if len(self) == 0: return bytes() b = b"" for name, value in self.items(): @@ -191,11 +191,11 @@ def __bytes__(self): return b def __json__(self): - if len(self) is 0: + if len(self) == 0: return {} d = {} # JSON output is *not* ordered for name, value in self.items(): - if isinstance(value, Optional) and value.isempty(): + if isinstance(value, Optional) and value.isempty(): # pragma: no cover continue if isinstance(value, String): @@ -234,17 +234,10 @@ def isArgsThisClass(self, args): # Common Objects class Asset(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - super().__init__( - OrderedDict( - [ - ("amount", Int64(kwargs["amount"])), - ("asset_id", ObjectId(kwargs["asset_id"], "asset")), - ] - ) - ) + def detail(self, *args, **kwargs): + return OrderedDict( + [ + ("amount", Int64(kwargs["amount"])), + ("asset_id", ObjectId(kwargs["asset_id"], "asset")), + ] + ) diff --git a/graphenebase/operations.py b/graphenebase/operations.py index 185adbcb..646fdfd4 100644 --- a/graphenebase/operations.py +++ b/graphenebase/operations.py @@ -12,7 +12,7 @@ VoteId, ObjectId, ) -from .objects import GrapheneObject, isArgsThisClass +from .objects import GrapheneObject, isArgsThisClass, Asset from .account import PublicKey from .chains import default_prefix @@ -56,16 +56,6 @@ def detail(self, *args, **kwargs): ) -class Asset(GrapheneObject): - def detail(self, *args, **kwargs): - return OrderedDict( - [ - ("amount", Int64(kwargs["amount"])), - ("asset_id", ObjectId(kwargs["asset_id"], "asset")), - ] - ) - - class Permission(GrapheneObject): def detail(self, *args, **kwargs): prefix = kwargs.pop("prefix", default_prefix) diff --git a/graphenebase/types.py b/graphenebase/types.py index 7ec8f9ce..1893433e 100644 --- a/graphenebase/types.py +++ b/graphenebase/types.py @@ -264,7 +264,7 @@ def __str__(self): def isempty(self): if self.data is None: return True - if not bool(str(self.data)): + if not bool(str(self.data)): # pragma: no cover return True return not bool(bytes(self.data)) diff --git a/graphenestorage/masterpassword.py b/graphenestorage/masterpassword.py index 963a84f3..2737ba41 100644 --- a/graphenestorage/masterpassword.py +++ b/graphenestorage/masterpassword.py @@ -178,7 +178,7 @@ def encrypt(self, wif): raise WalletLocked return format(bip38.encrypt(str(wif), self.masterkey), "encwif") - def changePassword(self, newpassword): + def changePassword(self, newpassword): # pragma: no cover warnings.warn( "changePassword will be replaced by change_password in the future", PendingDeprecationWarning, diff --git a/tests/fixtures.py b/tests/fixtures.py index 2136ccc3..ff7ec3ba 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -149,6 +149,12 @@ def get_all_workers(self): def get_workers_by_account(self, name): return [self._load("workers")[0]] + def get_dynamic_global_properties(self): + return { + "head_block_id": "021dcf4a9af758e508364f16e3ab5ac928b7f76c", + "head_block_number": 35508042, + } + def __getattr__(self, name): def fun(self, *args, **kwargs): return {} diff --git a/tests/test_api.py b/tests/test_api.py index 9dfdb668..73ad5427 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -20,6 +20,7 @@ def test_chain_params(self): p.get("chain_id"), "4018d7844c78f6a6c41c6a552b898022310fc5dec06da467ee7905a8dad512c8", ) + self.assertIsInstance(api.api_id, dict) def test_websocket_connection(self): api = Api(urls[0]) diff --git a/tests/test_tapos_params.py b/tests/test_tapos_params.py new file mode 100644 index 00000000..6063ed2a --- /dev/null +++ b/tests/test_tapos_params.py @@ -0,0 +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)) diff --git a/tests/test_types.py b/tests/test_types.py index d8266211..aa4031fa 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import json import unittest +from binascii import hexlify, unhexlify from .fixtures import types from datetime import datetime @@ -368,3 +369,49 @@ class MyEnum(types.Enum8): with self.assertRaises(ValueError): MyEnum("barbar") + + def test_Hash(self): + u = types.Hash(hexlify(b"foobar").decode("ascii")) + self.assertEqual(bytes(u), b"foobar") + self.assertEqual(str(u), "666f6f626172") + self.assertEqual(u.json(), "666f6f626172") + + def test_ripemd160(self): + u = types.Ripemd160("37f332f68db77bd9d7edd4969571ad671cf9dd3b") + self.assertEqual( + bytes(u), b"7\xf32\xf6\x8d\xb7{\xd9\xd7\xed\xd4\x96\x95q\xadg\x1c\xf9\xdd;" + ) + self.assertEqual(str(u), "37f332f68db77bd9d7edd4969571ad671cf9dd3b") + self.assertEqual(u.json(), "37f332f68db77bd9d7edd4969571ad671cf9dd3b") + + with self.assertRaises(AssertionError): + types.Ripemd160("barbar") + + def test_sha1(self): + u = types.Sha1("37f332f68db77bd9d7edd4969571ad671cf9dd3b") + self.assertEqual( + bytes(u), b"7\xf32\xf6\x8d\xb7{\xd9\xd7\xed\xd4\x96\x95q\xadg\x1c\xf9\xdd;" + ) + self.assertEqual(str(u), "37f332f68db77bd9d7edd4969571ad671cf9dd3b") + self.assertEqual(u.json(), "37f332f68db77bd9d7edd4969571ad671cf9dd3b") + + with self.assertRaises(AssertionError): + types.Sha1("barbar") + + def test_sha256(self): + u = types.Sha256( + "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + ) + self.assertEqual( + bytes(u), + b"\xe3\xb0\xc4B\x98\xfc\x1c\x14\x9a\xfb\xf4\xc8\x99o\xb9$'\xaeA\xe4d\x9b\x93L\xa4\x95\x99\x1bxR\xb8U", + ) + self.assertEqual( + str(u), "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + ) + self.assertEqual( + u.json(), "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + ) + + with self.assertRaises(AssertionError): + types.Sha256("barbar") From f1999a263c38a0f3b25dc4c35b0679606bf4c37f Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Fri, 8 Mar 2019 14:55:18 +0100 Subject: [PATCH 2/4] Improve unittest coverage --- Makefile | 2 +- graphenebase/operations.py | 1 + graphenecommon/account.py | 16 +- tests/fixtures.py | 53 ++- tests/fixtures.yaml | 10 + tests/test_account.py | 50 ++- tests/vector_get_account_history.yaml | 456 ++++++++++++++++++++++++++ 7 files changed, 569 insertions(+), 19 deletions(-) create mode 100644 tests/vector_get_account_history.yaml diff --git a/Makefile b/Makefile index b26dc0ca..41bfe20a 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ clean-build: rm -fr build/ rm -fr dist/ rm -fr *.egg-info - rm -fr __pycache__/ .eggs/ .cache/ .tox/ + rm -fr __pycache__/ .eggs/ .cache/ .tox/ .pytest_cache/ .scannerwork/ clean-pyc: find . -name '*.pyc' -exec rm -f {} + diff --git a/graphenebase/operations.py b/graphenebase/operations.py index 646fdfd4..f4c5cdd7 100644 --- a/graphenebase/operations.py +++ b/graphenebase/operations.py @@ -15,6 +15,7 @@ from .objects import GrapheneObject, isArgsThisClass, Asset from .account import PublicKey from .chains import default_prefix +from .operationids import getOperationNameForId # Old style of defining an operation diff --git a/graphenecommon/account.py b/graphenecommon/account.py index f91a5989..ee138250 100644 --- a/graphenecommon/account.py +++ b/graphenecommon/account.py @@ -61,7 +61,7 @@ def refresh(self): raise AccountDoesNotExistsException(self.identifier) self.store(account, "name") - if self.full: + if self.full: # pragma: no cover accounts = self.blockchain.rpc.get_full_accounts([account["id"]], False) if accounts and isinstance(accounts, list): account = accounts[0][1] @@ -81,12 +81,12 @@ def name(self): return self["name"] @property - def is_fully_loaded(self): + def is_fully_loaded(self): # pragma: no cover """ Is this instance fully loaded / e.g. all data available? """ return self.full and "votes" in self - def ensure_full(self): + def ensure_full(self): # pragma: no cover if not self.is_fully_loaded: self.full = True self.refresh() @@ -170,7 +170,7 @@ def history(self, first=0, last=0, limit=-1, only_ops=[], exclude_ops=[]): ): cnt += 1 yield i - if limit >= 0 and cnt >= limit: + if limit >= 0 and cnt >= limit: # pragma: no cover return if not txs: @@ -181,25 +181,25 @@ def history(self, first=0, last=0, limit=-1, only_ops=[], exclude_ops=[]): break first = int(txs[-1]["id"].split(".")[2]) - def upgrade(self): + def upgrade(self): # pragma: no cover """ Upgrade account to life time member """ assert callable(self.blockchain.upgrade_account) return self.blockchain.upgrade_account(account=self) - def whitelist(self, account): + def whitelist(self, account): # pragma: no cover """ Add an other account to the whitelist of this account """ assert callable(self.blockchain.account_whitelist) return self.blockchain.account_whitelist(account, lists=["white"], account=self) - def blacklist(self, account): + def blacklist(self, account): # pragma: no cover """ Add an other account to the blacklist of this account """ assert callable(self.blockchain.account_whitelist) return self.blockchain.account_whitelist(account, lists=["black"], account=self) - def nolist(self, account): + def nolist(self, account): # pragma: no cover """ Remove an other account from any list of this account """ assert callable(self.blockchain.account_whitelist) diff --git a/tests/fixtures.py b/tests/fixtures.py index ff7ec3ba..263afb18 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -2,6 +2,7 @@ import os import mock import yaml +import json # Graphene API from grapheneapi import exceptions @@ -24,7 +25,6 @@ ) from graphenebase import types, utils from graphenebase.transactions import formatTimeFromNow, timeformat -from graphenebase.operations import Account_create from graphenebase.signedtransactions import Signed_Transaction, MissingSignatureForKey from graphenebase.account import ( BrainKey, @@ -36,8 +36,14 @@ BitcoinAddress, ) from graphenebase.objects import Operation, GrapheneObject -from graphenebase.operations import Newdemooepration, Newdemooepration2, Demooepration -from graphenebase.operationids import ops, operations, getOperationNameForId +from graphenebase.operations import ( + Newdemooepration, + Newdemooepration2, + Demooepration, + Account_create, +) +from graphenebase import operations as operations_module +from graphenebase.operationids import ops, getOperationNameForId, operations from graphenebase import bip38 from graphenebase.bip38 import encrypt, decrypt @@ -78,6 +84,18 @@ from graphenecommon.witness import Witness as GWitness, Witnesses as GWitnesss from graphenecommon.chain import AbstractGrapheneChain +objects_cache = dict() + + +def store_test_object(o): + global objects_cache + if o.get("id"): + objects_cache[o["id"]] = o + + +def get_object(id): + return objects_cache.get(id, {}) + class SharedInstance(GSharedInstance): pass @@ -131,14 +149,23 @@ def _load(self, name): d = yaml.safe_load(fid) return d.get(name) - def get_objects(self, *args, **kwargs): - return [] + def get_objects(self, ids, *args, **kwargs): + return [self.get_object(x) for x in ids] - def get_object(self, *args, **kwargs): - return {} + def get_object(self, id, *args, **kwargs): + return get_object(id) def get_account_history(self, *args, **kwargs): - return [] + with open( + os.path.join( + os.path.dirname(__file__), "vector_get_account_history.yaml" + ) + ) as fid: + history = yaml.safe_load(fid) + return history + + def get_account_balances(self, account, *args, **kwargs): + return [{"asset_id": "1.3.0", "amount": 132442}] def lookup_account_names(self, name, **kwargs): return [None] @@ -190,7 +217,7 @@ class Account(GAccount): def define_classes(self): self.type_id = 2 self.amount_class = Amount - self.operations = operations + self.operations = operations_module @BlockchainInstance.inject @@ -271,16 +298,22 @@ def fixture_data(): with open(os.path.join(os.path.dirname(__file__), "fixtures.yaml")) as fid: data = yaml.safe_load(fid) + for o in data.get("objects"): + store_test_object(o) + # Feed our objects into the caches! for account in data.get("accounts"): + store_test_object(account) Account._cache[account["id"]] = account Account._cache[account["name"]] = account for asset in data.get("assets"): + store_test_object(asset) Asset._cache[asset["symbol"]] = asset Asset._cache[asset["id"]] = asset for committee in data.get("committees"): + store_test_object(committee) Committee._cache[committee["id"]] = committee for blocknum, block in data.get("blocks").items(): @@ -288,7 +321,9 @@ def fixture_data(): Block._cache[str(blocknum)] = block for worker in data.get("workers"): + store_test_object(worker) Worker._cache[worker["id"]] = worker for witness in data.get("witnesses"): + store_test_object(witness) Witness._cache[witness["id"]] = witness diff --git a/tests/fixtures.yaml b/tests/fixtures.yaml index 3c22e64f..39360f97 100644 --- a/tests/fixtures.yaml +++ b/tests/fixtures.yaml @@ -244,3 +244,13 @@ workers: worker: - 1 - balance: '1.13.10000' + +objects: + - id: "2.6.100" + lifetime_fees_paid: "44261516129" + most_recent_op: "2.9.0" + owner: "1.2.100" + pending_fees: 0 + pending_vested_fees: 16310 + total_core_in_orders: "6788845277634" + total_ops: 0 diff --git a/tests/test_account.py b/tests/test_account.py index b1b2838f..997fdc6f 100644 --- a/tests/test_account.py +++ b/tests/test_account.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import unittest from .fixtures import fixture_data, Account, AccountUpdate, getOperationNameForId +from graphenecommon.exceptions import AccountDoesNotExistsException class Testcases(unittest.TestCase): @@ -17,10 +18,53 @@ def test_account(self): self.assertEqual(str(account), "") account = Account("1.2.100") self.assertEqual(str(account), "") - for h in account.history(limit=1): + for h in account.history(limit=1, first=-1): + pass + for h in account.history( + limit=1, first=2, exclude_ops=["newdemooepration"], only_ops=["fups"] + ): pass self.assertIsInstance(Account(account), Account) + self.assertFalse(account.is_ltm) + + def test_balances(self): + account = Account("init0", full=True) + balances = account.balances + self.assertEqual(len(balances), 1) + self.assertEqual(float(balances[0]), 1.32442) + self.assertEqual(str(balances[0]), "1.32442 GPH") + + balance = account.balance("GPH") + self.assertEqual(float(balance), 1.32442) + self.assertEqual(str(balance), "1.32442 GPH") + + balance = account.balance(dict(symbol="GPH")) + self.assertEqual(float(balance), 1.32442) + self.assertEqual(str(balance), "1.32442 GPH") + + balance = account.balance(dict(symbol="USD")) + self.assertEqual(float(balance), 0) + self.assertEqual(str(balance), "0.0000 USD") + + def test_history(self): + account = Account("init0", full=True) + for h in account.history(): + break + + def test_account_refresh(self): + account = Account("1.2.100") + account.refresh() + + def test_fail_lookup_name(self): + with self.assertRaises(AccountDoesNotExistsException): + account = Account("sf332sas") + account.refresh() + + with self.assertRaises(AccountDoesNotExistsException): + account = Account("1.2.100", full=True) + account.refresh() + def test_account_upgrade(self): account = Account("init0") account.upgrade() @@ -39,3 +83,7 @@ def test_accountupdate(self): update = AccountUpdate(t) self.assertEqual(update["owner"], "1.2.100") self.assertIsInstance(update.account, Account) + + update = AccountUpdate("1.2.100") + self.assertEqual(update["owner"], "1.2.100") + self.assertIsInstance(update.account, Account) diff --git a/tests/vector_get_account_history.yaml b/tests/vector_get_account_history.yaml new file mode 100644 index 00000000..0cba93fd --- /dev/null +++ b/tests/vector_get_account_history.yaml @@ -0,0 +1,456 @@ +- id: 1.11.782581103 + op: + - 1 + - fee: + amount: 48132 + asset_id: 1.3.0 + from: 1.2.114406 + to: 1.2.1098071 + amount: + amount: 25000000 + asset_id: 1.3.121 + memo: + from: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + to: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + nonce: '17232635877779709952' + message: 9b023eda7048249a7e97e18379d6eda506846d5bfd40abbd62c4a0ed53c9341c + extensions: [] + result: + - 0 + - {} + block_num: 35478865 + trx_in_block: 22 + op_in_trx: 0 + virtual_op: 43330 +- id: 1.11.782569067 + op: + - 0 + - fee: + amount: 48526 + asset_id: 1.3.0 + from: 1.2.114406 + to: 1.2.1098071 + amount: + amount: 11983699 + asset_id: 1.3.121 + memo: + from: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + to: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + nonce: '12905488011527272831' + message: 4ff51b6a52650f8de9ee5ee9bed1b3e0e7191bdf8e63e16232d9bd5c80e4e8f8d7960200198d090bcd51f93d1a0549ec + extensions: [] + result: + - 0 + - {} + block_num: 35478606 + trx_in_block: 4 + op_in_trx: 0 + virtual_op: 17964 +- id: 1.11.782568623 + op: + - 0 + - fee: + amount: 48526 + asset_id: 1.3.0 + from: 1.2.364315 + to: 1.2.114406 + amount: + amount: 11983699 + asset_id: 1.3.121 + memo: + from: BTS5LKaNYUyf4q91fqJCfXzkGCx5erx5pVV9ZUYZVpLdB7YJutwmN + to: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + nonce: '623295324347032752' + message: d9ff00faf606265218a37b5e87a035f72403072d9bfa1356779af69bc4ed74705a4dc3c883670e67273cdc06f2659b17 + extensions: [] + result: + - 0 + - {} + block_num: 35478593 + trx_in_block: 5 + op_in_trx: 0 + virtual_op: 17042 +- id: 1.11.782546383 + op: + - 0 + - fee: + amount: 48132 + asset_id: 1.3.0 + from: 1.2.364315 + to: 1.2.114406 + amount: + amount: 26250000 + asset_id: 1.3.121 + memo: + from: BTS5LKaNYUyf4q91fqJCfXzkGCx5erx5pVV9ZUYZVpLdB7YJutwmN + to: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + nonce: '4241633382289934858' + message: 25056c4c0bf57baf956438cdadda866f632d633a55b013fbbd6986f3f7bf89b0 + extensions: [] + result: + - 0 + - {} + block_num: 35478152 + trx_in_block: 13 + op_in_trx: 0 + virtual_op: 34366 +- id: 1.11.782546383 + op: + - 0 + - fee: + amount: 48132 + asset_id: 1.3.0 + from: 1.2.364315 + to: 1.2.114406 + amount: + amount: 26250000 + asset_id: 1.3.121 + memo: + from: BTS5LKaNYUyf4q91fqJCfXzkGCx5erx5pVV9ZUYZVpLdB7YJutwmN + to: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + nonce: '4241633382289934858' + message: 25056c4c0bf57baf956438cdadda866f632d633a55b013fbbd6986f3f7bf89b0 + extensions: [] + result: + - 0 + - {} + block_num: 35478152 + trx_in_block: 13 + op_in_trx: 0 + virtual_op: 34366 +- id: 1.11.782546383 + op: + - 0 + - fee: + amount: 48132 + asset_id: 1.3.0 + from: 1.2.364315 + to: 1.2.114406 + amount: + amount: 26250000 + asset_id: 1.3.121 + memo: + from: BTS5LKaNYUyf4q91fqJCfXzkGCx5erx5pVV9ZUYZVpLdB7YJutwmN + to: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + nonce: '4241633382289934858' + message: 25056c4c0bf57baf956438cdadda866f632d633a55b013fbbd6986f3f7bf89b0 + extensions: [] + result: + - 0 + - {} + block_num: 35478152 + trx_in_block: 13 + op_in_trx: 0 + virtual_op: 34366 +- id: 1.11.782546383 + op: + - 0 + - fee: + amount: 48132 + asset_id: 1.3.0 + from: 1.2.364315 + to: 1.2.114406 + amount: + amount: 26250000 + asset_id: 1.3.121 + memo: + from: BTS5LKaNYUyf4q91fqJCfXzkGCx5erx5pVV9ZUYZVpLdB7YJutwmN + to: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + nonce: '4241633382289934858' + message: 25056c4c0bf57baf956438cdadda866f632d633a55b013fbbd6986f3f7bf89b0 + extensions: [] + result: + - 0 + - {} + block_num: 35478152 + trx_in_block: 13 + op_in_trx: 0 + virtual_op: 34366 +- id: 1.11.782546383 + op: + - 0 + - fee: + amount: 48132 + asset_id: 1.3.0 + from: 1.2.364315 + to: 1.2.114406 + amount: + amount: 26250000 + asset_id: 1.3.121 + memo: + from: BTS5LKaNYUyf4q91fqJCfXzkGCx5erx5pVV9ZUYZVpLdB7YJutwmN + to: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + nonce: '4241633382289934858' + message: 25056c4c0bf57baf956438cdadda866f632d633a55b013fbbd6986f3f7bf89b0 + extensions: [] + result: + - 0 + - {} + block_num: 35478152 + trx_in_block: 13 + op_in_trx: 0 + virtual_op: 34366 +- id: 1.11.782546383 + op: + - 0 + - fee: + amount: 48132 + asset_id: 1.3.0 + from: 1.2.364315 + to: 1.2.114406 + amount: + amount: 26250000 + asset_id: 1.3.121 + memo: + from: BTS5LKaNYUyf4q91fqJCfXzkGCx5erx5pVV9ZUYZVpLdB7YJutwmN + to: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + nonce: '4241633382289934858' + message: 25056c4c0bf57baf956438cdadda866f632d633a55b013fbbd6986f3f7bf89b0 + extensions: [] + result: + - 0 + - {} + block_num: 35478152 + trx_in_block: 13 + op_in_trx: 0 + virtual_op: 34366 +- id: 1.11.782546383 + op: + - 0 + - fee: + amount: 48132 + asset_id: 1.3.0 + from: 1.2.364315 + to: 1.2.114406 + amount: + amount: 26250000 + asset_id: 1.3.121 + memo: + from: BTS5LKaNYUyf4q91fqJCfXzkGCx5erx5pVV9ZUYZVpLdB7YJutwmN + to: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + nonce: '4241633382289934858' + message: 25056c4c0bf57baf956438cdadda866f632d633a55b013fbbd6986f3f7bf89b0 + extensions: [] + result: + - 0 + - {} + block_num: 35478152 + trx_in_block: 13 + op_in_trx: 0 + virtual_op: 34366 +- id: 1.11.782546383 + op: + - 0 + - fee: + amount: 48132 + asset_id: 1.3.0 + from: 1.2.364315 + to: 1.2.114406 + amount: + amount: 26250000 + asset_id: 1.3.121 + memo: + from: BTS5LKaNYUyf4q91fqJCfXzkGCx5erx5pVV9ZUYZVpLdB7YJutwmN + to: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + nonce: '4241633382289934858' + message: 25056c4c0bf57baf956438cdadda866f632d633a55b013fbbd6986f3f7bf89b0 + extensions: [] + result: + - 0 + - {} + block_num: 35478152 + trx_in_block: 13 + op_in_trx: 0 + virtual_op: 34366 +- id: 1.11.782546383 + op: + - 0 + - fee: + amount: 48132 + asset_id: 1.3.0 + from: 1.2.364315 + to: 1.2.114406 + amount: + amount: 26250000 + asset_id: 1.3.121 + memo: + from: BTS5LKaNYUyf4q91fqJCfXzkGCx5erx5pVV9ZUYZVpLdB7YJutwmN + to: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + nonce: '4241633382289934858' + message: 25056c4c0bf57baf956438cdadda866f632d633a55b013fbbd6986f3f7bf89b0 + extensions: [] + result: + - 0 + - {} + block_num: 35478152 + trx_in_block: 13 + op_in_trx: 0 + virtual_op: 34366 +- id: 1.11.782546383 + op: + - 0 + - fee: + amount: 48132 + asset_id: 1.3.0 + from: 1.2.364315 + to: 1.2.114406 + amount: + amount: 26250000 + asset_id: 1.3.121 + memo: + from: BTS5LKaNYUyf4q91fqJCfXzkGCx5erx5pVV9ZUYZVpLdB7YJutwmN + to: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + nonce: '4241633382289934858' + message: 25056c4c0bf57baf956438cdadda866f632d633a55b013fbbd6986f3f7bf89b0 + extensions: [] + result: + - 0 + - {} + block_num: 35478152 + trx_in_block: 13 + op_in_trx: 0 + virtual_op: 34366 +- id: 1.11.782546383 + op: + - 0 + - fee: + amount: 48132 + asset_id: 1.3.0 + from: 1.2.364315 + to: 1.2.114406 + amount: + amount: 26250000 + asset_id: 1.3.121 + memo: + from: BTS5LKaNYUyf4q91fqJCfXzkGCx5erx5pVV9ZUYZVpLdB7YJutwmN + to: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + nonce: '4241633382289934858' + message: 25056c4c0bf57baf956438cdadda866f632d633a55b013fbbd6986f3f7bf89b0 + extensions: [] + result: + - 0 + - {} + block_num: 35478152 + trx_in_block: 13 + op_in_trx: 0 + virtual_op: 34366 +- id: 1.11.782546383 + op: + - 0 + - fee: + amount: 48132 + asset_id: 1.3.0 + from: 1.2.364315 + to: 1.2.114406 + amount: + amount: 26250000 + asset_id: 1.3.121 + memo: + from: BTS5LKaNYUyf4q91fqJCfXzkGCx5erx5pVV9ZUYZVpLdB7YJutwmN + to: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + nonce: '4241633382289934858' + message: 25056c4c0bf57baf956438cdadda866f632d633a55b013fbbd6986f3f7bf89b0 + extensions: [] + result: + - 0 + - {} + block_num: 35478152 + trx_in_block: 13 + op_in_trx: 0 + virtual_op: 34366 +- id: 1.11.782546383 + op: + - 0 + - fee: + amount: 48132 + asset_id: 1.3.0 + from: 1.2.364315 + to: 1.2.114406 + amount: + amount: 26250000 + asset_id: 1.3.121 + memo: + from: BTS5LKaNYUyf4q91fqJCfXzkGCx5erx5pVV9ZUYZVpLdB7YJutwmN + to: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + nonce: '4241633382289934858' + message: 25056c4c0bf57baf956438cdadda866f632d633a55b013fbbd6986f3f7bf89b0 + extensions: [] + result: + - 0 + - {} + block_num: 35478152 + trx_in_block: 13 + op_in_trx: 0 + virtual_op: 34366 +- id: 1.11.782546383 + op: + - 0 + - fee: + amount: 48132 + asset_id: 1.3.0 + from: 1.2.364315 + to: 1.2.114406 + amount: + amount: 26250000 + asset_id: 1.3.121 + memo: + from: BTS5LKaNYUyf4q91fqJCfXzkGCx5erx5pVV9ZUYZVpLdB7YJutwmN + to: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + nonce: '4241633382289934858' + message: 25056c4c0bf57baf956438cdadda866f632d633a55b013fbbd6986f3f7bf89b0 + extensions: [] + result: + - 0 + - {} + block_num: 35478152 + trx_in_block: 13 + op_in_trx: 0 + virtual_op: 34366 +- id: 1.11.782546383 + op: + - 0 + - fee: + amount: 48132 + asset_id: 1.3.0 + from: 1.2.364315 + to: 1.2.114406 + amount: + amount: 26250000 + asset_id: 1.3.121 + memo: + from: BTS5LKaNYUyf4q91fqJCfXzkGCx5erx5pVV9ZUYZVpLdB7YJutwmN + to: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + nonce: '4241633382289934858' + message: 25056c4c0bf57baf956438cdadda866f632d633a55b013fbbd6986f3f7bf89b0 + extensions: [] + result: + - 0 + - {} + block_num: 35478152 + trx_in_block: 13 + op_in_trx: 0 + virtual_op: 34366 +- id: 1.11.782546383 + op: + - 0 + - fee: + amount: 48132 + asset_id: 1.3.0 + from: 1.2.364315 + to: 1.2.114406 + amount: + amount: 26250000 + asset_id: 1.3.121 + memo: + from: BTS5LKaNYUyf4q91fqJCfXzkGCx5erx5pVV9ZUYZVpLdB7YJutwmN + to: BTS6A9Qsp2FrrCWNndZmWqbeLq6g7Lr1T8Y9sQ5RbqutoeW5nBTAU + nonce: '4241633382289934858' + message: 25056c4c0bf57baf956438cdadda866f632d633a55b013fbbd6986f3f7bf89b0 + extensions: [] + result: + - 0 + - {} + block_num: 35478152 + trx_in_block: 13 + op_in_trx: 0 + virtual_op: 34366 From 02ea1fa0fe95cc851709b0d50617dced7c020b32 Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Mon, 11 Mar 2019 09:50:28 +0100 Subject: [PATCH 3/4] Add pyup service --- .pyup.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pyup.yml b/.pyup.yml index 457b8e87..c27d5eb7 100644 --- a/.pyup.yml +++ b/.pyup.yml @@ -2,6 +2,7 @@ # see https://pyup.io/docs/configuration/ for all available options update: all +branch: develop # update schedule # default: empty From 765213556cbb8f90c23083e03a34a9388209da28 Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Wed, 13 Mar 2019 15:19:43 +0100 Subject: [PATCH 4/4] Only load stake that matches the prefix --- graphenecommon/genesisbalance.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/graphenecommon/genesisbalance.py b/graphenecommon/genesisbalance.py index 78554ec9..5cccb13f 100644 --- a/graphenecommon/genesisbalance.py +++ b/graphenecommon/genesisbalance.py @@ -55,6 +55,8 @@ def claim(self, account=None, **kwargs): pubkeys = self.blockchain.wallet.getPublicKeys() addresses = dict() for p in pubkeys: + if p[: len(self.blockchain.prefix)] != self.blockchain.prefix: + continue pubkey = self.publickey_class(p) addresses[ str( @@ -131,6 +133,8 @@ def __init__(self, **kwargs): pubkeys = self.blockchain.wallet.getPublicKeys() addresses = list() for p in pubkeys: + if p[: len(self.blockchain.prefix)] != self.blockchain.prefix: + continue pubkey = self.publickey_class(p) addresses.append( str(