def newBatch(): transsuite = int(20 + random.random() * 100) msgjs = [] scopes = set() acccount = len(accpool) print('tps batch msgs: ' + str(transsuite * 2)) for idx in range(0, transsuite): idx1 = int(random.random() * acccount) step = 1 + int(random.random() * acccount / 2) idx2 = int(idx1 + step) % acccount acc1 = accpool[idx1] acc2 = accpool[idx2] newjson1 = transfer.transferJson(acc1, acc2, TEST_TRANSFER_AMOUNT, "") newjson2 = transfer.transferJson(acc2, acc1, TEST_TRANSFER_AMOUNT, "") msgjs.append(newjson1) msgjs.append(newjson2) scopes.add(acc1) scopes.add(acc2) ss = [i for i in scopes] ss.sort() trxjson = trx.formatTrxJson(msgjs, ss) postjson = trx.formatPostJson([ACTIVE_KEY_PRIVATE], [trxjson]) rpc.pushTrxRpc(RPC_SERVER_POINT, postjson, False)
def transferToken(fromAcc, toAcc, amount, memo): newjson = transfer.transferJson(fromAcc, toAcc, amount, memo) scopes = [fromAcc, toAcc] trxjson = trx.formatTrxJson([newjson], scopes) postjson = trx.formatPostJson([ACTIVE_KEY_PRIVATE], [trxjson]) rpc.pushTrxRpc(RPC_SERVER_POINT, postjson, False) return
def transferTest(Acc1, Acc2, amount): newjson1 = transfer.transferJson(Acc1, Acc2, amount, "") scopes = [Acc1, Acc2] scopes.sort() msgs = [newjson1] trxjson = trx.formatTrxJson(msgs, scopes) postjson = trx.formatPostJson([ACTIVE_KEY_PRIVATE], [trxjson]) rpc.pushTrxRpc(RPC_SERVER_POINT, postjson, False) return
def newAccount(accname, amount): newaccjson = account.newAccountJson(CREATOR_NAME, accname, amount, OWNER_KEY, ACTIVE_KEY) scopes = [CREATOR_NAME] trxjson = trx.formatTrxJson([newaccjson], scopes) postjson = trx.formatPostJson([CREATOR_PRI_KEY], [trxjson]) print('new account: ' + accname) rpc.pushTrxRpc(RPC_SERVER_POINT, postjson, False) return
def transferTest(Acc1, Acc2, amount, count): newjson1 = transfer.transferJson(Acc1, Acc2, amount, "") newjson2 = transfer.transferJson(Acc2, Acc1, amount, "") scopes = [Acc1, Acc2] msgs = [] for idx in range(0, count): if(idx % 2 == 0): msgs.append(newjson1) else: msgs.append(newjson2) trxjson = trx.formatTrxJson(msgs, scopes) postjson = trx.formatPostJson([ACTIVE_KEY_PRIVATE], [trxjson]) rpc.pushTrxRpc(RPC_SERVER_POINT, postjson, False) return
for idx in range(0, TEST_NEWACC_COUNT): if (idx % SLEEP_POINT == 0): print('sleepping...') time.sleep(SLEEP_TIME) accname = accName(prefix, idx) newaccjson = account.newAccountJson(CREATOR_NAME, accname, 1, OWNER_KEY, ACTIVE_KEY) scopes = [CREATOR_NAME] trxjson = trx.formatTrxJson([newaccjson], scopes) postjson = trx.formatPostJson([CREATOR_PRI_KEY], [trxjson]) print('new account: ' + accname) rpc.pushTrxRpc(RPC_SERVER_POINT, postjson, False) #print(postjson) time.sleep(0.5) for idx in range(0, TEST_NEWACC_COUNT): accname = accName(prefix, idx) getjson = account.getAccountJson(accname) rpc.rpcCall(GET_ACC_RPC, getjson, True) time.sleep(SLEEP_TIME)