def prepare_for_debug(filename): TG = TrxGenerator('http://127.0.0.1:8897', payer=None) Api = api.Api('http://127.0.0.1:8897') boss = base.User() # issue fungible DBG_Symbol = base.Symbol('DBG', 666, 5) DBG_Asset = base.new_asset(DBG_Symbol) act_newf = AG.new_action('newfungible', name='DBG', sym_name='DBG', sym=DBG_Symbol, creator=boss.pub_key, total_supply=DBG_Asset(1000000)) trx = TG.new_trx() trx.add_action(act_newf) trx.add_sign(boss.priv_key) trx.set_payer(boss.pub_key.to_string()) resp = Api.push_transaction(trx.dumps()) print(resp) with open(filename, 'r') as f: tmp = json.load(f) users = [base.User.from_string( each['pub_key'], each['priv_key']) for each in tmp] trx = TG.new_trx() for user in users: act_issue = AG.new_action('issuefungible', address=base.Address( ).set_public_key(user.pub_key), number=DBG_Asset(1000), memo='') trx.add_action(act_issue) trx.add_sign(boss.priv_key) trx.set_payer(boss.pub_key.to_string()) resp = Api.push_transaction(trx.dumps()) print(resp)
def main(): j = json.dumps(watches_config()) socket.send_string(j) print(socket.recv_string()) global api api = api.Api('http://127.0.0.1:8888') suite = unittest.TestLoader().loadTestsFromTestCase(Test) runner = unittest.TextTestRunner() result = runner.run(suite)
def main(url, start_evtd, evtd_path, public_key, private_key): global evtdout evtdout = None p = None if start_evtd == True: evtdout = open('/tmp/evt_api_tests_evtd.log', 'w') p = subprocess.Popen([evtd_path, '-e', '--http-validate-host=false', '--charge-free-mode', '--loadtest-mode', '--plugin=evt::mongo_db_plugin', '--plugin=evt::history_plugin', '--plugin=evt::history_api_plugin', '--plugin=evt::chain_api_plugin', '--plugin=evt::evt_api_plugin', '--plugin=evt::evt_link_plugin', '--producer-name=evt', '--delete-all-blocks', '-d', '/tmp/evt', '-m', 'mongodb://127.0.0.1:27017'], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=evtdout, shell=False) # wait for evtd to initialize time.sleep(3) try: global domain_name domain_name = 'cookie' global token1_name, token2_name, token3_name token1_name = fake_name('token') token2_name = fake_name('token') token3_name = 'tpass' global group_name group_name = fake_name('group') global sym_name, sym_id, sym_prec sym_name, sym_id, sym_prec = fake_symbol() sym_id = 3 sym_prec = 5 global pub2, priv2 pub2, priv2 = ecc.generate_new_pair() global evt_pub, priv_evt evt_pub = ecc.PublicKey.from_string( 'EVT6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV') priv_evt = ecc.PrivateKey.from_string( '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3') global TG TG = transaction.TrxGenerator(url=url, payer=public_key) global user user = base.User.from_string(public_key, private_key) global api, EvtAsset, AG api = api.Api(url) EvtAsset = base.EvtAsset AG = action.ActionGenerator() pre_action() suite = unittest.TestLoader().loadTestsFromTestCase(Test) runner = unittest.TextTestRunner() result = runner.run(suite) finally: if p is not None: p.kill() if evtdout is not None: evtdout.close()
def set_url(self, url): self.Api = api.Api(url) self.TG = TrxGenerator(url, payer=None)
def create(config): f = open('launch.config', 'r') text = f.read() f.close() paras = json.loads(text) producer_number = paras['producer_number'] # the number of the producer nodes_number = paras['nodes_number'] # the number of nodes we run evtd_port_http = paras[ 'evtd_port_http'] # the begin port of nodes port,port+1 .... evtd_port_p2p = paras[ 'evtd_port_p2p'] # the begin port of nodes port,port+1 .... evtd_dir = paras['evtd_dir'] # the data directory of the evtd use_tmpfs = paras['use_tmpfs'] # use the tmpfs or not tmpfs_size = paras['tmpfs_size'] # the memory usage per node client = docker.from_env() click.echo('check and free the container before') free_container('evtd_', client) try: net = client.networks.get("evt-net") except docker.errors.NotFound: network = client.networks.create("evt-net", driver="bridge") container = client.containers.run( image='bitnami/postgresql:11.1.0', name='postgre', network='evt-net', detach=True, volumes={'pg-data-volume': { 'bind': '/bitnami', 'mode': 'rw' }}) # begin the nodes one by one click.echo('begin open the evtd') for i in range(0, nodes_number): # create files in evtd_dir if (not os.path.exists(evtd_dir)): os.mkdir(evtd_dir, 0o755) file = os.path.join(evtd_dir, 'dir_{}'.format(i)) if (os.path.exists(file)): click.echo("Warning: the file before didn't freed ") else: os.mkdir(file, 0o755) # make the command cmd = command('evtd.sh') cmd.add_option('--delete-all-blocks') cmd.add_option('--http-validate-host=false') cmd.add_option('--charge-free-mode') # cmd.add_option('--plugin=evt::postgres_plugin') # cmd.add_option('--plugin=evt::history_plugin') # cmd.add_option('--plugin=evt::history_api_plugin') cmd.add_option('--plugin=evt::evt_link_plugin') cmd.add_option('--plugin=evt::chain_api_plugin') cmd.add_option('--plugin=evt::evt_api_plugin') # cmd.add_option('--postgres-uri=postgresql://postgres@localhost:5432/evt{}'.format(i)) if (i < producer_number): cmd.add_option('--enable-stale-production') if (i == 0): cmd.add_option('--producer-name=evt') else: cmd.add_option('--producer-name=evt{}'.format(i)) cmd.add_option( '--signature-provider=EVT7vuvMYQwm6WYLoopw6DqhBumM4hC7RA5ufK8WSqU7VQyfmoLwA=KEY:5KZ2HeogGk12U2WwU7djVrfcSami4BRtMyNYA7frfcAnhyAGzKM' ) cmd.add_option('--http-server-address=evtd_{}:{}'.format(i, 8888 + i)) cmd.add_option('--p2p-listen-endpoint=evtd_{}:{}'.format(i, 9876 + i)) for j in range(0, nodes_number): if (i == j): continue cmd.add_option( ('--p2p-peer-address=evtd_{}:{}'.format(j, 9876 + j))) # run the image evtd in container if (not use_tmpfs): click.echo('********evtd {} **************'.format(i)) click.echo('name: evtd_{}'.format(i)) click.echo('nework: evt-net') click.echo('http port: {} /tcp: {}'.format(evtd_port_http + i, 8888 + i)) click.echo('p2p port: {} /tcp: {}'.format(evtd_port_p2p + i, 9876 + i)) click.echo('mount location: {}'.format(file)) click.echo('****************************') container = client.containers.run( image='everitoken/evt:latest', name='evtd_{}'.format(i), command=cmd.get_arguments(), network='evt-net', ports={ '{}'.format(evtd_port_http + i): 8888 + i, '{}/tcp'.format(evtd_port_p2p + i): 9876 + i }, detach=True, volumes={file: { 'bind': '/opt/evtd/data', 'mode': 'rw' }}) else: click.echo('********evtd {} **************'.format(i)) click.echo('name: evtd_{}'.format(i)) click.echo('nework: evt-net') click.echo('http port: {} /tcp: {}'.format(evtd_port_http + i, 8888 + i)) click.echo('p2p port: {} /tcp: {}'.format(evtd_port_p2p + i, 9876 + i)) click.echo('tmpfs use size: {} M'.format(tmpfs_size)) click.echo('****************************') container = client.containers.run( image='everitoken/evt:latest', name='evtd_{}'.format(i), command=cmd.get_arguments(), network='evt-net', ports={ '{}'.format(evtd_port_http + i): 8888 + i, '{}/tcp'.format(evtd_port_p2p + i): 9876 + i }, detach=True, tmpfs={'/opt/evtd/data': 'size=' + str(tmpfs_size) + 'M'} # ) # update producers # producers_json = json.dumps(paras['producers_config']) url = 'http://127.0.0.1:8888' priv_evt = ecc.PrivateKey.from_string( '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3') pub_evt = ecc.PublicKey.from_string( 'EVT6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV') TG = transaction.TrxGenerator(url=url, payer=pub_evt.to_string()) Api = api.Api(url) AG = action.ActionGenerator() producers_json = {} producers = [] for i in range(0, producer_number): dic = {} if (i > 0): dic['producer_name'] = "evt{}".format(i) else: dic['producer_name'] = "evt" dic['block_signing_key'] = "EVT7vuvMYQwm6WYLoopw6DqhBumM4hC7RA5ufK8WSqU7VQyfmoLwA" producers.append(dic) producers_json['producers'] = producers updsched = AG.new_action_from_json('updsched', json.dumps(producers_json)) trx = TG.new_trx() trx.add_action(updsched) trx.add_sign(priv_evt) Api.push_transaction(trx.dumps())
from pyevtsdk import action, api, base, transaction, unit_test keys = [1111,2222,3333] pubs = [bls.privtopub(key) for key in keys] root_key = ecc.PrivateKey.from_string( '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3') root_pub = ecc.PublicKey.from_string( 'EVT6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV') # root_key = '5JFZQ7bRRuBJyh42uV5ELwswr2Bt3rfwmyEsyXAoUue18NUreAF' # root_pub = 'EVT8CAme1QR2664bLQsVfrERBkXL3xEKsALMSfogGavaXFkaVVqR1' url = 'https://testnet1.everitoken.io' ecc_domain = 43 domain_name = 'virtual-machine' api = api.Api(url) # print(api.get_info()) TG = transaction.TrxGenerator(url=url, payer=root_pub) # user = base.User.from_string(root_key, root_pub) EvtAsset = base.EvtAsset AG = action.ActionGenerator() # newdomain = AG.new_action( # 'newdomain', name='virtual-machine', creator=root_pub) # trx = TG.new_trx() # # trx.add_action(prodvote) # trx.add_action(newdomain) # trx.add_sign(root_key)