예제 #1
0
파일: test.py 프로젝트: anklee/pyeos
def test_rent3():
    balance_test1 = eosapi.get_account('test')
    balance_currency1 = eosapi.get_account('currency')
    amount = 1

    show_rent_result(b'test', b'currency')

    with producer:
        stake = {'from':'test','to':'currency','amount':amount}
        r = eosapi.push_message('eos', 'stake', stake, ['eos', 'test', 'currency'], {'test':'active'})
        assert r

    show_rent_result(b'test', b'currency')

    amount = 1
    #try to unstake 1000 eos from test
    with producer:
        stake = {'from':'test','to':'currency','amount':amount}
        r = eosapi.push_message('eos', 'unstake', stake, ['eos', 'test', 'currency'], {'test':'active'})
        assert r

    show_rent_result(b'test', b'currency')

    amount = 1
    with producer:
        stake = {'from':'test','to':'currency','amount':amount}
        r = eosapi.push_message('eos', 'release', stake, ['eos', 'test', 'currency'], {'test':'active'})
        assert r

    show_rent_result(b'test', b'currency')
예제 #2
0
파일: test.py 프로젝트: eosconsultant/pyeos
def test_rent2():
    balance_test1 = eosapi.get_account('test')
    balance_currency1 = eosapi.get_account('currency')
    amount = 1
    with producer:
        stake = {'from': 'test', 'to': 'currency', 'amount': amount}
        r = eosapi.push_message('eos', 'stake', stake,
                                ['eos', 'test', 'currency'],
                                {'test': 'active'})
        assert r

    amount = 2
    with producer:
        stake = {'from': 'inita', 'to': 'currency', 'amount': amount}
        r = eosapi.push_message('eos', 'stake', stake,
                                ['eos', 'inita', 'currency'],
                                {'inita': 'active'})
        assert r

    #try to unstake 1000 eos from test
    amount = 1000
    with producer:
        stake = {'from': 'test', 'to': 'currency', 'amount': amount}
        r = eosapi.push_message('eos', 'unstake', stake,
                                ['eos', 'test', 'currency'],
                                {'test': 'active'})
        assert not r
예제 #3
0
파일: test.py 프로젝트: anklee/pyeos
def init():
    psw = 'PW5Kd5tv4var9XCzvQWHZVyBMPjHEXwMjH1V19X67kixwxRpPNM4J'
    wallet.open('mywallet')
    wallet.unlock('mywallet', psw)
    
    key1 = 'EOS61MgZLN7Frbc2J7giU7JdYjy2TqnfWFjZuLXvpHJoKzWAj7Nst'
    key2 = 'EOS5JuNfuZPATy8oPz9KMZV2asKf9m8fb2bSzftvhW55FKQFakzFL'
    
    with producer:
        if not eosapi.get_account('currency'):
            r = eosapi.create_account('inita', 'currency', key1, key2)

        if not eosapi.get_account('test'):
            r = eosapi.create_account('inita', 'test', key1, key2)
            assert r

    with producer:
        r = eosapi.set_contract('currency', '../../programs/pyeos/contracts/currency/currency.py', '../../contracts/currency/currency.abi', eosapi.py_vm_type)
        assert r
        r = eosapi.set_contract('test','../../programs/pyeos/contracts/test/code.py','../../programs/pyeos/contracts/test/test.abi', eosapi.py_vm_type)
        assert r

    #transfer some "money" to test account for test
    with producer:
        r = eosapi.push_message('currency','transfer','{"from":"currency","to":"test","quantity":1000}',['currency','test'],{'currency':'active'})
        assert r

    #transfer some "money" to test account for test
    with producer:
        r = eosapi.push_message('eos','transfer',{"from":"inita","to":"test","amount":1000,"memo":"hello"},['inita','test'],{'inita':'active'})
        assert r
