Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_request_get_account_asset(self):
logger.info("test_request_get_account_asset")
req = GetAccountAssets(
account_id = "test@test",
asset_id = "test/test"
)
payload = Query.Payload()
wrap_query(payload,req)
self.assertEqual(payload,Query.Payload(
get_account_assets = req
))
def setUp(self):
logger.setDebug()
logger.info("ConnectionTest")
def test_sign_hash(self):
hash = crypto.sign_hash(self.tx.payload)
logger.info(hash)
logger.info(crypto.b64encode(hash))
sign = crypto.sign(self.keypair,hash)
logger.info(sign)
is_verify = crypto.verify(self.keypair.public_key,sign,hash)
logger.info(is_verify)
self.assertTrue(is_verify)
def add_asset_quantity(cmd):
logger.info("stateless validate add_asset_quantity")
if verify_asset_id(cmd.asset_id) and verify_account_id(cmd.account_id) and verify_amount(cmd.amount):
return True
return False
def command(cmd):
logger.info(cmd.HasField)
if cmd.HasField("create_account"):
return create_account(cmd.create_account)
elif cmd.HasField("add_signatory"):
return add_signatory(cmd.add_signatory)
elif cmd.HasField("remove_signatory"):
return remove_signatory(cmd.remove_signatory)
elif cmd.HasField("set_account_quorum"):
return set_account_quorum(cmd.set_account_quorum)
elif cmd.HasField("create_domain"):
return create_domain(cmd.create_domain)
elif cmd.HasField("create_asset"):
return create_asset(cmd.create_asset)
elif cmd.HasField("add_asset_quantity"):
return add_asset_quantity(cmd.add_asset_quantity)
elif cmd.HasField("transfer_asset"):
return transfer_asset(cmd.transfer_asset)
def add_signatory(cmd):
logger.info("stateless validate add_signatory")
if verify_account_id(cmd.account_id) and verify_pubkey(cmd.pubkey):
return True
return False
def remove_signatory(cmd):
logger.info("stateless validate remove_signaotry")
if verify_account_id(cmd.account_id) and verify_pubkey(cmd.pubkey):
return True
return False
return False
'''
if payload.HasField("get_account"):
return get_account(payload.get_account)
elif payload.HasField("get_signatories"):
return get_signatories(payload.get_signatories)
elif payload.HasField("get_account_transactions"):
return get_account_transactions(payload.get_account_transactions)
elif payload.HasField("get_account_asset_transactions"):
return get_account_asset_transactions(payload.get_account_asset_transactions)
elif payload.HasField("get_account_assets"):
return get_account_assets(payload.get_account_assets)
elif payload.HasField("get_transactions"):
return get_transactions(payload.get_transactions)
logger.info("Stateless validate Not has field")
return False
def verify_domain_id(domain_id):
if DOMAIN_ID.match(domain_id) is None:
logger.info("Stateless Domain Id Failed: " + domain_id)
return False
return True