Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUpClass(cls):
nodelist = NodeList()
cls.bts = Steem(
node=nodelist.get_nodes(exclude_limited=False),
nobroadcast=True,
num_retries=10
)
set_shared_steem_instance(cls.bts)
def test_blockchain(self, node_param):
if node_param == "instance":
set_shared_steem_instance(self.bts)
o = Blockchain()
self.assertIn(o.steem.rpc.url, self.urls)
with self.assertRaises(
RPCConnection
):
Blockchain(steem_instance=Steem(node="https://abc.d", autoconnect=False, num_retries=1))
else:
set_shared_steem_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1))
stm = self.bts
o = Blockchain(steem_instance=stm)
self.assertIn(o.steem.rpc.url, self.urls)
with self.assertRaises(
RPCConnection
):
Blockchain()
node=nodelist.get_nodes(exclude_limited=True),
nobroadcast=True,
unsigned=True,
keys={"active": wif},
num_retries=10
)
cls.steemit = Steem(
node="https://api.steemit.com",
nobroadcast=True,
unsigned=True,
keys={"active": wif},
num_retries=10
)
# from getpass import getpass
# self.bts.wallet.unlock(getpass())
set_shared_steem_instance(cls.bts)
cls.bts.set_default_account("test")
def test_wallet(self, node_param):
if node_param == "instance":
set_shared_steem_instance(self.bts)
o = Wallet()
self.assertIn(o.steem.rpc.url, self.urls)
with self.assertRaises(
RPCConnection
):
o = Wallet(steem_instance=Steem(node="https://abc.d", autoconnect=False, num_retries=1))
o.steem.get_config()
else:
set_shared_steem_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1))
stm = self.bts
o = Wallet(steem_instance=stm)
self.assertIn(o.steem.rpc.url, self.urls)
with self.assertRaises(
RPCConnection
):
o = Wallet()
o.steem.get_config()
def setUpClass(cls):
nodelist = NodeList()
nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(exclude_limited=False, appbase=True), num_retries=10))
node_list = nodelist.get_nodes(exclude_limited=True)
cls.bts = Steem(
node=node_list,
use_condenser=True,
nobroadcast=True,
keys={"active": wif},
num_retries=10
)
# from getpass import getpass
# self.bts.wallet.unlock(getpass())
set_shared_steem_instance(cls.bts)
cls.bts.set_default_account("test")
def test_comment(self, node_param):
if node_param == "instance":
set_shared_steem_instance(self.bts)
o = Comment(self.authorperm)
self.assertIn(o.steem.rpc.url, self.urls)
with self.assertRaises(
RPCConnection
):
Comment(self.authorperm, steem_instance=Steem(node="https://abc.d", autoconnect=False, num_retries=1))
else:
set_shared_steem_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1))
stm = self.bts
o = Comment(self.authorperm, steem_instance=stm)
self.assertIn(o.steem.rpc.url, self.urls)
with self.assertRaises(
RPCConnection
):
Comment(self.authorperm)
def test_amount(self, node_param):
if node_param == "instance":
stm = Steem(node="https://abc.d", autoconnect=False, num_retries=1)
set_shared_steem_instance(self.bts)
o = Amount("1 SBD")
self.assertIn(o.steem.rpc.url, self.urls)
with self.assertRaises(
RPCConnection
):
Amount("1 SBD", steem_instance=stm)
else:
set_shared_steem_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1))
stm = self.bts
o = Amount("1 SBD", steem_instance=stm)
self.assertIn(o.steem.rpc.url, self.urls)
with self.assertRaises(
RPCConnection
):
Amount("1 SBD")
nodelist = NodeList()
nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(exclude_limited=False), num_retries=10))
node_list = nodelist.get_nodes(exclude_limited=True)
cls.stm = Steem(
node=node_list,
keys={"active": wif, "owner": wif2, "memo": wif3},
nobroadcast=True,
num_retries=10
)
cls.steemit = Steem(
node="https://api.steemit.com",
nobroadcast=True,
keys={"active": wif, "owner": wif2, "memo": wif3},
num_retries=10
)
set_shared_steem_instance(cls.stm)
cls.stm.set_default_account("test")
def test_amount(self, node_param):
if node_param == "instance":
stm = Steem(node="https://abc.d", autoconnect=False, num_retries=1)
set_shared_steem_instance(self.bts)
o = Amount("1 SBD")
self.assertIn(o.steem.rpc.url, self.urls)
with self.assertRaises(
RPCConnection
):
Amount("1 SBD", steem_instance=stm)
else:
set_shared_steem_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1))
stm = self.bts
o = Amount("1 SBD", steem_instance=stm)
self.assertIn(o.steem.rpc.url, self.urls)
with self.assertRaises(
RPCConnection
):
Amount("1 SBD")
def profiling(name_list):
stm = Steem()
set_shared_steem_instance(stm)
del stm
print("start")
for name in name_list:
print("account: %s" % (name))
acc = Account(name)
max_index = acc.virtual_op_count()
print(max_index)
stopTime = datetime(2018, 4, 22, 0, 0, 0)
hist_elem = None
for h in acc.history_reverse(stop=stopTime):
hist_elem = h
print(hist_elem)
print("blockchain")
blockchain_object = Blockchain()
current_num = blockchain_object.get_current_block_num()
startBlockNumber = current_num - 20