예제 #4
0
파일: test.py 프로젝트: eosconsultant/pyeos
def test2():
    with producer:
        if not eosapi.get_account('currency'):
            r = eosapi.create_account('inita', 'currency', key1, key2)
            assert r
        if not eosapi.get_account('test'):
            if not eosapi.get_account('test'):
                r = eosapi.create_account('inita', 'test', key1, key2)
                assert r
        r = eosapi.set_contract('currency',
                                '../../contracts/currency/currency.py',
                                '../../contracts/currency/currency.abi', 1)

    start = time.time()
    ts = PySignedTransaction()
    ts.reqire_scope(b'test')
    ts.reqire_scope(b'currency')

    for i in range(1):
        data = struct.pack("QQQ", N(b'currency'), N(b'test'), 1)
        msg = PyMessage()
        msg.init(b'currency', b'transfer', [[b'currency', b'active']], data)
        ts.add_message(msg)

    ctl = chain_controller()
    ctl.process_transaction(ts)
    r = eosapi.get_table(b'test', b'currency', b'account')
    print(r)
    print('cost:', time.time() - start)
예제 #5
0
파일: test.py 프로젝트: 51weekend/pyeos
def init():
    psw = 'PW5Kd5tv4var9XCzvQWHZVyBMPjHEXwMjH1V19X67kixwxRpPNM4J'
    wallet.open('mywallet')
    wallet.unlock('mywallet', psw)

    key1 = 'EOS61MgZLN7Frbc2J7giU7JdYjy2TqnfWFjZuLXvpHJoKzWAj7Nst'
    key2 = 'EOS5JuNfuZPATy8oPz9KMZV2asKf9m8fb2bSzftvhW55FKQFakzFL'
    if not eosapi.get_account('currency'):
        with producer:
            r = eosapi.create_account('inita', 'currency', key1, key2)
            assert r

    if not eosapi.get_account('exchange'):
        with producer:
            r = eosapi.create_account('inita', 'exchange', key1, key2)
            assert r

    with producer:
        r = eosapi.set_contract(
            'currency', '../../programs/pyeos/contracts/currency/currency.py',
            '../../contracts/currency/currency.abi', 1)
        assert r
        r = eosapi.set_contract(
            'exchange', '../../programs/pyeos/contracts/exchange/exchange.py',
            '../../contracts/exchange/exchange.abi', 1)
        assert r
예제 #6
0
파일: test.py 프로젝트: eosconsultant/pyeos
def show_result():
    r = eosapi.get_account('test')

    print('r.balance:', r.balance)
    print('r.stakedBalance:', r.stakedBalance)
    print('r.unstakingBalance:', r.unstakingBalance)

    r = eosapi.get_account('currency')
    print('r.stakedBalance:', r.stakedBalance)
    print('r.unstakingBalance:', r.unstakingBalance)
예제 #7
0
파일: test.py 프로젝트: eosconsultant/pyeos
def claim_eos():
    args = {"account": "test", "amount": 1000}
    scopes = ['test', 'eos']
    permissions = {'test': 'active'}

    with producer:
        r = eosapi.push_message('eos', 'claim', args, scopes, permissions)

    r = eosapi.get_account('inita')
    print(r)
    r = eosapi.get_account('test')
    print(r)
예제 #8
0
파일: test.py 프로젝트: eosconsultant/pyeos
def init():
    with producer:
        if not eosapi.get_account('micropython'):
                r = eosapi.create_account('inita', 'micropython', initeos.key1, initeos.key2)
                assert r
        if not eosapi.get_account('test'):
            if not eosapi.get_account('test'):
                r = eosapi.create_account('inita', 'test', initeos.key1, initeos.key2)
                assert r

    with producer:
        r = eosapi.set_contract('micropython','../../programs/pyeos/contracts/micropython/mp.py','../../contracts/currency/currency.abi',2)
#        r = eosapi.set_contract('currency', '../../build/contracts/currency/currency.wast', '../../build/contracts/currency/currency.abi',0)
        assert r
