コード例 #1
0
ファイル: demotool.py プロジェクト: LoopNewtorkInc/Loopchain
def menu4_8(params):
    peer_stub = params[0]
    test_start_time = datetime.datetime.now()

    print("Input Maximum Create Tx Random Times: default 1000")
    max_times = input(" >>  ")
    if max_times == "":
        max_times = 1000

    print("Input Maximum Sleep Seconds Random: default 10")
    max_sleep = input(" >>  ")
    if max_sleep == "":
        max_sleep = 10

    while True:
        random_times = random.randrange(0, int(max_times))
        random_sleep = random.randrange(0, int(max_sleep))
        print(f"Random Test try: {random_times} times and {random_sleep} seconds sleep, "
              f"total test mins({util.datetime_diff_in_mins(test_start_time)})")
        try:
            for i in range(random_times):
                peer_stub.CreateTx(
                    loopchain_pb2.CreateTxRequest(
                        data=f"TEST transaction data by demotool {i}",
                        channel=test_globals["channel_name"]
                    )
                )
            time.sleep(random_sleep)
        except KeyboardInterrupt:
            break
コード例 #2
0
ファイル: demotool.py プロジェクト: racingslab/loopchain
def menu4_2(params):
    peer_stub = params[0]
    print("Create Tx Performance Test")
    grpc_performance_test(
        peer_stub, "CreateTx",
        loopchain_pb2.CreateTxRequest(
            data="TEST transaction data by demotool"))
コード例 #3
0
ファイル: demotool.py プロジェクト: LoopNewtorkInc/Loopchain
def menu4_13(params):
    peer_stub = params[0]

    print("Input Repeat Times: default 100000")
    repeat_times = input(" >>  ")
    if repeat_times == "":
        repeat_times = 100000
    repeat_times = int(repeat_times)

    print("Input Test Interval Seconds: default 10")
    test_interval = input(" >>  ")
    if test_interval == "":
        test_interval = 10
    test_interval = int(test_interval)

    print("Allow fail times during test: default 3 (immediately stop)")
    allow_fails = input(" >>  ")
    if allow_fails == "":
        allow_fails = 3
    allow_fails_reset = int(allow_fails)
    allow_fails = allow_fails_reset
    test_times = 0
    fail_times = 0

    while repeat_times > 0:
        response = peer_stub.CreateTx(
            loopchain_pb2.CreateTxRequest(
                data=f"TEST transaction data by demotool",
                channel=test_globals["channel_name"]
            )
        )
        tx_hash = response.tx_hash
        print(f"Create Tx({tx_hash}) remain times({repeat_times})")

        time.sleep(test_interval)
        response = peer_stub.GetTx(loopchain_pb2.GetTxRequest(
            tx_hash=tx_hash,
            channel=test_globals["channel_name"]
        ), conf.GRPC_TIMEOUT)

        if response.response_code != message_code.Response.success:
            allow_fails -= 1
            fail_times += 1
        else:
            allow_fails = allow_fails_reset

        print("Find Tx: " + str(response))
        print(f"({test_times}) test times, ({allow_fails}) allow fails, ({fail_times}) fail times")

        time.sleep(test_interval)
        test_times += 1

        if allow_fails <= 0:
            response = requests.get("http://127.0.0.1:9002" + "/api/v1/peer/status-list")
            print("Radio Station Last Status List: ")
            print(util.pretty_json(response.text))
            menu7()

        repeat_times -= 1
コード例 #4
0
 def create_transaction(self, data):
     # logging.debug("Grpc Create Tx Data : " + data)
     return self.__stub_to_peer_service.CreateTx(
         loopchain_pb2.CreateTxRequest(data=data), self.REST_GRPC_TIMEOUT)
コード例 #5
0
 def create_transaction(self, data, channel):
     # logging.debug("Grpc Create Tx Data : " + data)
     return PeerServiceStub().call(
         "CreateTx",
         loopchain_pb2.CreateTxRequest(data=data, channel=channel),
         PeerServiceStub.REST_GRPC_TIMEOUT)
コード例 #6
0
ファイル: rest_server.py プロジェクト: hyerim-kim/loopchain
 def create_transaction(self, data):
     return self.__stub_to_peer_service.CreateTx(
         loopchain_pb2.CreateTxRequest(data=data), conf.GRPC_TIMEOUT)