def send_message(): r = eosapi.get_table('test','currency','account') print(r) r = eosapi.get_table('inita','currency','account') print(r) #inita is require for scoping with producer: r = eosapi.push_message('test','testmsg','',['test','inita'],{'test':'active'},rawargs=True) assert r r = eosapi.get_table('test','currency','account') print(r) r = eosapi.get_table('inita','currency','account') print(r)
def test_bs(): with producer: args = { "buyer": { "name": "inita", "number": 1 }, "at_price": "2", "quantity": 4, "expiration": "2018-11-11T13:12:28", "fill_or_kill": 0 } scopes = ['exchange', 'inita'] permissions = {'inita': 'active'} r = eosapi.push_message('exchange', 'buy', args, scopes, permissions) args = { "seller": { "name": "initb", "number": 1 }, "at_price": "2", "quantity": 2, "expiration": "2018-11-11T13:12:28", "fill_or_kill": 0 } scopes = ['exchange', 'inita'] permissions = {'initb': 'active'} r = eosapi.push_message('exchange', 'sell', args, scopes, permissions) r = eosapi.get_table('exchange', 'exchange', 'account') print(r)
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)
def test(): with producer: r = eosapi.push_message( 'currency', 'transfer', '{"from":"currency","to":"inita","quantity":1000}', ['currency', 'inita'], {'currency': 'active'}) assert r r = eosapi.get_table('inita', 'currency', 'account') print(r)
def send_transaction(): r = eosapi.get_table('test', 'currency', 'account') print(r) r = eosapi.get_table('inita', 'currency', 'account') print(r) with producer: r = eosapi.push_message('test', 'testts', '', [ 'test', ], {'test': 'active'}, rawargs=True) assert r r = eosapi.get_table('test', 'currency', 'account') print(r) r = eosapi.get_table('inita', 'currency', 'account') print(r) producer() r = eosapi.get_table('test', 'currency', 'account') print(r) r = eosapi.get_table('inita', 'currency', 'account') print(r)