tx handler

This commit is contained in:
CJ Cobb
2020-12-23 13:18:39 -05:00
parent 251c6f6c49
commit 943cac57ea
10 changed files with 314 additions and 37 deletions

16
test.py
View File

@@ -22,13 +22,24 @@ async def account_info(ip, port):
except websockets.exceptions.ConnectionClosedError as e:
print(e)
async def tx(ip, port, tx_hash):
address = 'ws://' + str(ip) + ':' + str(port)
try:
async with websockets.connect(address) as ws:
await ws.send(json.dumps({"command":"tx","transaction":tx_hash}))
res = json.loads(await ws.recv())
print(res)
except websockets.exceptions.ConnectionClosedError as e:
print(e)
parser = argparse.ArgumentParser(description='test script for xrpl-reporting')
parser.add_argument('action', choices=["account_info"])
parser.add_argument('action', choices=["account_info", "tx"])
parser.add_argument('--ip', default='127.0.0.1')
parser.add_argument('--port', default='8080')
parser.add_argument('--hash')
@@ -39,6 +50,9 @@ def run(args):
if args.action == "account_info":
asyncio.get_event_loop().run_until_complete(
account_info(args.ip, args.port))
if args.action == "tx":
asyncio.get_event_loop().run_until_complete(
tx(args.ip, args.port, args.hash))
else:
print("incorrect arguments")