def setUpClass(cls): stm = shared_dpay_instance() stm.config.refreshBackup() nodelist = NodeList() nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes( normal=True, appbase=True), num_retries=10)) cls.stm = DPay( node=nodelist.get_nodes(appbase=False), nobroadcast=True, # We want to bundle many operations into a single transaction bundle=True, num_retries=10 # Overwrite wallet to use this list of wifs only ) cls.appbase = DPay(node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, bundle=True, num_retries=10) cls.stm.set_default_account("test") set_shared_dpay_instance(cls.stm) # self.stm.newWallet("TestingOneTwoThree") cls.wallet = Wallet(dpay_instance=cls.stm) cls.wallet.wipe(True) cls.wallet.newWallet(pwd="TestingOneTwoThree") cls.wallet.unlock(pwd="TestingOneTwoThree") cls.wallet.addPrivateKey(wif)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) cls.bts = DPay( node=nodelist.get_nodes(appbase=False), use_condenser=True, nobroadcast=True, unsigned=True, keys={"active": wif}, num_retries=10 ) cls.appbase = DPay( node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, unsigned=True, keys={"active": wif}, num_retries=10 ) acc = Account("holger80", dpay_instance=cls.bts) comment = acc.get_feed(limit=20)[-1] cls.authorperm = comment.authorperm [author, permlink] = resolve_authorperm(cls.authorperm) cls.author = author cls.permlink = permlink cls.category = comment.category cls.title = comment.title
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(dpay_instance=DPay( node=nodelist.get_nodes(normal=True, appbase=True), num_retries=3)) cls.nodes = nodelist.get_nodes(https=False, appbase=False) cls.nodes_https = nodelist.get_nodes(wss=False, appbase=False) cls.nodes_appbase = nodelist.get_nodes(normal=False) cls.test_list = nodelist.get_nodes() cls.bts = DPay(node=cls.nodes, nobroadcast=True, keys={ "active": wif, "owner": wif, "memo": wif }, num_retries=10) cls.appbase = DPay(node=cls.nodes_appbase, nobroadcast=True, keys={ "active": wif, "owner": wif, "memo": wif }, num_retries=10) cls.rpc = DPayNodeRPC(urls=cls.test_list) # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_dpay_instance(cls.bts) cls.bts.set_default_account("test")
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes( normal=True, appbase=True), num_retries=10)) dpay = DPay(node=nodelist.get_nodes(appbase=False), nobroadcast=True, num_retries=10) set_shared_dpay_instance(dpay)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) nodelist = NodeList() nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes( normal=True, appbase=True), num_retries=10)) stm = DPay(node=nodelist.get_nodes(appbase=False)) self.ws = DPayWebsocket(urls=stm.rpc.nodes, num_retries=10)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) cls.bts = DPay( node=nodelist.get_nodes(), nobroadcast=True, keys=[wif], num_retries=10 ) set_shared_dpay_instance(cls.bts)
def test_stm1stm2(self): nodelist = NodeList() nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) b1 = DPay( node=nodelist.get_testnet(testnet=True, testnetdev=False), nobroadcast=True, num_retries=10 ) b2 = DPay( node=nodelist.get_nodes(appbase=False), nobroadcast=True, num_retries=10 ) self.assertNotEqual(b1.rpc.url, b2.rpc.url)
def setUpClass(cls): nodelist = NodeList() cls.bts = DPay( node=nodelist.get_nodes(appbase=False), nobroadcast=True, num_retries=10 ) set_shared_dpay_instance(cls.bts)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes( normal=True, appbase=True), num_retries=10)) cls.bts = DPay(node=nodelist.get_nodes(appbase=False), nobroadcast=True, num_retries=10) cls.appbase = DPay(node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, use_condenser=False, num_retries=10) set_shared_dpay_instance(cls.bts) cls.asset = Asset("BBD") cls.symbol = cls.asset["symbol"] cls.precision = cls.asset["precision"] cls.asset2 = Asset("BEX")
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes( normal=True, appbase=True), num_retries=10)) cls.bts = DPay(node=nodelist.get_nodes(appbase=False), nobroadcast=True, keys={"active": wif}, num_retries=10) cls.appbase = DPay(node=nodes_appbase, nobroadcast=True, keys={"active": wif}, num_retries=10) cls.test_block_id = 19273700 # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_dpay_instance(cls.bts) cls.bts.set_default_account("test")
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes( normal=True, appbase=True), num_retries=10)) cls.bts = DPay( node=nodelist.get_nodes(appbase=False), nobroadcast=True, bundle=False, # Overwrite wallet to use this list of wifs only keys={"active": wif}, num_retries=10) cls.appbase = DPay( node=nodelist.get_nodes(appbase=True, dev=True), nobroadcast=True, bundle=False, # Overwrite wallet to use this list of wifs only keys={"active": wif}, num_retries=10)
def test_default_connection(self): nodelist = NodeList() nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) b1 = DPay( node=nodelist.get_testnet(testnet=True, testnetdev=False), nobroadcast=True, ) set_shared_dpay_instance(b1) test = Account("dpaygo") b2 = DPay( node=nodelist.get_nodes(appbase=False), nobroadcast=True, ) set_shared_dpay_instance(b2) bts = Account("dpaygo") self.assertEqual(test.dpay.prefix, "DWT") self.assertEqual(bts.dpay.prefix, "DWB")
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes( normal=True, appbase=True), num_retries=10)) cls.bts = DPay(node=nodelist.get_nodes(appbase=False), nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, num_retries=10) cls.appbase = DPay(node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, num_retries=10) cls.account = Account("test", full=True, dpay_instance=cls.bts) cls.account_appbase = Account("test", full=True, dpay_instance=cls.appbase)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes( normal=True, appbase=True), num_retries=10)) cls.bts = DPay( node=nodelist.get_nodes(), nobroadcast=True, timeout=30, num_retries=30, ) # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_dpay_instance(cls.bts) cls.bts.set_default_account("test") b = Blockchain(dpay_instance=cls.bts) num = b.get_current_block_num() # num = 23346630 cls.start = num - 25 cls.stop = num
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes( normal=True, appbase=True), num_retries=10)) cls.bts = DPay(node=nodelist.get_nodes(appbase=False), nobroadcast=True, keys={"active": wif}, num_retries=10) cls.appbase = DPay(node=nodes_appbase, nobroadcast=True, keys={"active": wif}, num_retries=10) # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_dpay_instance(cls.bts) cls.bts.set_default_account("test") b = Blockchain(dpay_instance=cls.bts) num = b.get_current_block_num() cls.start = num - 25 cls.stop = num
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes( normal=True, appbase=True), num_retries=10)) cls.stm = DPay(node=nodelist.get_nodes(appbase=False), keys={ "active": wif, "owner": wif, "memo": wif }, nobroadcast=True, num_retries=10) cls.appbase = DPay(node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, keys={ "active": wif, "owner": wif, "memo": wif }, num_retries=10) set_shared_dpay_instance(cls.stm) cls.stm.set_default_account("test")
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes( normal=True, appbase=True), num_retries=10)) cls.bts = DPay( node=nodelist.get_nodes(normal=False, appbase=True, dev=True), nobroadcast=True, num_retries=10, timeout=30, use_condenser=False, keys={"active": wif}, ) # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_dpay_instance(cls.bts) cls.bts.set_default_account("test") b = Blockchain(dpay_instance=cls.bts) num = b.get_current_block_num() cls.start = num - 100 cls.stop = num cls.max_batch_size = 1 # appbase does not support batch rpc calls at the momement (internal error)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes( normal=True, appbase=True), num_retries=10)) cls.bts = DPay(node=nodelist.get_nodes(appbase=False), nobroadcast=True, keys={"active": wif}, num_retries=10) cls.appbase = DPay(node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, keys={"active": wif}, num_retries=10) # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_dpay_instance(cls.bts) cls.bts.set_default_account("test") acc = Account("holger80", dpay_instance=cls.bts) n_votes = 0 index = 0 while n_votes == 0: comment = acc.get_feed(limit=30)[::-1][index] votes = comment.get_votes() n_votes = len(votes) index += 1 last_vote = votes[0] cls.authorpermvoter = construct_authorpermvoter( last_vote['author'], last_vote['permlink'], last_vote["voter"]) [author, permlink, voter] = resolve_authorpermvoter(cls.authorpermvoter) cls.author = author cls.permlink = permlink cls.voter = voter cls.authorperm = construct_authorperm(author, permlink)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) cls.bts = DPay( node=nodelist.get_nodes(normal=True, appbase=False), nobroadcast=True, bundle=False, unsigned=True, # Overwrite wallet to use this list of wifs only keys={"active": wif}, num_retries=10 ) cls.appbase = DPay( node=nodelist.get_nodes(normal=False, appbase=True, dev=False), nobroadcast=True, bundle=False, unsigned=True, # Overwrite wallet to use this list of wifs only keys={"active": wif}, num_retries=10 ) cls.account = Account("dpaygobot", full=True, dpay_instance=cls.bts) cls.account_appbase = Account("dpaygobot", full=True, dpay_instance=cls.appbase) set_shared_dpay_instance(cls.bts)
from dpaygo.block import Block from dpaygo.dpay import DPay from dpaygo.utils import parse_time, formatTimedelta from dpaygo.nodelist import NodeList from dpaygoapi.exceptions import NumRetriesReached log = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) if __name__ == "__main__": how_many_minutes = 10 how_many_virtual_op = 10000 max_batch_size = None threading = False thread_num = 16 nodelist = NodeList() nodes = nodelist.get_nodes(normal=True, appbase=True, dev=True) t = PrettyTable([ "node", "10 blockchain minutes", "10000 virtual account op", "version" ]) t.align = "l" for node in nodes: print("Current node:", node) try: stm = DPay(node=node, num_retries=3) blockchain = Blockchain(dpay_instance=stm) account = Account("gtg", dpay_instance=stm) virtual_op_count = account.virtual_op_count() blockchain_version = stm.get_blockchain_version() last_block_id = 19273700 last_block = Block(last_block_id, dpay_instance=stm)
from dpaygo.amount import Amount from dpaygographenebase.account import PasswordKey, PrivateKey, PublicKey from dpaygo.dpay import DPay from dpaygo.utils import parse_time, formatTimedelta from dpaygoapi.exceptions import NumRetriesReached from dpaygo.nodelist import NodeList log = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) password = "******" username = "******" useWallet = False if __name__ == "__main__": nodelist = NodeList() stm = DPay(node=nodelist.get_nodes(normal=False, appbase=False, testnet=True)) prefix = stm.prefix # curl --data "username=username&password=secretPassword" https://testnet.dpay.vc/create stm.wallet.wipe(True) if useWallet: stm.wallet.create("123") stm.wallet.unlock("123") active_key = PasswordKey(username, password, role="active", prefix=prefix) owner_key = PasswordKey(username, password, role="owner", prefix=prefix) posting_key = PasswordKey(username, password, role="posting", prefix=prefix) memo_key = PasswordKey(username, password, role="memo", prefix=prefix) active_pubkey = active_key.get_public_key() owner_pubkey = owner_key.get_public_key() posting_pubkey = posting_key.get_public_key() memo_pubkey = memo_key.get_public_key() active_privkey = active_key.get_private_key()
def test_nodes_update(self): nodelist = NodeList() all_nodes = nodelist.get_nodes(normal=True, appbase=True, dev=True, testnet=True) nodelist.update_nodes(dpay_instance=self.bts) nodes = nodelist.get_nodes() self.assertIn(nodes[0], all_nodes)
import logging from dpaygo.blockchain import Blockchain from dpaygo.block import Block from dpaygo.dpay import DPay from dpaygo.utils import parse_time, formatTimedelta from dpaygo.nodelist import NodeList log = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) if __name__ == "__main__": node_setup = 1 how_many_hours = 1 nodes = NodeList() if node_setup == 0: stm = DPay(node=nodes.get_nodes(normal=True, wss=True), num_retries=10) max_batch_size = None threading = False thread_num = 8 elif node_setup == 1: stm = DPay(node=nodes.get_nodes(normal=True, wss=True), num_retries=10) max_batch_size = None threading = True thread_num = 16 elif node_setup == 2: stm = DPay(node=nodes.get_nodes(appbase=False, https=False), num_retries=10) max_batch_size = None threading = True thread_num = 16 blockchain = Blockchain(dpay_instance=stm)
sys.stdout.write("\r%s" % op['block_num']) opcount += 1 now = time.time() total_duration = now - start_time print(" votes: %d, time %.2f" % (opcount, total_duration)) return opcount, total_duration if __name__ == "__main__": node_setup = 1 threading = True thread_num = 8 timeout = 10 nodes = NodeList() nodes.update_nodes(weights={"block": 1}) node_list_wss = nodes.get_nodes(https=False)[:5] node_list_https = nodes.get_nodes(wss=False)[:5] vote_result = [] duration = [] stm_wss = DPay(node=node_list_wss, timeout=timeout) stm_https = DPay(node=node_list_https, timeout=timeout) print("Without threading wss") opcount_wot_wss, total_duration_wot_wss = stream_votes(stm_wss, False, 8) print("Without threading https") opcount_wot_https, total_duration_wot_https = stream_votes( stm_https, False, 8) if threading: print("\n Threading with %d threads is activated now." % thread_num) stm = DPay(node=node_list_wss, timeout=timeout)
sys.stdout.write("\r%s" % op['block_num']) opcount += 1 now = time.time() total_duration = now - start_time print(" votes: %d, time %.2f" % (opcount, total_duration)) return opcount, total_duration if __name__ == "__main__": node_setup = 1 threading = True thread_num = 8 timeout = 10 nodes = NodeList() nodes.update_nodes(weights={"block": 1}) node_list = nodes.get_nodes()[:5] vote_result = [] duration = [] stm = DPay(node=node_list, timeout=timeout) b = Blockchain(dpay_instance=stm) block = b.get_current_block() block.set_cache_auto_clean(False) opcount, total_duration = stream_votes(stm, threading, thread_num) print("Finished!") block.set_cache_auto_clean(True) cache_len = len(list(block._cache)) start_time = time.time() block.clear_cache_from_expired_items() clear_duration = time.time() - start_time
def test_get_nodes(self): nodelist = NodeList() all_nodes = nodelist.get_nodes(normal=True, appbase=True, dev=True, testnet=True, testnetdev=True) self.assertEqual(len(nodelist) - 6, len(all_nodes)) https_nodes = nodelist.get_nodes(wss=False) self.assertEqual(https_nodes[0][:5], 'https')