예제 #9
0
파일: test.py 프로젝트: eosconsultant/pyeos
def lock_eos():
    #    args = {"from":"inita", "to":"test", "amount":1000, "memo":"hello"}
    #    scopes = ['test', 'inita', 'eos']
    args = {"from": "inita", "to": "test", "amount": 50}
    scopes = ['inita', 'eos', 'test']
    permissions = {'inita': 'active'}

    with producer:
        r = eosapi.push_message('eos', 'lock', args, scopes, permissions)

    r = eosapi.get_account('inita')
    print(r)
    r = eosapi.get_account('test')
    print(r)
예제 #10
0
def init(mpy=True):
    with producer:
        if not eosapi.get_account('backyard').permissions:
            r = eosapi.create_account('eosio', 'backyard', initeos.key1,
                                      initeos.key2)
            assert r

    with producer:
        if mpy:
            with open('../../programs/pyeos/contracts/backyard/backyard.mpy',
                      'wb') as f:
                f.write(
                    eosapi.mp_compile(
                        '../../programs/pyeos/contracts/backyard/backyard.py'))
            r = eosapi.set_contract(
                'backyard',
                '../../programs/pyeos/contracts/backyard/backyard.mpy',
                '../../programs/pyeos/contracts/backyard/backyard.abi', 1)
        else:
            r = eosapi.set_contract(
                'backyard',
                '../../programs/pyeos/contracts/backyard/backyard.py',
                '../../programs/pyeos/contracts/backyard/backyard.abi', 1)
            #        r = eosapi.set_contract('currency', '../../build/contracts/currency/currency.wast', '../../build/contracts/currency/currency.abi',0)
            assert r
예제 #11
0
def deploy(account, src):
    if not eosapi.get_account(account):
        print('account does not exists, create it.')
        r = eosapi.create_account2('eosio', account, initeos.key1,
                                   initeos.key2)
        assert r
    '''
    abs_src_file = os.path.dirname(__file__)
    last_update = eosapi.get_code_update_time_ms(account)
    modify_time = os.path.getmtime(abs_src_file)*1000
    if last_update >= modify_time:
        return
    '''

    actions = []
    _src_dir = os.path.dirname(__file__)
    abi_file = os.path.join(_src_dir, 'tester.abi')
    setabi = eosapi.pack_setabi(abi_file, eosapi.N(account))
    act = ['eosio', 'setabi', setabi, {account: 'active'}]
    actions.append(act)

    args = eosapi.pack_args(
        "eosio", 'setcode', {
            'account': account,
            'vmtype': 10,
            'vmversion': 0,
            'code': src.encode('utf8').hex()
        })
    act = ['eosio', 'setcode', args, {account: 'active'}]
    actions.append(act)

    r, cost = eosapi.push_actions(actions)
    print(r['except'])
    print(r['elapsed'])
예제 #12
0
파일: t.py 프로젝트: shuke0327/pyeos
def init():
    with producer:
        r = eosapi.get_account('evm')
        if not r:
            print('evm account not exist, create it.')
            r = eosapi.create_account('eosio', 'evm', initeos.key1, initeos.key2)
            assert r
예제 #13
0
def init():
    if not eosapi.get_account('currency'):
        with producer:
            r = eosapi.create_account('inita', 'currency', initeos.key1, initeos.key2)
            assert r

    if not eosapi.get_account('exchange'):
        with producer:
            r = eosapi.create_account('inita', 'exchange', initeos.key1, initeos.key2)
            assert r

    with producer:
        r = eosapi.set_contract('currency', '../../programs/pyeos/contracts/currency/currency.py', '../../contracts/currency/currency.abi', eosapi.py_vm_type)
        assert r
        r = eosapi.set_contract('exchange', '../../programs/pyeos/contracts/exchange/exchange.py', '../../contracts/exchange/exchange.abi', eosapi.py_vm_type)
        assert r
