def t2(): with producer: r = eosapi.push_action('bugs','t2','',{'bugs':'active'}) assert r eosapi.produce_block()
def test_reentrant(sign=True): with producer: r = eosapi.push_action('bugs','t2','',{'bugs':'active'}) assert not r eosapi.produce_block()
def test(wasm=False): args = {"to": "currency", "quantity": "1000.0000 CUR", "memo": ""} r = eosapi.push_action('eosio.token', 'issue', args, {'eosio.token': 'active'}) assert r eosapi.produce_block()
def init(): psw = 'PW5K87AKbRvFFMJJm4dU7Zco4fi6pQtygEU4iyajwyTvmELUDnFBK' if not os.path.exists('data-dir/mywallet.wallet'): psw = wallet.create('mywallet') print('wallet password:'******'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) if eosapi.is_replay(): return src_dir = os.path.dirname(os.path.abspath(__file__)) ''' r = eosapi.push_message('eosio.token', 'create', {"to":"eosio", "quantity":"10000.0000 EOS", "memo":""},{'eosio':'active'}) r = eosapi.push_message('eosio.token','issue',{"to":"hello","quantity":"1000.0000 EOS","memo":""},{'hello':'active'}) assert r msg = {"from":"eosio", "to":"hello", "quantity":"25.0000 EOS", "memo":"m"} r = eosapi.push_message('eosio.token', 'transfer', msg, {'eosio':'active'}) assert r ''' contracts_path = os.path.join(src_dir, '../../build', '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).permissions: r = eosapi.create_account('eosio', account, key1, key2) assert r eosapi.produce_block() old_code = eosapi.get_code(account)[0] need_update = not old_code if False: #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: 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() if False: #account == 'eosio.token': msg = { "issuer": "eosio", "maximum_supply": "1000000000.0000 EOS", "can_freeze": 0, "can_recall": 0, "can_whitelist": 0 } r = eosapi.push_message('eosio.token', 'create', msg, {'eosio.token': 'active'}) assert r r = eosapi.push_message('eosio.token', 'issue', { "to": "eosio", "quantity": "1000.0000 EOS", "memo": "" }, {'eosio': 'active'}) assert r eosapi.produce_block() from backyard import t t.deploy_mpy() #load common libraries # t.load_all() console = PyEosConsole(locals=globals()) console.interact(banner='Welcome to PyEos')
def test(name='mike'): r = eosapi.push_message('hello', 'sayhello', name, {'eosio': 'active'}) assert r eosapi.produce_block()
def t3(count=100, sign=True): # tracemalloc.start() # snapshot1 = tracemalloc.take_snapshot() wast = '../../build/contracts/eosio.token/eosio.token.wast' key_words = b"hello,world" r = eosapi.set_contract( 'bugs', wast, '../../build/contracts/eosio.token/eosio.token.abi', 0) msg = { "issuer": "eosio", "maximum_supply": "1000000000.0000 EOS", "can_freeze": 0, "can_recall": 0, "can_whitelist": 0 } r = eosapi.push_message('bugs', 'create', msg, {'bugs': 'active'}) r = eosapi.push_message('bugs', 'issue', { "to": "bugs", "quantity": "1000000.0000 EOS", "memo": "" }, {'eosio': 'active'}) _src_dir = os.path.dirname(__file__) for i in range(count): actions = [] #break the wasm cache key_words = b"hello,world" wast_file = os.path.join( _src_dir, '/Users/newworld/dev/pyeos/build/contracts/eosio.token/eosio.token.wast' ) with open(wast_file, 'rb') as f: data = f.read() replace_str = b"%d" % (int(time.time()), ) replace_str.zfill(len(key_words)) data = data.replace(key_words, replace_str) wasm = eosapi.wast2wasm(data) raw_code = eosapi.pack_bytes(wasm) code = struct.pack('QBB', N('bugs'), 0, 0) code += raw_code act = [N('eosio'), N('setcode'), [[N('bugs'), N('active')]], code] setabi = eosapi.pack_setabi( '../../build/contracts/eosio.token/eosio.token.abi', eosapi.N('bugs')) setabi_action = [ N('eosio'), N('setabi'), [[N('bugs'), N('active')]], setabi ] actions.append([act, setabi_action]) code = struct.pack('QBB', N('eosio.token'), 0, 0) code += raw_code act = [ N('eosio'), N('setcode'), [[N('eosio.token'), N('active')]], code ] setabi = eosapi.pack_setabi( '../../build/contracts/eosio.token/eosio.token.abi', eosapi.N('eosio.token')) setabi_action = [ N('eosio'), N('setabi'), [[N('eosio.token'), N('active')]], setabi ] actions.append([act, setabi_action]) print('&' * 50) cost_time = eosapi.push_transactions2(actions, sign) print('*' * 50) msg = { "from": "bugs", "to": "eosio", "quantity": "0.0001 EOS", "memo": "%d" % (i, ) } r = eosapi.push_message('bugs', 'transfer', msg, {'bugs': 'active'}) print( '=' * 20, 'cached module should be decreased by 1 as eosio.token load the same code as bugs' ) msg = { "from": "bugs", "to": "eosio", "quantity": "0.0001 EOS", "memo": "%d" % (i, ) } r = eosapi.push_message('eosio.token', 'transfer', msg, {'bugs': 'active'}) if i % 50 == 0: cost_time = eosapi.produce_block() eosapi.produce_block()
def t(): with producer: r = eosapi.push_message('bugs', 't1', '', {'bugs': 'active'}) assert r eosapi.produce_block()
def test(): with producer: r = eosapi.push_message('test','dbtest','',{'test':'active','hello':'active'},rawargs=True) assert r eosapi.produce_block()
def test(name='mike'): r = eosapi.push_action('hello', 'sayhello', name, {'hello': 'active'}) assert r # print(eosapi.JsonStruct(r[0])) eosapi.produce_block()