def issuefungible(self): fungible = self.get_item('fungible') asset = base.new_asset(fungible.sym) user = self.get_user() fungible.accounts.append(user) return { 'address': user.pub_key, 'number': asset(1), 'memo': fake_name('memo') }, fungible.priv_keys()
def newfungible(self): sym = fake_symbol(self.tg_name, self.symbols) asset = base.new_asset(sym) fungible = Fungible(sym, self.get_user(), total_supply=100000) self.add_item('fungible', fungible) return { 'sym': sym, 'creator': fungible.pub_key(), 'total_supply': asset(100000) }, fungible.priv_keys()
def transferft(self): fungible = None random.shuffle(self.pool['fungible']) for fung in self.pool['fungible']: if len(fung.accounts) > 0: fungible = fung break asset = base.new_asset(fungible.sym) user1 = random.choice(fungible.accounts) user2 = self.get_user() # not add user2 into accounts for convinient return { '_from': str(user1.pub_key), 'to': str(user2.pub_key), 'number': asset(0.0001), 'memo': fake_name('memo') }, [user1.priv_key]
def __init__(self, freq, users, watch_pool, sym='5,S#1', amount=10, nodes=None): self.freq = freq self.users = self.load_users(users) self.linkids = set([]) self.nodes = nodes self.sym = sym self.symbol_id = int(sym.split('#')[1]) self.balance = {} DBG_Symbol = base.Symbol('DBG', 666, 5) self.asset = base.new_asset(DBG_Symbol) self.amount = amount self.wp = watch_pool
def prepare_for_debug(filename): TG = TrxGenerator('http://127.0.0.1:8897', payer=None) Api = api.Api('http://127.0.0.1:8897') boss = base.User() # issue fungible DBG_Symbol = base.Symbol('DBG', 666, 5) DBG_Asset = base.new_asset(DBG_Symbol) act_newf = AG.new_action('newfungible', name='DBG', sym_name='DBG', sym=DBG_Symbol, creator=boss.pub_key, total_supply=DBG_Asset(1000000)) trx = TG.new_trx() trx.add_action(act_newf) trx.add_sign(boss.priv_key) trx.set_payer(boss.pub_key.to_string()) resp = Api.push_transaction(trx.dumps()) print(resp) with open(filename, 'r') as f: tmp = json.load(f) users = [ base.User.from_string(each['pub_key'], each['priv_key']) for each in tmp ] trx = TG.new_trx() for user in users: act_issue = AG.new_action('issuefungible', address=base.Address().set_public_key( user.pub_key), number=DBG_Asset(1000), memo='') trx.add_action(act_issue) trx.add_sign(boss.priv_key) trx.set_payer(boss.pub_key.to_string()) resp = Api.push_transaction(trx.dumps()) print(resp)