예제 #14
0
def init():

    psw = 'PW5Kk1h8RqDwf8CB8mKcz7WZ8r6MF9of9CYvrC96XdBL5Z1SwBVx9'

    if not os.path.exists('data-dir/mywallet.wallet'):
        psw = wallet.create('mywallet')
        print(psw)

    wallet.open('mywallet')
    wallet.unlock('mywallet', psw)

    priv_keys = [
        '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3',
        '5JEcwbckBCdmji5j8ZoMHLEUS8TqQiqBG1DRx1X9DN124GUok9s',
        '5JbDP55GXN7MLcNYKCnJtfKi9aD2HvHAdY7g8m67zFTAFkY1uBB'
    ]

    keys = wallet.list_keys()
    exist_priv_keys = keys.values()
    for priv_key in priv_keys:
        if not priv_key in exist_priv_keys:
            wallet.import_key('mywallet', priv_key)

    src_dir = os.path.dirname(os.path.abspath(__file__))
    sys.path.append(os.path.join(src_dir, '/contracts/cryptokitties'))
    contracts_path = os.path.join(src_dir, '../../build', 'contracts')
    for account in ['eosio.bios', 'eosio.msig', 'eosio.system', 'eosio.token']:
        if not eosapi.get_account(account).permissions:
            r = eosapi.create_account('eosio', account, key1, key2)
            assert r
        if not eosapi.get_code(account):
            wast = os.path.join(contracts_path, account, account + '.wast')
            abi = os.path.join(contracts_path, account, account + '.abi')
            r = eosapi.set_contract(account, wast, abi, 0)
        eosapi.produce_block()
예제 #15
0
 def func_wrapper(*args, **kwargs):
     if not eosapi.get_account('evm'):
         print('evm account not exist, create it.')
         r = eosapi.create_account('eosio', 'evm', initeos.key1,
                                   initeos.key2)
         assert r
     func(*args, **kwargs)
예제 #16
0
파일: test.py 프로젝트: eosconsultant/pyeos
def test3(count, d=0):
    keys = list(wallet.list_keys().keys())
    for i in range(0, count):
        currency = 'curre'+n2s(i)
#        currency = 'currency'

        key1 = keys[i]
        key2 = keys[10000+i]

        if not eosapi.get_account(currency).permissions:
            r = eosapi.create_account('eosio', currency, key1, key2)
            assert r
        if d:
            if d==1:
                r = eosapi.set_contract(currency,'../../programs/pyeos/contracts/currency/currency.py','../../contracts/currency/currency.abi', 1)
            elif d == 2:
                with open('../../programs/pyeos/contracts/currency/currency.mpy', 'wb') as f:
                    data = eosapi.mp_compile('../../programs/pyeos/contracts/currency/currency.py')
                    f.write(data)
                r = eosapi.set_contract(currency,'../../programs/pyeos/contracts/currency/currency.mpy','../../contracts/currency/currency.abi', 1)
            elif d == 3:
                wast = '../../build/contracts/currency/currency.wast'
                key_words = b"hello,world\\00"
                wast = '../../build/contracts/currency/currency.wast'
                with open(wast, 'rb') as f:
                    data = f.read()
                    #data.find(key_words)
                    replace_str = b"%s\\00"%(currency.encode('utf8'),)
                    replace_str.zfill(len(key_words))
                    #replace key works with custom words to break the effect of code cache mechanism
                    data = data.replace(key_words, replace_str)
                    with open('currency2.wast', 'wb') as f:
                        f.write(data)
                r = eosapi.set_contract(currency, 'currency2.wast', '../../build/contracts/currency/currency.abi',0)
            else:
                assert 0

    eosapi.produce_block()

    accounts = []
    functions = []
    args = []
    per = []
    
    for i in range(0, count):
        currency = 'curre'+n2s(i)
        accounts.append(currency)
        per.append({currency:'active'})
        functions.append('issue')
        arg = str(i)
        args.append({"to":currency,"quantity":"1000.0000 CUR","memo":""})
    ret = eosapi.push_messages(accounts, functions, args, per, True, rawargs=False)

    assert ret
    if ret:
        cost = ret['cost_time']
    eosapi.produce_block()

    print('total cost time:%.3f s, cost per action: %.3f ms, actions per second: %.3f'%(cost/1e6, cost/count/1000, 1*1e6/(cost/count)))
