Beispiel #1
0
def test_transfer2():
    data =generate_call_params('testTransfer')
    print(data)
    balance = eosapi.get_balance('evm')
    ret = eosapi.transfer('eosio', 'evm', 0.0001, data)
    assert ret
    assert math.isclose(balance, eosapi.get_balance('evm'))
Beispiel #2
0
def test2(count=100):
    _from = 'eosio'
    _to = 'hello'

    print(eosapi.get_balance(_from), eosapi.get_balance(_to))
    actions = []
    for i in range(count):
        action = [
            'eosio.token', 'transfer', {
                "from": _from,
                "to": _to,
                "quantity": "0.0010 EOS",
                "memo": str(i)
            }, {
                _from: 'active'
            }
        ]
        actions.append(action)

    ret, cost = eosapi.push_actions(actions)
    if ret['except']:
        print(ret['except'])
    assert not ret['except']
    print(eosapi.get_balance(_from), eosapi.get_balance(_to))

    print(
        'total cost time:%.3f s, cost per action: %.3f ms, actions per second: %.3f'
        % (cost / 1e6, cost / count / 1000, 1 * 1e6 / (cost / count)))
Beispiel #3
0
def call(msg='hello,world\n'):
    _from = 'eosio'
    _to = 'hello'
    amount = 0.01
    msg = struct.pack('QQQ', eosapi.s2n(_from), eosapi.s2n(_to), int(0.01*10000))

    print(eosapi.get_balance(_from), eosapi.get_balance(_to))

    r = eosapi.push_action('call', 'call', msg, {'call':'active', 'eosio':'active'})

    print(eosapi.get_balance(_from), eosapi.get_balance(_to))

    assert r
Beispiel #4
0
def t():
    if eosapi.get_balance('lab') <= 0:
        eosapi.transfer('eosio', 'lab', 100)
    msg = {'bidder': 'lab', 'bid': "1.3000 EOS"}
    msg = eosapi.pack_args('eosio', 'bidjit', msg)
    act = ['eosio', 'bidjit', msg, {'lab': 'active'}]

    rr, cost = eosapi.push_actions([act])
    assert_ret(rr)
Beispiel #5
0
def publish_system_contracts(accounts_map):
    contracts_path = os.path.join(os.getcwd(), '..', 'contracts')
    sys.path.append(os.getcwd())
    #    accounts_map = {'eosio.token':'eosio.token', 'eosio.msig':'eosio.msig', 'eosio':'eosio.system'}
    for account in accounts_map:
        print('account', account)
        if not eosapi.get_account(account):
            r = eosapi.create_account('eosio', account, key1, key2)
            assert r

        _path = os.path.join(contracts_path, accounts_map[account],
                             accounts_map[account])
        wast = _path + '.wast'
        code = open(wast, 'rb').read()
        code = eosapi.wast2wasm(code)
        hash = eosapi.sha256(code)
        old_hash = eosapi.get_code_hash(account)
        if old_hash != hash:
            print('+++++++++code update', account)
            wast = _path + '.wast'
            abi = _path + '.abi'
            r = eosapi.set_contract(account, wast, abi, 0)
            print(wast, abi)
            time.sleep(1.0)
            if account == 'eosio.token' and eosapi.get_balance('eosio') <= 0.0:
                print('issue system token...')
                #                msg = {"issuer":"eosio","maximum_supply":"1000000000.0000 EOS","can_freeze":0,"can_recall":0, "can_whitelist":0}
                msg = {
                    "issuer": "eosio",
                    "maximum_supply": "11000000000000.0000 EOS"
                }
                r = eosapi.push_action('eosio.token', 'create', msg,
                                       {'eosio.token': 'active'})
                assert r
                r = eosapi.push_action(
                    'eosio.token', 'issue', {
                        "to": "eosio",
                        "quantity": "10000000000000.0000 EOS",
                        "memo": ""
                    }, {'eosio': 'active'})
                assert r
Beispiel #6
0
def test_transfer():
    balance = eosapi.get_balance('evm')
    call('testTransfer', (), amount=10000) #1.0 EOS
    assert math.isclose(balance+1, eosapi.get_balance('evm')+0.0001)