Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions bitsharesbase/operationids.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@
"liquidity_pool_withdraw",
"liquidity_pool_exchange",
]
operations = [x for x, _ in enumerate(ops)]
operations = {o: ops.index(o) for o in ops}


def getOperationNameForId(i: int):
def getOperationNameForId(i):
"""Convert an operation id into the corresponding string."""
if i < len(ops):
return ops[i]
return f"Unknown Operation ID {i}"
for key in operations:
if int(operations[key]) is int(i):
return key
return "Unknown Operation ID %d" % i


def getOperationName(id: str):
Expand Down
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ classifiers =
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Topic :: Software Development :: Version Control :: Git

[options]
python_requires = >= 3.6
packages = find:
Expand All @@ -35,6 +36,9 @@ setup_requires =
[aliases]
test=pytest

[tool:pytest]
addopts = --ignore-glob=*/aio/*

[coverage:run]
source=bitsharesbase,bitsharesapi,bitshares
omit=
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# bitshares instance
bitshares = BitShares(
"wss://bitshares.openledger.info/ws", keys=wifs, nobroadcast=True, num_retries=1
"wss://eu.nodes.bitshares.ws", keys=wifs, nobroadcast=True, num_retries=1
)
config = bitshares.config

Expand Down
15 changes: 6 additions & 9 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,14 @@


class Testcases(unittest.TestCase):
def test_bts1bts2(self):
b1 = BitShares("wss://node.testnet.bitshares.eu", nobroadcast=True)

b2 = BitShares("wss://node.bitshares.eu", nobroadcast=True)

self.assertNotEqual(b1.rpc.url, b2.rpc.url)

def test_default_connection(self):
b1 = BitShares("wss://node.testnet.bitshares.eu", nobroadcast=True)
b1 = BitShares("wss://eu.nodes.bitshares.ws", nobroadcast=True)
set_shared_bitshares_instance(b1)
test = Asset("1.3.0", blockchain_instance=b1)
# Needed to clear cache
test.refresh()

"""
b2 = BitShares("wss://node.bitshares.eu", nobroadcast=True)
set_shared_bitshares_instance(b2)
bts = Asset("1.3.0", blockchain_instance=b2)
Expand All @@ -33,15 +27,18 @@ def test_default_connection(self):

self.assertEqual(test["symbol"], "TEST")
self.assertEqual(bts["symbol"], "BTS")
"""

def test_default_connection2(self):
b1 = BitShares("wss://node.testnet.bitshares.eu", nobroadcast=True)
b1 = BitShares("wss://eu.nodes.bitshares.ws", nobroadcast=True)
test = Asset("1.3.0", blockchain_instance=b1)
test.refresh()

"""
b2 = BitShares("wss://node.bitshares.eu", nobroadcast=True)
bts = Asset("1.3.0", blockchain_instance=b2)
bts.refresh()

self.assertEqual(test["symbol"], "TEST")
self.assertEqual(bts["symbol"], "BTS")
"""
6 changes: 4 additions & 2 deletions tests/test_objectcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ class Testcases(unittest.TestCase):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

self.bts = BitShares(nobroadcast=True,)
self.bts = BitShares(
nobroadcast=True,
)
set_shared_bitshares_instance(self.bts)

def test_cache(self):
cache = ObjectCache(default_expiration=1)
self.assertEqual(str(cache), "ObjectCache(n=0, default_expiration=1)")
self.assertEqual(str(cache), "ObjectCacheInMemory(default_expiration=1)")

# Data
cache["foo"] = "bar"
Expand Down
6 changes: 1 addition & 5 deletions tests/test_price.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@
from bitshares.price import Price
from bitshares.asset import Asset
import unittest
from .fixtures import bitshares


class Testcases(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(Testcases, self).__init__(*args, **kwargs)
bitshares = BitShares("wss://node.bitshares.eu", nobroadcast=True,)
set_shared_bitshares_instance(bitshares)

def test_init(self):
# self.assertEqual(1, 1)

Expand Down