Ejemplo n.º 1
0
async def run_test():
    if config.system_contract == 'eosio':
        print('This example only works on uuos network currently')
        return
    uuosapi = chainapi.ChainApiAsync(config.network_url)
    code = uuosapi.mp_compile(test_account1, src)

    r = await uuosapi.deploy_python_contract(test_account1, code, abi)

    args = {'account': test_account1, 'group_name': 'group1'}
    try:
        r = await uuosapi.push_action(test_account1, 'creategroup', args,
                                      {test_account1: 'active'})
        test_helper.print_console(r)
    except chainapi.ChainException as e:
        print('++++error:', e.json['error']['details'][1]['message'])

    if not hasattr(chainapi, 'count'):
        chainapi.count = 0
    chainapi.count += 1
    print('++++count:', chainapi.count)
    args = {
        'account': test_account1,
        'group_name': 'group1',
        'msg': 'hello,world' + str(chainapi.count)
    }
    try:
        r = await uuosapi.push_action(test_account1, 'chat', args,
                                      {test_account1: 'active'})
        test_helper.print_console(r)
        print(r['processed']['elapsed'])
    except chainapi.ChainException as e:
        print('++++chat error:', e)
Ejemplo n.º 2
0
async def run_test():
    uuosapi = chainapi.ChainApiAsync(config.network_url)
    code = uuosapi.mp_compile(test_account1, src)

    r = await uuosapi.deploy_python_contract(test_account1, code, abi)

    args = b'hello,world'
    try:
        r = await uuosapi.push_action(test_account1, 'test1', args,
                                      {test_account1: 'active'})
        test_helper.print_console(r)
    except chainapi.ChainException as e:
        print('+++test1:', e)

    args = b'hello,world'
    try:
        r = await uuosapi.push_action(test_account1, 'test2', args,
                                      {test_account1: 'active'})
        test_helper.print_console(r)
    except chainapi.ChainException as e:
        print('+++test2: assertion failed as expected:', e)

    args = b'hello,world'
    try:
        r = await uuosapi.push_action(test_account1, 'test3', args,
                                      {test_account1: 'active'})
        test_helper.print_console(r)
    except chainapi.ChainException as e:
        print('+++test3, assertion raised:')
        msg = e.json['error']['details'][0]['message']
        print(msg)
        assert msg == "assertion failure with message: bad action"
Ejemplo n.º 3
0
async def run_test():
    uuosapi = chainapi.ChainApiAsync(config.network_url)
    code = uuosapi.mp_compile(test_account1, src)

    r = await uuosapi.deploy_python_contract(test_account1, code, abi)

    args = 'hello,world'
    r = await uuosapi.exec(test_account1, args)
    test_helper.print_console(r)
Ejemplo n.º 4
0
async def run_test():
    if config.system_contract == 'eosio':
        print('This example only works on uuos network')
        return
    uuosapi = chainapi.ChainApiAsync(config.network_url)
    code = uuosapi.mp_compile(test_account1, src)

    r = await uuosapi.deploy_python_contract(test_account1, code, abi)

    args = 'hello,world'
    r = await uuosapi.exec(test_account1, args)
    test_helper.print_console(r)
Ejemplo n.º 5
0
async def run_test():
    uuosapi = chainapi.ChainApiAsync(config.network_url)
    code2 = uuosapi.mp_compile('hello', src2)
    r = await uuosapi.deploy_module(test_account1, 'hello', code2)

    # deploy_contract comes after deploy_module
    # if a module deployed used by contract has been changed
    # deploy_contract must call again to reflect the changes made in the module
    code = uuosapi.mp_compile(test_account1, src1)

    r = await uuosapi.deploy_python_contract(test_account1, code, abi)

    args = uuosapi.s2b(test_account1)
    r = await uuosapi.exec(test_account1, args)
    test_helper.print_console(r)
Ejemplo n.º 6
0
async def run_test():
    uuosapi = chainapi.ChainApiAsync(config.network_url)
    code = uuosapi.mp_compile(test_account1, src)
    await update_code_auth(uuosapi)
    print(config.main_token_contract)

    r = await uuosapi.deploy_python_contract(test_account1, code, abi)

    memo = 'helloworld51-0003ff99995d1ec79e7662bc7ffa076aeceda00fb9540406091ad36bf8f2ec58d651'
    balance1 = await uuosapi.get_balance(test_account2)
    r = await uuosapi.transfer(test_account2, test_account1, 1.0, memo)
    balance2 = await uuosapi.get_balance(test_account2)
    print(balance1, balance2)
    console = r['processed']['action_traces'][0]['inline_traces'][1]['console']
    print('+++console:', console)
Ejemplo n.º 7
0
async def run_test():
    uuosapi = chainapi.ChainApiAsync(config.network_url)
    code = uuosapi.mp_compile(test_account1, src)

    try:
        r = await update_code_auth(uuosapi)
    except chainapi.ChainException as e:
        print('+++update_code_auth error:', e)

    r = await uuosapi.deploy_python_contract(test_account1, code, abi)

    args = b'hello,world'
    r = await uuosapi.push_action(test_account1, 'testinline', args,
                                  {test_account1: 'active'})
    print('+++testinline:', r['processed']['action_traces'][0]['console'])
    print('+++sayhello:',
          r['processed']['action_traces'][0]['inline_traces'][0]['console'])
    print('+++++++push_action elapsed:', r['processed']['elapsed'])