예제 #17
0
파일: test.py 프로젝트: eosconsultant/pyeos
def init(wasm = False):
    with producer:
        if not eosapi.get_account('currency').permissions:
                r = eosapi.create_account('eosio', 'currency', initeos.key1, initeos.key2)
                assert r
        if not eosapi.get_account('test').permissions:
            if not eosapi.get_account('test'):
                r = eosapi.create_account('eosio', 'test', initeos.key1, initeos.key2)
                assert r

    with producer:
        if wasm:
            r = eosapi.set_contract('currency', '../../build/contracts/currency/currency.wast', '../../build/contracts/currency/currency.abi',0)
            assert r
        else:
            r = eosapi.set_contract('currency','../../programs/pyeos/contracts/currency/currency.py','../../contracts/currency/currency.abi', 1)
            assert r
예제 #18
0
파일: test.py 프로젝트: eosconsultant/pyeos
def play():
    with producer:
        if not eosapi.get_account('hello').permissions:
            r = eosapi.create_account('eosio', 'hello', initeos.key1, initeos.key2)
            assert r
    with producer:
        r = eosapi.push_message('hello','play','',{'hello':'active'},rawargs=True)
        assert r
예제 #19
0
파일: test.py 프로젝트: eosconsultant/pyeos
def test_rent():
    balance_test1 = eosapi.get_account('test')
    balance_currency1 = eosapi.get_account('currency')
    amount = 1
    with producer:
        stake = {'from': 'test', 'to': 'currency', 'amount': amount}
        r = eosapi.push_message('eos', 'stake', stake,
                                ['eos', 'test', 'currency'],
                                {'test': 'active'})
        assert r

    balance_test2 = eosapi.get_account('test')
    balance_currency2 = eosapi.get_account('currency')

    assert balance_test1.balance == balance_test2.balance + amount
    assert balance_currency1.balance == balance_currency2.balance
    assert balance_currency1.stakedBalance + amount == balance_currency2.stakedBalance

    balance_test1 = balance_test2
    balance_currency1 = balance_currency2

    with producer:
        stake = {'from': 'test', 'to': 'currency', 'amount': amount}
        r = eosapi.push_message('eos', 'unstake', stake,
                                ['eos', 'test', 'currency'],
                                {'test': 'active'})
        assert r

    balance_test2 = eosapi.get_account('test')
    balance_currency2 = eosapi.get_account('currency')

    assert balance_test1.balance == balance_test2.balance
    assert balance_currency1.balance == balance_currency2.balance
    assert balance_currency1.stakedBalance == balance_currency2.stakedBalance + amount
    assert balance_currency1.unstakingBalance == balance_currency2.unstakingBalance - amount

    balance_test1 = balance_test2
    balance_currency1 = balance_currency2

    with producer:
        stake = {'from': 'test', 'to': 'currency', 'amount': amount}
        r = eosapi.push_message('eos', 'release', stake,
                                ['eos', 'test', 'currency'],
                                {'test': 'active'})
        assert r

    balance_test2 = eosapi.get_account('test')
    balance_currency2 = eosapi.get_account('currency')

    print(balance_test1.balance, balance_test2.balance)

    assert balance_test1.balance + amount == balance_test2.balance
    assert balance_currency1.balance == balance_currency2.balance
    assert balance_currency1.stakedBalance == balance_currency2.stakedBalance
    assert balance_currency1.unstakingBalance == balance_currency2.unstakingBalance + amount
예제 #20
0
파일: test.py 프로젝트: eosconsultant/pyeos
def test(name=None):
    with producer:
        if not eosapi.get_account('hello').permissions:
            r = eosapi.create_account('eosio', 'hello', initeos.key1, initeos.key2)
            assert r
    with producer:
        if not name:
            name = 'mike'
        r = eosapi.push_message('hello','sayhello',name,{'hello':'active'},rawargs=True)
        assert r
