def test_action_updatedomain(self): # Example: Add another user into issue permimssion # Create a new domain name = fake_name() newdomain = AG.new_action('newdomain', name=name, creator=user.pub_key) trx = TG.new_trx() trx.add_action(newdomain) trx.add_sign(user.priv_key) api.push_transaction(data=trx.dumps()) # Create manage Permission with both user pub_key2, priv_key2 = ecc.generate_new_pair() # another user ar1 = base.AuthorizerRef('A', user.pub_key) ar2 = base.AuthorizerRef('A', pub_key2) issue_per = base.PermissionDef('issue', threshold=2) issue_per.add_authorizer(ar1, weight=1) issue_per.add_authorizer(ar2, weight=1) updatedomain = AG.new_action('updatedomain', name=name, issue=issue_per) trx = TG.new_trx() trx.add_action(updatedomain) trx.add_sign(user.priv_key) resp = api.push_transaction(data=trx.dumps()) self.assertTrue('transaction_id' in resp.text)
def test_action_updfungible(self): # create a new fungible sym_name, sym_id, sym_prec = fake_symbol() symbol = base.Symbol(sym_name=sym_name, sym_id=sym_id, precision=sym_prec) asset = base.new_asset(symbol) newfungible = AG.new_action('newfungible', name=sym_name, sym_name=sym_name, sym=symbol, creator=user.pub_key, total_supply=asset(100000)) trx = TG.new_trx() trx.add_action(newfungible) trx.add_sign(user.priv_key) api.push_transaction(trx.dumps()) # add pub2 into manage permission pub2, priv2 = ecc.generate_new_pair() ar1 = base.AuthorizerRef('A', user.pub_key) ar2 = base.AuthorizerRef('A', pub2) manage = base.PermissionDef('manage', threshold=2) manage.add_authorizer(ar1, weight=1) manage.add_authorizer(ar2, weight=1) updfungible = AG.new_action('updfungible', sym_id=str(sym_id), manage=manage) trx = TG.new_trx() trx.add_action(updfungible) trx.add_sign(user.priv_key) resp = api.push_transaction(trx.dumps()).text self.assertTrue('transaction_id' in resp)
def test_action_issuefungible(self): # Create a fungible, and then use the issue fungible with the asset sym_name, sym_id, sym_prec = fake_symbol() symbol = base.Symbol(sym_name=sym_name, sym_id=sym_id, precision=sym_prec) asset = base.new_asset(symbol) newfungible = AG.new_action('newfungible', name=sym_name, sym_name=sym_name, sym=symbol, creator=user.pub_key, total_supply=asset(100000)) trx = TG.new_trx() trx.add_action(newfungible) trx.add_sign(user.priv_key) api.push_transaction(trx.dumps()) pub2, priv2 = ecc.generate_new_pair() issuefungible = AG.new_action( 'issuefungible', address=base.Address().set_public_key(pub2), number=asset(100), memo='goodluck') trx = TG.new_trx() trx.add_action(issuefungible) trx.add_sign(user.priv_key) resp = api.push_transaction(trx.dumps()).text self.assertTrue('transaction_id' in resp)
def test_action_transferft(self): # Create a fungible and issue sym_name, sym_id, sym_prec = fake_symbol() symbol = base.Symbol(sym_name=sym_name, sym_id=sym_id, precision=sym_prec) asset = base.new_asset(symbol) newfungible = AG.new_action('newfungible', name=sym_name, sym_name=sym_name, sym=symbol, creator=user.pub_key, total_supply=asset(100000)) trx = TG.new_trx() trx.add_action(newfungible) trx.add_sign(user.priv_key) api.push_transaction(trx.dumps()) issuefungible = AG.new_action('issuefungible', address=user.pub_key, number=asset(100), memo='goodluck') trx = TG.new_trx() trx.add_action(issuefungible) trx.add_sign(user.priv_key) api.push_transaction(trx.dumps()) # Transfer asset to pub2 pub2, priv2 = ecc.generate_new_pair() transferft = AG.new_action('transferft', _from=user.pub_key, to=pub2, number=asset(1), memo='goodjob') trx = TG.new_trx() trx.add_action(transferft) trx.add_sign(user.priv_key) resp = api.push_transaction(trx.dumps()).text self.assertTrue('transaction_id' in resp)
def test_action_transfer(self): domain_name = fake_name() token_name = fake_name('token') newdomain = AG.new_action('newdomain', name=domain_name, creator=user.pub_key) issuetoken = AG.new_action( 'issuetoken', domain=domain_name, names=[token_name], owner=[base.Address().set_public_key(user.pub_key)]) # create a new domain trx = TG.new_trx() trx.add_action(newdomain) trx.add_sign(user.priv_key) api.push_transaction(trx.dumps()) # issue a new token trx = TG.new_trx() trx.add_action(issuetoken) trx.add_sign(user.priv_key) api.push_transaction(trx.dumps()) # transfer the token to pub2 pub2, priv2 = ecc.generate_new_pair() transfer = AG.new_action('transfer', domain=domain_name, name=token_name, to=[pub2], memo='haha') trx = TG.new_trx() trx.add_action(transfer) trx.add_sign(user.priv_key) # priv_key of the owner of this token resp = api.push_transaction(trx.dumps()) self.assertTrue('transaction_id' in resp.text)