Exemplo n.º 1
0
    def test_get_history_transaction(self):
        prodvote = AG.new_action('prodvote',
                                 producer='evt',
                                 key="global-charge-factor",
                                 value=10000)

        trx = TG.new_trx()
        trx.add_action(prodvote)
        trx.add_sign(priv_evt)
        trx.add_sign(user.priv_key)
        trx.set_payer(user.pub_key.to_string())
        resp = api.push_transaction(trx.dumps())
        time.sleep(0.5)

        name = fake_name()
        newdomain = AG.new_action('newdomain', name=name, creator=user.pub_key)

        trx = TG.new_trx()
        trx.add_action(newdomain)
        trx.set_payer(user.pub_key.to_string())
        trx.add_sign(user.priv_key)

        resp = api.push_transaction(data=trx.dumps()).text
        res_dict = json.loads(resp)
        time.sleep(0.5)

        req = {
            'id':
            'f0c789933e2b381e88281e8d8e750b561a4d447725fb0eb621f07f219fe2f738'
        }
        req['id'] = res_dict['transaction_id']

        resp = api.get_history_transaction(json.dumps(req)).text
        res_dict = json.loads(resp)
        self.assertEqual(res_dict['transaction']['actions'][0]['name'],
                         'newdomain',
                         msg=resp)
        self.assertTrue(name in resp, msg=resp)

        resp = api.get_transaction_actions(json.dumps(req)).text
        res_dict = json.loads(resp)
        self.assertEqual(len(res_dict), 2, msg=res_dict)
        self.assertEqual(res_dict[1]['name'], 'paycharge', msg=res_dict)
Exemplo n.º 2
0
    def test_get_history_transaction(self):
        name = fake_name()
        newdomain = AG.new_action('newdomain', name=name, creator=user.pub_key)

        trx = TG.new_trx()
        trx.add_action(newdomain)
        trx.add_sign(user.priv_key)

        resp = api.push_transaction(data=trx.dumps()).text
        res_dict = json.loads(resp)
        time.sleep(0.5)

        req = {
            'id': 'f0c789933e2b381e88281e8d8e750b561a4d447725fb0eb621f07f219fe2f738'
        }
        req['id'] = res_dict['transaction_id']

        resp = api.get_history_transaction(json.dumps(req)).text
        self.assertTrue('newdomain' in resp, msg=resp)
        self.assertTrue(name in resp, msg=resp)
Exemplo n.º 3
0
    def test_block(self):
        symbol = base.Symbol(sym_name=sym_name,
                             sym_id=sym_id,
                             precision=sym_prec)
        asset = base.new_asset(symbol)
        pay_link = evt_link.EvtLink()
        pay_link.set_timestamp(int(time.time()))
        pay_link.set_max_pay(999999999)
        pay_link.set_header(evt_link.HeaderType.version1.value
                            | evt_link.HeaderType.everiPay.value)
        pay_link.set_symbol_id(sym_id)
        pay_link.set_link_id_rand()
        pay_link.sign(user.priv_key)

        everipay = AG.new_action('everipay',
                                 payee=pub2,
                                 number=asset(1),
                                 link=pay_link.to_string())

        req = {'link_id': 'ddc101c51318d51733d682e80b8ea2bc'}
        req['link_id'] = pay_link.get_link_id().hex()
        for i in range(10000):
            pay_link.set_link_id_rand()
            everipay = AG.new_action('everipay',
                                     payee=pub2,
                                     number=asset(1),
                                     link=pay_link.to_string())
            trx = TG.new_trx()
            trx.add_action(everipay)
            trx.add_sign(user.priv_key)
            trx.set_payer(user.pub_key.to_string())
            api.push_transaction(trx.dumps())
            time.sleep(0.1)

        req = {
            'block_num_or_id': '5',
        }

        resp = api.get_block(json.dumps(req)).text
        res_dict = json.loads(resp)
        self.assertTrue('block_num' in res_dict.keys(), msg=resp)
        self.assertEqual(res_dict['block_num'], 5, msg=resp)

        url = 'http://127.0.0.1:8888/v1/chain/get_block'

        tasks = []
        for i in range(1024):
            req['block_num_or_id'] = random.randint(1, 100)
            tasks.append(grequests.post(url, data=json.dumps(req)))

        i = 0
        for resp in grequests.imap(tasks, size=128):
            self.assertEqual(resp.status_code, 200, msg=resp.content)
            res_dict = json.loads(resp.text)
            req = {
                'id':
                'f0c789933e2b381e88281e8d8e750b561a4d447725fb0eb621f07f219fe2f738'
            }
            for trx in res_dict['transactions']:
                req['id'] = trx['trx']['id']
                resp = api.get_history_transaction(json.dumps(req)).text
            i += 1
            if i % 100 == 0:
                print('Received {} responses'.format(i))