예제 #21
0
파일: t.py 프로젝트: shuke0327/pyeos
 def func_wrapper(*args, **kwargs):
     if not eosapi.get_account('test'):
         r = eosapi.create_account('eosio', 'test', initeos.key1, initeos.key2)
         assert r
         eosapi.produce_block()
     if wasm:
         prepare('credit', 'credit.wast', 'credit.abi', __file__)
     else:
         prepare('credit', 'credit.py', 'credit.abi', __file__)
     return func(*args, **kwargs)
예제 #22
0
파일: test.py 프로젝트: eosconsultant/pyeos
def show_rent_result(from_, to_):
    balance = eosapi.get_account(from_).balance

    eos = N(b'eos')
    keys = struct.pack('Q', N(to_))
    values = bytes(16)
    ret = util.load(eos, eos, N(from_), keys, 0, 0, values)

    result = struct.unpack('QQ', values)
    print(ret, balance, result)
예제 #23
0
def init():
    if not eosapi.get_account('test').permissions:
        with producer:
            r = eosapi.create_account('eosio', 'test', initeos.key1, initeos.key2)
            assert r

    with producer:
        r = eosapi.set_contract('test','../../programs/pyeos/contracts/apitest/apitest.py','../../programs/pyeos/contracts/apitest/test.abi', 1)
        assert r
    eosapi.produce_block()
예제 #24
0
파일: t.py 프로젝트: openchatproject/safeos
def create_accounts():
    step = 500
    for i in range(0, len(accounts), step):
        with producer:
            for j in range(step):
                if i+j >= len(accounts):
                    break
                a = accounts[i+j]
                print(a, i, j)
                if not eosapi.get_account(a['name']):
                    eosapi.create_account('eosio', a['name'], a['pub'], a['pub'])
예제 #25
0
def init():
    if not eosapi.get_account('cache').permissions:
        with producer:
            r = eosapi.create_account('eosio', 'cache', initeos.key1,
                                      initeos.key2)
            assert r

    with producer:
        r = eosapi.set_contract(
            'cache', '../../programs/pyeos/contracts/cache/cache.py',
            '../../programs/pyeos/contracts/cache/test.abi', 1)
        assert r
예제 #26
0
def _create_account(account):
    actions = []
    newaccount = {
        'creator': 'eosio',
        'name': account,
        'owner': {
            'threshold': 1,
            'keys': [{
                'key': initeos.key1,
                'weight': 1
            }],
            'accounts': [],
            'waits': []
        },
        'active': {
            'threshold': 1,
            'keys': [{
                'key': initeos.key2,
                'weight': 1
            }],
            'accounts': [],
            'waits': []
        }
    }
    if not eosapi.get_account(account):
        _newaccount = eosapi.pack_args('eosio', 'newaccount', newaccount)
        act = ['eosio', 'newaccount', _newaccount, {'eosio': 'active'}]
        actions.append(act)
    '''
    args = {'payer':'eosio', 'receiver':account, 'quant':"1.0000 EOS"}
    args = eosapi.pack_args('eosio', 'buyram', args)
    act = ['eosio', 'buyram', {'eosio':'active'}, args]
    actions.append(act)
    '''

    args = {'payer': 'eosio', 'receiver': account, 'bytes': 128 * 1024 * 1024}
    args = eosapi.pack_args('eosio', 'buyrambytes', args)
    act = ['eosio', 'buyrambytes', args, {'eosio': 'active'}]
    actions.append(act)

    args = {
        'from': 'eosio',
        'receiver': account,
        'stake_net_quantity': '1.0050 EOS',
        'stake_cpu_quantity': '1.0050 EOS',
        'transfer': 1
    }
    args = eosapi.pack_args('eosio', 'delegatebw', args)
    act = ['eosio', 'delegatebw', args, {'eosio': 'active'}]
    actions.append(act)
    rr, cost = eosapi.push_actions(actions)
    assert_ret(rr)