Ejemplo n.º 8
0
async def run_test():
    uuosapi = chainapi.ChainApiAsync(config.network_url)
    code = uuosapi.mp_compile(test_account1, src)
    print(test_account1, test_account2)
    try:
        r = await uuosapi.deploy_contract(test_account2,
                                          wasm_code,
                                          wasm_abi,
                                          vm_type=0)
    except chainapi.ChainException as e:
        print('+++deploy error:', e.json['message'])

    r = await uuosapi.deploy_python_contract(test_account1, code, abi)

    args = 'hello,world'
    try:
        r = await uuosapi.push_action(test_account1, 'sayhello', args,
                                      {test_account1: 'active'})
        test_helper.print_console(r)
    except chainapi.ChainException as e:
        print('+++test error:', e)
Ejemplo n.º 9
0
async def run_test():
    uuosapi = chainapi.ChainApiAsync(config.network_url)
    code = uuosapi.mp_compile(test_account1, src)

    r = await uuosapi.deploy_python_contract(test_account1, code, abi)

    args = b'hello,world'
    try:
        r = await uuosapi.push_action(test_account1, 'test1', args,
                                      {test_account1: 'active'})
        test_helper.print_console(r)
    except chainapi.ChainException as e:
        print('+++test1 error:', e)

    args = b'hello,world'
    try:
        r = await uuosapi.push_action(test_account1, 'test2', args,
                                      {test_account1: 'active'})
        test_helper.print_console(r)
    except chainapi.ChainException as e:
        msg = e.json['error']['details'][0]['message']
        assert msg == f"missing authority of {test_account1}/owner"
Ejemplo n.º 10
0
async def run_test():
    uuosapi = chainapi.ChainApiAsync(config.network_url)
    code1 = uuosapi.mp_compile(test_account1, src)

    try:
        r = await uuosapi.deploy_contract(test_account1, code1, abi, vm_type=1)
    except chainapi.ChainException as e:
        print('+++deploy error:', e.json['message'])

    try:
        r = await uuosapi.deploy_contract(test_account2,
                                          wasm_code,
                                          b'',
                                          vm_type=0)
    except chainapi.ChainException as e:
        print('+++deploy error2:', e.json['message'])

    args = uuosapi.s2b(test_account2)
    r = await uuosapi.exec(test_account1, args)
    print('+++1:', r['processed']['action_traces'][0]['console'])
    print('+++2:',
          r['processed']['action_traces'][0]['inline_traces'][0]['console'])
Ejemplo n.º 11
0
async def run_test():
    uuosapi = chainapi.ChainApiAsync(config.network_url)
    code = uuosapi.mp_compile(test_account1, src)

    try:
        r = await uuosapi.deploy_python_contract(test_account1, code, abi)
        print('++++deploy time:', r['processed']['elapsed'])
    except chainapi.ChainException as e:
        print('+++deploy error:', e)

    if not hasattr(chainapi, 'count'):
        chainapi.count = 0
    chainapi.count += 1
    r = await uuosapi.get_table_rows(False, test_account1, test_account1, 'log', '', '', 1)
    old_state = None
    if r['rows']:
        old_state = r['rows'][0]

    args = 'hello,world' + str(chainapi.count)
    r = await uuosapi.exec(test_account1, args)
    test_helper.print_console(r)

    await show_log(uuosapi, old_state)
Ejemplo n.º 12
0
async def run_test():
    uuosapi = chainapi.ChainApiAsync(config.network_url)
    code = uuosapi.mp_compile(test_account1, src)

    await uuosapi.deploy_abi(test_account1, abi)

    try:
        r = await uuosapi.deploy_python_contract(test_account1, code, abi)
    except chainapi.ChainException as e:
        print('+++deploy error:', e.json['message'])

    args = {'issuer': test_account1, 'maximum_supply': '1000.0000 TTT'}
    try:
        r = await uuosapi.push_action(test_account1, 'create', args,
                                      {test_account1: 'active'})
        test_helper.print_console(r)
    except chainapi.ChainException as e:
        print(e)
        msg = e.json['error']['details'][0]['message']
        print('+++create:', msg)

    args = {
        'to': test_account1,
        'quantity': '10.0000 TTT',
        'memo': f'issue 10 TTT to {test_account1}'
    }

    balance1 = await uuosapi.get_balance(test_account1,
                                         token_account=test_account1,
                                         token_name='TTT')
    try:
        r = await uuosapi.push_action(test_account1, 'issue', args,
                                      {test_account1: 'active'})
        test_helper.print_console(r)
    except chainapi.ChainException as e:
        print('+++issue error:', e)
    balance2 = await uuosapi.get_balance(test_account1,
                                         token_account=test_account1,
                                         token_name='TTT')
    print(balance1, balance2)

    args = {
        'from': test_account1,
        'to': test_account2,
        'quantity': '10.0000 TTT',
        'memo': f'transfer 10 TTT to {test_account2}'
    }
    print('++++++++++:', test_account1, test_account2)

    balance1 = await uuosapi.get_balance(test_account1,
                                         token_account=test_account1,
                                         token_name='TTT')
    r = await uuosapi.push_action(test_account1, 'transfer', args,
                                  {test_account1: 'active'})
    test_helper.print_console(r)
    print('+++transfer:', r['processed']['elapsed'])

    balance2 = await uuosapi.get_balance(test_account2,
                                         token_account=test_account1,
                                         token_name='TTT')
    print(balance1, balance2)