예제 #27
0
def init():
    with producer:
        if not eosapi.get_account('rpctest').permissions:
            r = eosapi.create_account('eosio', 'rpctest', initeos.key1,
                                      initeos.key2)
            assert r

    with producer:
        r = eosapi.set_contract(
            'rpctest', '../../programs/pyeos/contracts/rpctest/rpctest.py',
            '../../programs/pyeos/contracts/rpctest/rpctest.abi', 3)
        #        r = eosapi.set_contract('currency', '../../build/contracts/currency/currency.wast', '../../build/contracts/currency/currency.abi',0)
        assert r
예제 #28
0
def test():
    if not eosapi.get_account('testapi'):
        eosapi.create_account('eosio', 'testapi', initeos.key1, initeos.key2)
        
    act = debug.wasm_test_action('test_types', 'types_size')

    lib_path = '/Users/newworld/dev/pyeos/build-debug/contracts/test_api/libtest_api_natived.dylib'
    debug.set_debug_contract('testapi', lib_path)

    add_test()
    ret, cost = eosapi.push_actions(actions)
    print(ret)
    print(cost)
예제 #29
0
파일: test.py 프로젝트: eosconsultant/pyeos
def init():
    with producer:
        if not eosapi.get_account('currency'):
            r = eosapi.create_account('inita', 'currency', initeos.key1,
                                      initeos.key2)

        if not eosapi.get_account('test'):
            r = eosapi.create_account('inita', 'test', initeos.key1,
                                      initeos.key2)
            assert r

    with producer:
        r = eosapi.set_contract(
            'currency', '../../programs/pyeos/contracts/currency/currency.py',
            '../../contracts/currency/currency.abi', eosapi.py_vm_type)
        assert r
        r = eosapi.set_contract(
            'test', '../../programs/pyeos/contracts/test/code.py',
            '../../programs/pyeos/contracts/test/test.abi', eosapi.py_vm_type)
        assert r

    #transfer some "money" to test account for test
    with producer:
        r = eosapi.push_message(
            'currency', 'transfer',
            '{"from":"currency","to":"test","quantity":1000}',
            ['currency', 'test'], {'currency': 'active'})
        assert r

    #transfer some "money" to test account for test
    with producer:
        r = eosapi.push_message('eos', 'transfer', {
            "from": "inita",
            "to": "test",
            "amount": 1000,
            "memo": "hello"
        }, ['inita', 'test'], {'inita': 'active'})
        assert r
예제 #30
0
def publish_system_contract():
    contracts_path = os.path.join(os.getcwd(), '..', 'contracts')
    sys.path.append(os.getcwd())
    for account in ['eosio.bios', 'eosio.msig', 'eosio.system', 'eosio.token']:
        print('account', account)
        if not eosapi.get_account(account):
            with producer:
                r = eosapi.create_account('eosio', account, key1, key2)
                assert r

        old_code = eosapi.get_code(account)
        if old_code:
            old_code = old_code[0]
        need_update = not old_code
        if old_code:
            print('+++++++++old_code[:4]', old_code[:4])
            if old_code[:4] != b'\x00asm':
                old_code = eosapi.wast2wasm(old_code)

            wast = os.path.join(contracts_path, account, account + '.wast')
            code = open(wast, 'rb').read()
            code = eosapi.wast2wasm(code)

            print(len(code), len(old_code), old_code[:20])
            if code == old_code:
                need_update = False
        if need_update:
            print('+++++++++code update', account)
            wast = os.path.join(contracts_path, account, account + '.wast')
            abi = os.path.join(contracts_path, account, account + '.abi')
            with producer:
                r = eosapi.set_contract(account, wast, abi, 0)

            if account == 'eosio.token':
                #                msg = {"issuer":"eosio","maximum_supply":"1000000000.0000 EOS","can_freeze":0,"can_recall":0, "can_whitelist":0}
                with producer:
                    msg = {
                        "issuer": "eosio",
                        "maximum_supply": "10000000000.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": "1000.0000 EOS",
                        "memo": ""
                    }, {'eosio': 'active'})
                    assert r