Blockchain node testing method and device, electronic equipment and readable storage medium

CN115237794BActive Publication Date: 2026-09-25NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210921729.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-02
Publication Date
2026-09-25
Estimated Expiration
2042-08-02

AI Technical Summary

Technical Problem

但是,由于共识算法流程复杂,各个服务通信的通信流程复杂,上述两种方式除了无法完全自动化测试,流程复杂外,还无法完全模拟出共识算法中信息交互以及异常场景,导致测试效率以及准确率都较低

Benefits of technology

[0048]本申请实施例提供的区块链节点的测试方法、装置、电子设备及可读存储介质,建立模拟测试框架中各个模拟节点与待测试节点之间的通信连接,并基于待测试节点所属的区块链使用的目标共识算法的类型,生成与待测试节点进行通信的至少一条测试信息,并按照目标共识算法指示的通信顺序,控制各个模拟节点将至少一条测试信息发送至待测试节点;根据待测试节点基于至少一条待测试信息反馈的多条回复信息的信息回复内容、每条回复信息的回复时间以及不同回复信息之间的回复顺序,检测待测试节点处理的信息的流程是否符合预期信息处理规则,若不符合,生成节点预警信息。在本申请实施例中,预先构建的包含有多个模拟节点的模拟测试框架,模拟与待测试节点之间的信息交互过程,通过在交互信息层级,对待测试节点回复的信息的内容、时间以及不同信息之间的回复顺序多个信息维度进行检测,对共识算法内部逻辑以及待测试节点进行自动准确地测试,有助于提升区块链测试的测试效率以及准确率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115237794B_ABST
    Figure CN115237794B_ABST
Patent Text Reader

Abstract

The application provides a test method and device of a blockchain node, an electronic device and a readable storage medium. A communication connection between each simulation node in a simulation test framework and a to-be-tested node is established, and at least one piece of test information is sent to the to-be-tested node. According to the information reply content of multiple pieces of reply information fed back by the to-be-tested node to the test information, the reply time of each piece of reply information and the reply order between different pieces of reply information, whether the information processing flow of the to-be-tested node conforms to an expected information processing rule is detected. If not, a node warning information is generated. In the application, through a simulation test framework constructed in advance, the information interaction process between the simulation node and the to-be-tested node is simulated, the content, time and reply order between different pieces of information replied by the to-be-tested node are detected, the to-be-tested node is automatically and accurately tested, and the test efficiency and accuracy of the blockchain test are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of blockchain technology, and in particular to testing methods, apparatus, electronic devices and readable storage media for blockchain nodes. Background Technology

[0002] Consensus algorithms are a core element of blockchain technology, solving the problem of mutual trust among nodes in a distributed network. Research on blockchain typically begins with understanding its consensus algorithms.

[0003] Existing technologies for testing blockchain include: testing in a real-world environment by constructing anomaly tests such as killing processes or powering down machines; or using general automated testing frameworks to test via input / output. However, due to the complexity of consensus algorithms and the communication processes between various services, the above two methods, besides failing to fully automate testing and being too complex, also cannot fully simulate the information interaction and anomaly scenarios within the consensus algorithm, resulting in low testing efficiency and accuracy. Summary of the Invention

[0004] In view of this, the purpose of this application is to provide a testing method, device, electronic device and readable storage medium for blockchain nodes, a pre-constructed simulation testing framework containing multiple simulated nodes, to simulate the information interaction process between the node under test and the node under test. By detecting multiple information dimensions such as the content, time and order of responses between different information at the interaction information level, the internal logic of the consensus algorithm and the node under test can be automatically and accurately tested, which helps to improve the testing efficiency and accuracy of blockchain testing.

[0005] In a first aspect, embodiments of this application provide a method for testing a blockchain node, applied to a blockchain testing system. The blockchain testing system includes a node to be tested and a pre-built simulation testing framework for testing the node to be tested. The simulation testing framework includes at least one simulated node corresponding to a communication node that communicates and interacts with the node to be tested within the same blockchain. The testing method includes:

[0006] Establish communication connections between each simulated node in the simulation test framework and the node under test, and generate at least one piece of test information for communicating with the node under test based on the algorithm type of the target consensus algorithm used by the blockchain to which the node under test belongs;

[0007] According to the communication interaction order between the nodes of the blockchain to which the node under test belongs, as indicated by the target consensus algorithm, control each simulated node to send at least one test message to the node under test in the order of communication interaction.

[0008] Based on the information response content of multiple reply messages from the node under test in response to at least one test message, the reply time of each reply message, and the reply order between different reply messages, it is detected whether the information processing process of the node under test conforms to the expected information processing rules set by the target consensus algorithm.

[0009] If the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm, a node warning message is generated.

[0010] In one possible implementation, the internal information of the simulation testing framework is built based on the TTCN3 language, and the communication connection between the simulation testing framework and the node under test is established through the following steps:

[0011] Detect whether the node under test contains a TTCN3 language conversion layer;

[0012] If the node under test has a TTCN3 language conversion layer, determine the target language used inside the node under test.

[0013] After the mapping relationship between the target language and the TTCN3 language is set in the simulation test framework, a communication connection is established between each simulation node in the simulation test framework and the node to be tested.

[0014] In one possible implementation, generating at least one piece of test information for communication with the node under test, based on the algorithm type of the target consensus algorithm used by the blockchain to which the node under test belongs, includes:

[0015] Based on the algorithm type of the target consensus algorithm used by the blockchain to which the node to be tested belongs, determine the algorithm flow of the target consensus algorithm, and extract at least one consensus signaling message from the algorithm flow;

[0016] Based on the at least one consensus signaling message, perform message modeling to determine at least one modeling message;

[0017] For each modeling message, based on the mapping relationship between the target language and the TTCN3 language, the modeling message is converted into test information that the node to be tested can recognize.

[0018] In one possible implementation, the simulation testing framework further includes multiple pre-built test scenario cases. The step of detecting whether the information processing flow of the node under test conforms to the expected information processing rules set by the target consensus algorithm, based on the information response content of multiple response messages from the node under test in response to at least one received test message, the response time of each response message, and the response order between different response messages, includes:

[0019] Determine the target test scenario use cases for the current settings, and determine the preset target information response content and target message response order under the target test scenario use cases based on the target consensus algorithm;

[0020] Detect whether the response time for each reply exceeds a preset time threshold;

[0021] If the response time of each reply message does not exceed a preset time threshold, check whether the content of each reply message is consistent with the content of the target message reply, and whether the reply order between different reply messages is consistent with the reply order of the target message;

[0022] If multiple messages contain replies whose content is inconsistent with the target message's reply content, or if the reply order of different replies is inconsistent with the target message's reply order, it is determined that the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm.

[0023] In one possible implementation, the steps to determine that the response time for each reply message does not exceed a preset time threshold are as follows:

[0024] For each reply message, determine the current time when the corresponding simulated node receives the reply message;

[0025] For each reply message, the information time difference is determined based on the current time and the time when the test message corresponding to that reply message was sent;

[0026] For each reply message, if the time difference between the messages is less than a preset difference threshold, it is determined that the reply time of that reply message has not exceeded the preset time threshold.

[0027] In one possible implementation, determining the preset target information response content and target message response order under the target test scenario use case based on the target consensus algorithm includes:

[0028] Determine the content types of information responses in the target test scenario, as well as the proportion of different content types;

[0029] Based on the content type and the proportion of the same content type, combined with the information length specified by the target consensus algorithm and the important fields included in the information, the preset target information reply content is determined, and the target message reply order is determined based on the target consensus algorithm.

[0030] In one possible implementation, at least one simulation node included in the simulation testing framework is constructed through the following steps:

[0031] Identify at least one communication node in the blockchain to which the node under test belongs that interacts with the node under test;

[0032] For each communication node, based on the target consensus algorithm and the information flow direction in the communication node, a simulated node corresponding to the communication node is constructed using the TTCN3 language.

[0033] In one possible implementation, after constructing at least one piece of test information for communication with the node under test, the testing method further includes:

[0034] Based on the information processing efficiency of the node under test, the information response time of each simulated node after receiving the reply information is determined;

[0035] Each simulated node is controlled to respond to the node under test according to the response time after receiving the response information from the node under test, and to conduct information interaction.

[0036] In one possible implementation, generating a node warning message if the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm includes:

[0037] If the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm, for each reply message, a detection result corresponding to that reply message is determined; wherein, the detection result includes information content error, information reply timeout, and information reply order error;

[0038] The detection results of each reply are combined to generate the node warning information.

[0039] In one possible implementation, the testing method further includes:

[0040] If the information processing flow of the node under test conforms to the expected information processing rules set by the target consensus algorithm, the node under test is determined to have passed the test, and the simulation test framework is used to test other nodes in the same blockchain as the node under test.

[0041] Secondly, embodiments of this application also provide a testing device for a blockchain node, applied to a blockchain testing system. The blockchain testing system includes a node to be tested and a pre-built simulation testing framework for testing the node to be tested. The simulation testing framework includes at least one simulated node corresponding to a communication node that communicates and interacts with the node to be tested in the same blockchain. The testing device includes:

[0042] The communication establishment module is used to establish communication connections between each simulated node in the simulation test framework and the node under test, and to generate at least one piece of test information for communicating with the node under test based on the algorithm type of the target consensus algorithm used by the blockchain to which the node under test belongs.

[0043] The information sending module is used to control each simulated node to send at least one test message to the node under test in accordance with the communication interaction order between the nodes of the blockchain to which the node under test belongs, as indicated by the target consensus algorithm.

[0044] The response detection module is used to detect whether the information processing process of the node under test conforms to the expected information processing rules set by the target consensus algorithm, based on the information response content of multiple response messages fed back by the node under test in response to at least one test message, the response time of each response message, and the response order between different response messages.

[0045] The node early warning module is used to generate node early warning information if the information processing process of the node under test does not conform to the expected information processing rules set by the target consensus algorithm.

[0046] Thirdly, embodiments of this application also provide an electronic device, including: a processor, a storage medium, and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the blockchain node testing method as described in any of the first aspects.

[0047] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the blockchain node testing method as described in any of the first aspects.

[0048] The blockchain node testing method, apparatus, electronic device, and readable storage medium provided in this application establish communication connections between each simulated node and the node under test in a simulated testing framework. Based on the type of target consensus algorithm used by the blockchain to which the node under test belongs, at least one test message is generated for communication with the node under test. Following the communication order indicated by the target consensus algorithm, each simulated node is controlled to send at least one test message to the node under test. Based on the content of multiple response messages from the node under test based on at least one test message, the response time of each response message, and the response order between different response messages, the process of information processed by the node under test is detected to ensure it conforms to the expected information processing rules. If it does not conform, a node warning message is generated. In this application embodiment, a pre-constructed simulated testing framework containing multiple simulated nodes simulates the information interaction process between the node under test and the node under test. By detecting multiple information dimensions—content, time, and response order between different messages—at the interaction information level, the internal logic of the consensus algorithm and the node under test are automatically and accurately tested, which helps improve the testing efficiency and accuracy of blockchain testing.

[0049] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0050] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0051] Figure 1 A flowchart illustrating a blockchain node testing method provided in an embodiment of this application;

[0052] Figure 2 This is a schematic diagram of a consensus network in a physical environment provided in an embodiment of this application;

[0053] Figure 3 A schematic diagram of a simulated consensus network for the simulated test set provided in the embodiments of this application;

[0054] Figure 4 A flowchart illustrating another method for testing a blockchain node provided in an embodiment of this application;

[0055] Figure 5 This is one of the structural schematic diagrams of a blockchain node testing device provided in an embodiment of this application;

[0056] Figure 6 This is a second schematic diagram of the structure of a blockchain node testing device provided in an embodiment of this application;

[0057] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0058] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. Based on the embodiments of this application, every other embodiment obtained by those skilled in the art without inventive effort falls within the scope of protection of this application.

[0059] First, the applicable application scenarios of this application are introduced. This application can be applied to the field of blockchain technology. Consensus algorithm is the core element of blockchain technology, which solves the problem of mutual trust between distributed network nodes. Research on blockchain generally starts with consensus algorithm.

[0060] Existing technologies for testing blockchain include: testing in a real-world environment by constructing anomaly tests such as killing processes or powering down machines; or using general automated testing frameworks to test via input / output. However, due to the complexity of consensus algorithms and the communication processes between various services, the above two methods, besides failing to fully automate testing and being too complex, also cannot fully simulate the information interaction and anomaly scenarios within the consensus algorithm, resulting in low testing efficiency and accuracy.

[0061] Specifically, for real-world testing scenarios, it's difficult to cover consensus algorithms with multiple nodes (more than 10 nodes) due to the high costs of testing machines and manual operations. Furthermore, scenarios like machine power outages or network disconnections are difficult to control precisely with automated scripts, making automation challenging. Each code modification or optimization requires manual verification, resulting in high costs. While general automated testing frameworks can test interfaces, they can only simulate abnormal scenarios by breaking down the consensus process. Additionally, consensus algorithms have high real-time message requirements, and ordinary testing frameworks cannot handle time skew caused by task blocking within the framework. Therefore, both the efficiency and accuracy of blockchain testing are low.

[0062] Based on this, this application provides a method for testing blockchain nodes to improve the testing efficiency and accuracy of blockchain testing.

[0063] Please see Figure 1 , Figure 1 This is a flowchart illustrating a blockchain node testing method provided in an embodiment of this application. Figure 1 As shown in the embodiments of this application, the method for testing blockchain nodes includes:

[0064] S101. Establish communication connections between each simulated node in the simulation test framework and the node to be tested, and generate at least one piece of test information for communicating with the node to be tested based on the algorithm type of the target consensus algorithm used by the blockchain to which the node to be tested belongs.

[0065] S102. According to the communication interaction order between the nodes of the blockchain to which the node to be tested belongs, as indicated by the target consensus algorithm, control each simulated node to send the at least one test message to the node to be tested in the order of communication interaction.

[0066] S103. Based on the information response content of multiple response messages from the node under test in response to at least one test message received, the response time of each response message, and the response order between different response messages, detect whether the information processing process of the node under test conforms to the expected information processing rules set by the target consensus algorithm.

[0067] S104. If the information processing flow of the node to be tested does not conform to the expected information processing rules set by the target consensus algorithm, generate node warning information.

[0068] The blockchain node testing method provided in this application embodiment pre-constructs a simulation testing framework containing multiple simulated nodes to simulate the information interaction process between the node under test and the node under test. By detecting multiple information dimensions such as the content, time, and order of responses between different information at the interaction information level, the internal logic of the consensus algorithm and the node under test are automatically and accurately tested, which helps to improve the testing efficiency and accuracy of blockchain testing.

[0069] The exemplary steps of the embodiments of this application are described below:

[0070] S101. Establish communication connections between each simulated node in the simulation test framework and the node to be tested, and generate at least one piece of test information for communicating with the node to be tested based on the algorithm type of the target consensus algorithm used by the blockchain to which the node to be tested belongs.

[0071] In this embodiment, a blockchain testing system is used to test nodes in different blockchains. The blockchain testing system includes the node to be tested and a pre-built simulation testing framework for testing the node to be tested. The simulation testing framework tests the node to be tested in different testing scenarios by observing the feedback of the target consensus algorithm used by the blockchain to which the node to be tested belongs, thereby detecting whether the node to be tested is normal.

[0072] Consensus algorithms can be understood as a series of processes and rules developed to achieve distributed consensus protocols. When nodes distributed in different regions negotiate and interact according to these rules, they can eventually reach a consensus on one or more issues, thereby achieving consistency among different nodes in the distributed system. This allows multiple nodes within the same blockchain to cooperate and complete the corresponding services.

[0073] For example, commonly used consensus algorithms can include PoW, PoS, DPoS, PBFT, and RAFT.

[0074] It is worth noting that in this embodiment of the application, the solution is described using a simulation testing framework as the execution subject.

[0075] Specifically, in this application embodiment, the simulation test framework can be a test framework that includes at least one simulated communication node corresponding to a communication node that communicates and interacts with the node under test in the same blockchain, and in this application embodiment, a test framework based on TTCN3 is used.

[0076] TTCN-3 can be used as a description language for various response system tests on multiple communication ports. Typical application areas include protocol testing (including mobile protocols and internet protocols), service testing (including supplementary services), module testing, and CORBA testing based on platforms and APIs. TTCN-3 is not limited to conformance testing; it can be used for various types of testing, such as interoperability testing, robustness testing, regression testing, and system and integration testing. The top-level unit in TTCN-3 is the module.

[0077] Specifically, in one possible implementation, the test framework for the simulated node mainly includes a test management module, an encoding / decoding module, a port management module, and a clock source module.

[0078] Specifically, the test management module is used to call the simulation test framework to respond after the blockchain test system is started, and to build the test environment, test scenario and simulation node during the response process.

[0079] The encoding / decoding module is used to encode and decode message communication between the simulation test framework and the node under test. It encodes the TTCN-3 data sent to the node under test into messages that the node under test can recognize, and decodes the messages fed back by the node under test into TTCN3 data so that the simulation test framework can recognize them.

[0080] The port management module is used to represent different simulated nodes by creating different virtual ports. Port management includes configuration of the number of ports and management of send and receive directions.

[0081] The clock source module is used to start timing during testing and run until the test result is obtained. The clock source for the simulation test framework and the node under test is the same.

[0082] In one possible implementation, for a simulation testing framework, at least one simulation node included in the simulation testing framework can be constructed through the following steps:

[0083] a1: Identify at least one communication node in the blockchain to which the node under test belongs that interacts with the node under test.

[0084] a2: For each communication node, based on the target consensus algorithm and the information flow direction in the communication node, a simulated node corresponding to the communication node is constructed using the TTCN3 language.

[0085] In this embodiment of the application, when testing a certain node to be tested, it is necessary to completely simulate the normal information interaction of the node to be tested. Therefore, when setting up the simulation node, it is necessary to consider the number of communication nodes that interact with the node to be tested in the actual information interaction process. At the same time, it is also necessary to determine the information interaction order between the node to be tested and different communication nodes, and the information flow direction of each communication node that interacts with the node to be tested, so as to completely simulate the real information interaction process of the node to be tested. The most satisfactory simulation effect is that the information flow and interaction at the node to be tested is consistent with the actual information interaction scenario.

[0086] For example, please refer to Figure 2 as well as Figure 3 , Figure 2 This is a schematic diagram of a consensus network in a physical environment provided in an embodiment of this application. Figure 3 A schematic diagram of a simulated consensus network for the simulated test set provided in this application embodiment, as shown below. Figure 2 As shown, in a certain blockchain, nodes A, B, and C can communicate and exchange information. According to the consensus algorithm of this blockchain, nodes B and C can send information to node A simultaneously, with node C sending information before node B. Node B can receive information from node A, but node C does not receive information from node A. Therefore, as... Figure 3 As shown, when testing node A, i.e. when node A is the node to be tested, it is necessary to simulate node B' and node C'. At the same time, when sending test information to node A, the information sent by simulated node C' must be sent earlier than that of simulated node B', and only simulated node B' can receive and respond to the information of node A.

[0087] It is worth noting that since the overall simulation test framework in this application embodiment is built using TTCN3, the simulation nodes must also be built using the TTCN3 language.

[0088] In one possible implementation, since the internal information of the simulation test framework is built based on the TTCN3 language, but the language that can be recognized in the node under test is not necessarily the TTCN3 language, a conversion layer is required in the node under test to ensure normal communication between the simulation test framework and the node under test.

[0089] Specifically, the communication connection between the simulation test framework and the node under test is established through the following steps:

[0090] b1: Detect whether the TTCN3 language conversion layer exists inside the node to be tested.

[0091] b2: If the node under test has a TTCN3 language conversion layer, determine the target language used inside the node under test.

[0092] b3: After the mapping relationship between the target language and the TTCN3 language is set in the simulation test framework, establish the communication connection between each simulation node in the simulation test framework and the node to be tested.

[0093] In this embodiment of the application, after determining the node to be tested, it is also necessary to further determine whether there is a language conversion layer inside the node to be tested that can convert between different languages, that is, convert the received information of different language types into a language that can be recognized by the node itself. After determining that there is a language conversion layer inside the node to be tested that can convert languages, it is also necessary to further determine the target language used inside the node to be tested.

[0094] In one possible embodiment, for the simulation testing framework, since it is a relatively general testing framework applicable to different testing scenarios, different blockchains, and different test nodes, a mapping relationship between the TTCN3 language used by the simulation testing framework and the target language used by the node under test needs to be built within the simulation testing framework, because a fixed language is used internally. This ensures that messages between the simulation testing framework and the node under test can be mutually recognized, guaranteeing normal communication between the simulation testing framework and the node under test.

[0095] Furthermore, after starting the simulation test framework and setting the mapping relationship between the target language and the TTCN3 language, a communication connection between the simulation test framework and the node under test can be established. In this embodiment, the communication connection between the simulation test framework and the node under test is actually a communication connection between each simulation node in the simulation test framework and the node under test (a connection between simulation nodes that can communicate and interact and the node under test).

[0096] It is worth noting that, because the simulation test framework in this application embodiment is a relatively general test framework, applicable to different test scenarios, different blockchains, and different test nodes, the mapping relationship between the target language used by the node under test and the language used by the simulation test framework can be established in real time according to the target language used by different nodes under test. That is, after the node under test is determined, the language mapping relationship is established in real time for information interaction. Alternatively, the mapping relationship between different languages ​​and the language used inside the simulation test framework can be stored, and different language mapping relationships can be called for communication according to the target language used by different nodes under test.

[0097] Of the two methods mentioned above, the first method, which establishes language mapping relationships in real time, may result in lower testing efficiency due to the need to establish mapping relationships between languages. However, since it establishes relationships as needed, it does not consume excessive space in the simulation test framework. The second method, which stores language mapping relationships in advance, allows for direct invocation of these relationships when testing different nodes, significantly reducing the time required to establish them and improving testing efficiency. However, it requires a certain amount of space in the simulation test framework, which may lead to excessive use of the framework's space and thus affect the node testing process. The choice between these two methods can be made based on different testing requirements (efficiency or accuracy). This embodiment does not limit the specific method for determining language mapping relationships.

[0098] Furthermore, after determining that the node under test and the simulation test framework can mutually recognize the information sent to each other, test information for communication and interaction with the node under test can be constructed in the simulation test framework.

[0099] Specifically, the step "generating at least one piece of test information for communication with the node under test based on the algorithm type of the target consensus algorithm used by the blockchain to which the node under test belongs" includes:

[0100] c1: Based on the algorithm type of the target consensus algorithm used by the blockchain to which the node to be tested belongs, determine the algorithm flow of the target consensus algorithm, and extract at least one consensus signaling message from the algorithm flow;

[0101] c2: Based on the at least one consensus signaling message, perform message modeling to determine at least one modeling message.

[0102] c3: For each modeling message, based on the mapping relationship between the target language and the TTCN3 language, the modeling message is converted into test information that the node to be tested can recognize.

[0103] In the embodiments of this application, different consensus algorithms will have different algorithm flows and different consensus signaling messages. When constructing test information, the information composition method or information signaling of the target consensus algorithm used by the blockchain to which the node under test belongs must be followed. Therefore, when generating test information, it is necessary to generate it based on the consensus algorithm.

[0104] For example, taking the RAFT algorithm as the target consensus algorithm, the signaling messages involved in the RAFT algorithm are as follows:

[0105] A. Heartbeat messages: heart_beats are heartbeat messages sent by the leaders (master nodes) to all followers. A follower will trigger a request when it does not receive a heartbeat.

[0106] B. Election request message: vote_request;

[0107] C. Election response message: vote_response.

[0108] Therefore, when constructing test information in a simulation testing framework, it is also necessary to include heartbeat messages, election request messages, and election response messages.

[0109] In one possible implementation, after determining the basic signaling information, it is also necessary to construct test information under different test scenarios, and to model based on the signaling information to obtain modeling information.

[0110] For example, test scenarios may include error message scenarios. In this case, after determining the signaling information, it is necessary to construct correct modeling information based on the signaling information, and at the same time, it is also necessary to construct erroneous modeling information to ensure that when testing error message scenarios, the simulation test framework can send out erroneous information and use the erroneous information to test whether the feedback of the node under test meets expectations.

[0111] Furthermore, after the modeling information is constructed within the simulation testing framework, in order to ensure normal communication and interaction between the simulation testing framework and the node under test, and to ensure that the test information sent by the simulation testing framework can be recognized by the node under test, it is also necessary to convert the modeled information into test information that the node under test can recognize based on the determined mapping relationship between the target language and the TTCN3 language, so as to test whether the feedback of the node under test in different test scenarios meets expectations through the test information.

[0112] S102. According to the communication interaction order between the nodes of the blockchain to which the node to be tested belongs, as indicated by the target consensus algorithm, control each simulated node to send the at least one test message to the node to be tested in the order of communication interaction.

[0113] In this application example, since it is necessary to completely simulate the communication and interaction process of information in the actual scenario, when the simulation test framework sends test information to the node to be tested, it is also necessary to send the test information on the simulated node to the node to be tested according to the communication and interaction order between the nodes of the blockchain to which the node to be tested belongs, as indicated by the target consensus algorithm.

[0114] Specifically, the scenario design in the simulation test framework must also adhere to the information sending order specified by the consensus algorithm. In the consensus algorithm, different message sending orders across different nodes will affect the message processing flow. When different nodes use thread concurrency, the following process is implemented to ensure the message sending order: Components implement a message group function. Messages within the same message group have a strict sending order, and different message groups do not affect each other. The message control method within a message group is as follows: message numbers in the message group start from 0 and increment sequentially. When the message management module receives a new message, it checks whether its previous message has been sent. If not, the current message is cached until the previous message is sent before sending the current message. For example, if the message component receives message number 3, but the recorded sent messages are 0 and 1, then it must wait for message number 2 to be sent before sending message number 3. If message number 2 is not received for a long time, the cache times out and an alarm is reported, indicating an error in the test task design.

[0115] In the example above, in a certain blockchain, there are nodes A, B, and C that can communicate and exchange information. According to the consensus algorithm in this blockchain, nodes B and C can send information to node A simultaneously, with node C sending information before node B. When testing node A, i.e., when node A is the node to be tested, it is necessary to simulate node B' and node C'. At the same time, when sending test information to node A, the information sent by simulated node C' must be sent earlier than that sent by simulated node B'.

[0116] In one possible implementation, in addition to standardizing the order in which different simulated nodes send test information, it is also necessary to set the feedback time of communication nodes after receiving information from the node under test in the actual scenario. This will enable each simulated node in the simulation test framework to promptly perform information feedback interaction after receiving the reply information from the node under test, thus ensuring the accuracy of the test process.

[0117] Specifically, after the step of "constructing at least one piece of test information for communicating with the node under test", the testing method further includes:

[0118] d1: Based on the information processing efficiency of the node under test, determine the information response time of each simulated node after receiving the reply information.

[0119] d2: Control each simulated node to respond to the node under test according to the information response time after receiving the response information from the node under test, and perform information interaction.

[0120] In this embodiment, the information response time of different simulated nodes after receiving the reply information can be calculated based on the current amount of information being processed by the node under test and the processing efficiency of the information under test in the historical processing process. Then, the response time can be used to control different simulated nodes to reply to the node under test in a timely manner after receiving the reply information. Alternatively, the information response time after receiving the reply information can be determined directly based on the unified response time specified in the blockchain to which the node under test belongs.

[0121] It is worth noting that, in order to facilitate the management of different simulation nodes, the response time of different simulation nodes after receiving the reply information from the node under test is uniformly set. For example, the response time of different simulation nodes after receiving the reply information from the node under test is set to 500ms. After receiving the reply information from the node under test, the simulation node should send a message back to the node under test 500ms later. However, if the test process is terminated due to an abnormality in the basic communication process of the node under test, the simulation node does not need to reply to the node under test within the response time.

[0122] In one possible implementation, after setting the response time, the response time of the simulated node that receives the reply information from the node to be tested needs to be reserved. During this time period, the simulated node (virtual port) is in a suspended state and waits.

[0123] Specifically, the waiting time can be calculated as follows:

[0124] waitTime = T - (T t -T J );

[0125] Where waitTime is the waiting time, and T is the preset response time. t T represents the current time. J This is the time it takes for the simulated node to receive the response information from the node under test.

[0126] S103. Based on the information response content of multiple response messages from the node under test in response to at least one test message received, the response time of each response message, and the response order between different response messages, detect whether the information processing process of the node under test conforms to the expected information processing rules set by the target consensus algorithm.

[0127] In this embodiment of the application, after receiving the test information from different simulated nodes in the simulation test framework, the test node is tested in different dimensions, including the content of multiple reply messages received from at least one test message, the reply time of each reply message, and the reply order between different reply messages, to determine whether the process of the test node's information processing conforms to the expected information processing rules set by the target consensus algorithm. The test node is then tested based on the detection results showing that it conforms to the expected information processing rules.

[0128] Specifically, the simulation testing framework also includes multiple pre-built test scenario cases. The step "based on the information response content of multiple response messages from the node under test in response to at least one received test message, the response time of each response message, and the response order between different response messages, detecting whether the information processing flow of the node under test conforms to the expected information processing rules set by the target consensus algorithm" includes:

[0129] e1: Determine the target test scenario use case for the current setting, and determine the preset target information reply content and target message reply order under the target test scenario use case based on the target consensus algorithm.

[0130] In this embodiment, the requirements for whether the node under test needs to reply with information, the specific content of the reply information, and the processing method of the node under test for the test information vary depending on the test scenario. In this embodiment, the node under test needs to be tested under different test scenarios. Therefore, when determining the preset target information reply content of the node under test, it is also necessary to determine it based on different test scenarios.

[0131] Specifically, for different actual communication scenarios, the test scenarios that can be set in the simulation testing framework include, but are not limited to: network disconnection scenarios, malicious message scenarios, error message scenarios, message timeout scenarios, and message timing mismatch scenarios. Furthermore, the test information generated under different test scenarios will also differ, and the response information from the node under test is detected by defining the limitations of different test scenarios.

[0132] Specifically, the step "determining the preset target information response content and target message response order under the target test scenario use case based on the target consensus algorithm" includes:

[0133] f1: Determine the content type of the information response in the target test scenario, and the proportion of different content types.

[0134] f2: Based on the content type and the proportion of the same content type, combined with the information length specified by the target consensus algorithm and the important fields included in the information, determine the preset target information reply content, and determine the target message reply order based on the target consensus algorithm.

[0135] In this embodiment of the application, it is necessary to determine the target test scenario currently set in the simulation test framework, and to determine the different information categories and the proportion of different information categories in the current target test scenario. In combination with the content, length and important fields included in the information and the target message reply order specified in the consensus algorithm for different types of information, the preset target information reply content and target message reply order are determined.

[0136] For example, taking the current target test scenario as an error message, in this scenario, M correct test messages and N incorrect test messages need to be set. According to the consensus algorithm used by the blockchain of the node under test, specific content needs to be fed back for the error message. Therefore, in the preset target message reply content, the proportion of reply messages requiring specific content will be set to reach N / (M+N).

[0137] Furthermore, in addition to ensuring the proportion of different content types in the response content of the target information, it is also necessary to determine the field length of the target information and whether the important fields included in the information are correct, that is, whether the information responded by the node to be tested fully meets the requirements of the consensus algorithm.

[0138] e2: Detect whether the response time for each reply exceeds a preset time threshold.

[0139] In this embodiment, since the timer used by the node under test and the simulation test framework is the same, the response time of the reply information can be calculated from when the simulated node in the simulation test framework sends the test information to the node under test, until the simulated node in the simulation test framework receives the reply information. The calculation of the reply time tests whether the response time of the node under test meets expectations.

[0140] e3: If the reply time of each reply message does not exceed the preset time threshold, check whether the reply content of each reply message is consistent with the reply content of the target message, and whether the reply order of different reply messages is consistent with the reply order of the target message.

[0141] In this embodiment, testing the response time of the node under test is a test of the basic functions of the node under test. If the response time of each response message does not exceed the preset time threshold, subsequent tests can be conducted to check whether the response content of each response message is consistent with the response content of the target message, and whether the response order of different response messages is consistent with the response order of the target message. If the proportion of response messages in multiple response messages whose response times all exceed the preset time threshold exceeds the preset proportion threshold, it is determined that there is a problem with the basic functions of the node under test. At this time, the testing process of the node under test will be interrupted, and a warning message will be issued directly to debug the node under test.

[0142] Specifically, the following steps are used to determine that the response time for each reply message does not exceed a preset time threshold:

[0143] g1: For each reply message, determine the current time when the corresponding simulated node receives the reply message.

[0144] g2: For each reply message, determine the information time difference based on the current time and the time when the test message corresponding to that reply message was sent.

[0145] g3: For each reply message, if the time difference of the message is less than a preset difference threshold, it is determined that the reply time of the reply message has not exceeded the preset time threshold.

[0146] In this embodiment of the application, for each reply message from the node under test, it is necessary to determine the current time when the corresponding simulated node receives the reply message, and at the same time, determine the time when the corresponding simulated node sends the test message corresponding to the reply message, calculate a time difference, and this time difference value is the response time of the node under test. If this response time is within the preset time difference value, it is determined that the reply time of the reply message has not exceeded the preset time threshold.

[0147] The current time when the simulated node receives the reply message and the time when it sends the test message corresponding to the reply message are both determined by the clock source (timer) set in the simulation test framework.

[0148] For example, the time when the simulated node W receives the reply information sent by the node to be tested X is 08 minutes and 05 seconds, and the time when the simulated node W sends the corresponding test information is 08 minutes and 00 seconds, the time difference between the receiving time and the sending time is 5 seconds, the preset time difference is 10 seconds, which does not exceed the preset time difference value, so it is determined that the reply information does not exceed the preset time threshold.

[0149] e4: If multiple messages contain replies whose content is inconsistent with the target message's reply content, or if the reply order of different replies is inconsistent with the target message's reply order, it is determined that the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm.

[0150] In this embodiment of the application, it is necessary to detect whether the response of the node under test to different test information conforms to the target message response order specified by the target consensus algorithm of the blockchain to which the node under test belongs, based on the content of the response and the response order between different response information, so as to determine whether the node under test is abnormal.

[0151] Among them, the consensus algorithm specified in the blockchain not only requires the accuracy of the information response content, but also has strict rules on the order of response to different information. All nodes in the same blockchain need to strictly follow the order specified by the consensus algorithm used in the blockchain to interact and transfer information.

[0152] In the example above, in a certain blockchain, there are nodes A, B, and C that can communicate and exchange information. According to the consensus algorithm of this blockchain, nodes B and C can send information to node A simultaneously, with node C sending information before node B. Node A replies to node C first, then node B. When testing node A, when it receives test information from simulated nodes B' and C', the correct reply order should be to reply to simulated node C' first, then simulated node B'. That is, in the simulated testing framework, simulated node C' should receive the reply information from node A before simulated node B'. If this order is not followed, then node A has a problem.

[0153] In one possible implementation, checking the response content of the node under test A requires considering whether the response content corresponds to the test information (for example, if the test information tests error information in an error information scenario, then the response content of the node under test should be an error message for the error information), and whether the response content conforms to the information format specified by the target consensus algorithm used by the blockchain to which the node under test belongs. Only when the response content of the node under test meets the requirements of the target consensus algorithm in all detection dimensions can it be determined that the response content of the node under test is consistent with the target information response content.

[0154] S104. If the information processing flow of the node to be tested does not conform to the expected information processing rules set by the target consensus algorithm, generate node warning information.

[0155] In this embodiment of the application, if it is detected that the information processing process of the node under test does not conform to the expected information processing rules set by the target consensus algorithm, a test report for the problem of the node under test needs to be generated, and then corresponding node warning information is generated. The node warning information can accurately indicate the problem of the node under test, which helps the debugging personnel to make targeted adjustments to the node under test in the future.

[0156] Specifically, the step "if the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm, generate node warning information" includes:

[0157] h1: If the information processing flow of the node to be tested does not conform to the expected information processing rules set by the target consensus algorithm, for each reply message, determine the detection result corresponding to that reply message.

[0158] h2: Generate the node warning information by combining the detection results of each reply message.

[0159] In this embodiment of the application, after determining that the information processing process of the node to be tested does not conform to the expected information processing rules set by the target consensus algorithm, it is necessary to process and analyze each reply message from the node to be tested in order to determine the specific detection result of the node to be tested.

[0160] The detection results include errors in information content, timeouts in information responses, and incorrect order of information responses.

[0161] In one possible implementation, different solutions exist for different anomaly detection results. Specifically, for fundamental issues such as incorrect or timed-out responses that could affect subsequent node communication, the simulation testing framework will directly interrupt the testing process and generate corresponding warning information to indicate the anomaly of the node under test (such as incorrect or timed-out responses). If the anomaly of the node under test is not a fundamental issue such as incorrect or timed-out responses that could affect subsequent node communication, the subsequent testing process can continue, and the running information of the information under test can be recorded in the log. After the entire testing process is completed, the test results are automatically processed based on the log entries to determine whether the test of the node under test has passed. If it has failed, a warning should be issued for the anomaly information at the information level.

[0162] Please see Figure 4 , Figure 4 A flowchart illustrating another method for testing a blockchain node provided in an embodiment of this application. Figure 4 As shown in the embodiments of this application, the method for testing blockchain nodes includes:

[0163] S401. Establish communication connections between each simulated node in the simulation test framework and the node to be tested, and generate at least one piece of test information for communicating with the node to be tested based on the algorithm type of the target consensus algorithm used by the blockchain to which the node to be tested belongs.

[0164] S402. According to the communication interaction order between the nodes of the blockchain to which the node to be tested belongs, as indicated by the target consensus algorithm, control each simulated node to send the at least one test message to the node to be tested in the order of communication interaction.

[0165] S403. Based on the information response content of multiple response messages fed back by the node under test in response to at least one test message, the response time of each response message, and the response order between different response messages, detect whether the information processing process of the node under test conforms to the expected information processing rules set by the target consensus algorithm.

[0166] The descriptions of S401 to S403 can be referred to the descriptions of S101 to S103, and can achieve the same technical effect, so they will not be elaborated further.

[0167] S404. If the information processing flow of the node under test conforms to the expected information processing rules set by the target consensus algorithm, the node under test is determined to have passed the test, and the simulation test framework is used to test other nodes in the same blockchain as the node under test.

[0168] In this embodiment, if the information processing flow of the node under test conforms to the expected information processing rules set by the target consensus algorithm, then the node under test can be considered to have passed the test, and the node that has passed the test is recorded. Because the simulation test framework in this embodiment is a general test framework, after testing one node under test, other nodes in the same blockchain can be tested. At this time, since different nodes under test all belong to the same blockchain and use the same target consensus algorithm, the environment of the target consensus algorithm simulated by the simulation test framework as a whole does not need to be updated during testing, and node testing can be performed directly; if all nodes in the entire blockchain... After all nodes have been tested, when using a simulation testing framework to test different nodes in another blockchain, firstly, it is necessary to determine whether the consensus algorithm used by the next blockchain and the blockchain currently being tested is the same. If so, the environment of the target consensus algorithm simulated by the simulation testing framework does not need to be updated during testing, and node testing can be performed directly. If not, during testing, it is necessary to first redeploy the simulation testing framework according to the target consensus algorithm used by the next blockchain (the number of simulated nodes, the order in which the simulated nodes send information, the content, type, and format of the generated test information, etc.). After the deployment is completed, a new round of testing is conducted using the updated simulation testing framework.

[0169] It is worth noting that the simulation test framework in this application embodiment can not only perform node testing on a single node in a blockchain, but also test the entire communication system containing multiple nodes. The testing process is similar to that for a single node, and will not be described in detail here.

[0170] The testing process of the blockchain node in this application embodiment will be illustrated below with specific examples. In this example, the consensus algorithm is RAFT.

[0171] Step 1: Analyze the consensus process of the RAFT algorithm, extract the consensus signaling messages in the RAFT algorithm: heartbeat messages, election request messages, and election response messages, and model the extracted consensus signaling messages, including normal message content and erroneous message content, etc.

[0172] Step 2: Identify various abnormal scenarios for the RAFT consensus algorithm, such as network disconnection, malicious messages, error messages, message timeouts, and message timing discrepancies. Use the TTCN3 language to build a test framework (equivalent to the simulation test framework in this application embodiment) and deploy the RAFT algorithm in the test framework.

[0173] Step 3: Construct a test scenario using the RAFT consensus algorithm, setting up 4 consensus nodes to simulate a scenario where a follower triggers an election due to not receiving a heartbeat message, and the first election fails.

[0174] The message signaling sequence is set as follows:

[0175] A. Simulate node 1 sending a heartbeat message to the node under test;

[0176] B. The heartbeat message of simulated node 1 times out. After the timeout, it is necessary to check whether simulated node 1, simulated node 2, and simulated node 3 have all received vote_request, and to verify whether the vote field is correct.

[0177] C. If the verification is correct, construct an election failure scenario: simulate node 1, simulate node 2, simulate node 3, only one node responds with vote_response;

[0178] D. Check if the vote request is received again after the second timeout, and ensure that the term of the election is longer than the previous one.

[0179] E. Construct a successful election scenario: Simulate node 1, simulate node 2, simulate node 3, and both nodes respond with vote_response;

[0180] F. Check if the election was successful: Have you received a heartbeat message?

[0181] Step 4: Based on the information interaction of the nodes under test in the above test scenario, determine whether the nodes under test are abnormal and whether an alert is needed.

[0182] The blockchain node testing method provided in this application establishes communication connections between each simulated node and the node under test within a simulated testing framework. Based on the type of target consensus algorithm used by the blockchain to which the node under test belongs, it generates at least one test message for communication with the node under test. Following the communication order indicated by the target consensus algorithm, it controls each simulated node to send at least one test message to the node under test. Based on the content of multiple response messages from the node under test based on at least one test message, the response time of each response message, and the response order between different response messages, it detects whether the information processing flow of the node under test conforms to the expected information processing rules. If not, it generates a node warning message. In this application embodiment, the pre-constructed simulated testing framework containing multiple simulated nodes simulates the information interaction process between the node under test and the node under test. By detecting multiple information dimensions—content, time, and response order between different messages—at the interaction information level, it automatically and accurately tests the internal logic of the consensus algorithm and the node under test, helping to improve the testing efficiency and accuracy of blockchain testing.

[0183] Based on the same inventive concept, this application also provides a testing device for a blockchain node corresponding to the testing method for blockchain nodes. Since the principle of the device in this application is similar to the testing method for blockchain nodes described above, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.

[0184] Please see Figure 5 , Figure 6 , Figure 5 This is one of the structural schematic diagrams of a blockchain node testing device provided in an embodiment of this application. Figure 6 This is a second schematic diagram of the structure of a blockchain node testing device provided in an embodiment of this application. Figure 5 As shown, the testing apparatus 500 includes:

[0185] The communication establishment module 510 is used to establish communication connections between each simulated node in the simulation test framework and the node under test, and to generate at least one piece of test information for communicating with the node under test based on the algorithm type of the target consensus algorithm used by the blockchain to which the node under test belongs.

[0186] The information sending module 520 is used to control each simulated node to send the at least one test message to the node under test in the order of communication interaction between the nodes of the blockchain to which the node under test belongs, as indicated by the target consensus algorithm.

[0187] The response detection module 530 is used to detect whether the information processing process of the node under test conforms to the expected information processing rules set by the target consensus algorithm, based on the information response content of multiple response messages fed back by the node under test in response to at least one test message, the response time of each response message, and the response order between different response messages.

[0188] The node early warning module 540 is used to generate node early warning information if the information processing process of the node under test does not conform to the expected information processing rules set by the target consensus algorithm.

[0189] In one possible implementation, such as Figure 6 As shown, the test apparatus 500 further includes a simulation node construction module 550, which is used for:

[0190] Identify at least one communication node in the blockchain to which the node under test belongs that interacts with the node under test;

[0191] For each communication node, based on the target consensus algorithm and the information flow direction in the communication node, a simulated node corresponding to the communication node is constructed using the TTCN3 language.

[0192] In one possible implementation, such as Figure 6 As shown, the testing device 500 further includes a feedback time control module 560, which is used for:

[0193] Based on the information processing efficiency of the node under test, the information response time of each simulated node after receiving the reply information is determined;

[0194] Each simulated node is controlled to respond to the node under test according to the response time after receiving the response information from the node under test, and to conduct information interaction.

[0195] In one possible implementation, such as Figure 6 As shown, the testing device 500 further includes a node loop testing module 570, which is used for:

[0196] If the information processing flow of the node under test conforms to the expected information processing rules set by the target consensus algorithm, the node under test is determined to have passed the test, and the simulation test framework is used to test other nodes in the same blockchain as the node under test.

[0197] In one possible implementation, the internal information of the simulation test framework is constructed based on the TTCN3 language, and the communication establishment module 510 is used to establish a communication connection between the simulation test framework and the node under test through the following steps:

[0198] Detect whether the node under test contains a TTCN3 language conversion layer;

[0199] If the node under test has a TTCN3 language conversion layer, determine the target language used inside the node under test.

[0200] After the mapping relationship between the target language and the TTCN3 language is set in the simulation test framework, a communication connection is established between each simulation node in the simulation test framework and the node to be tested.

[0201] In one possible implementation, when the communication establishment module 510 generates at least one piece of test information for communicating with the node under test based on the algorithm type of the target consensus algorithm used by the blockchain to which the node under test belongs, the communication establishment module 510 is configured to:

[0202] Based on the algorithm type of the target consensus algorithm used by the blockchain to which the node to be tested belongs, determine the algorithm flow of the target consensus algorithm, and extract at least one consensus signaling message from the algorithm flow;

[0203] Based on the at least one consensus signaling message, perform message modeling to determine at least one modeling message;

[0204] For each modeling message, based on the mapping relationship between the target language and the TTCN3 language, the modeling message is converted into test information that the node to be tested can recognize.

[0205] In one possible implementation, the simulation testing framework further includes multiple pre-built test scenario cases. When the response detection module 530 detects whether the information processing flow of the node under test conforms to the expected information processing rules set by the target consensus algorithm, based on the information response content of multiple response messages from the node under test in response to at least one received test message, the response time of each response message, and the response order between different response messages, the response detection module 530 is used to:

[0206] Determine the target test scenario use cases for the current settings, and determine the preset target information response content and target message response order under the target test scenario use cases based on the target consensus algorithm;

[0207] Detect whether the response time for each reply exceeds a preset time threshold;

[0208] If the response time of each reply message does not exceed a preset time threshold, check whether the content of each reply message is consistent with the content of the target message reply, and whether the reply order between different reply messages is consistent with the reply order of the target message;

[0209] If multiple messages contain replies whose content is inconsistent with the target message's reply content, or if the reply order of different replies is inconsistent with the target message's reply order, it is determined that the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm.

[0210] In one possible implementation, the response detection module 530 is used to determine, through the following steps, that the response time of each response message does not exceed a preset time threshold:

[0211] For each reply message, determine the current time when the corresponding simulated node receives the reply message;

[0212] For each reply message, the information time difference is determined based on the current time and the time when the test message corresponding to that reply message was sent;

[0213] For each reply message, if the time difference between the messages is less than a preset difference threshold, it is determined that the reply time of that reply message has not exceeded the preset time threshold.

[0214] In one possible implementation, when the response detection module 530 is used to determine the preset target information response content and target message response order under the target test scenario use case based on the target consensus algorithm, the response detection module 530 is used to:

[0215] Determine the content types of information responses in the target test scenario, as well as the proportion of different content types;

[0216] Based on the content type and the proportion of the same content type, combined with the information length specified by the target consensus algorithm and the important fields included in the information, the preset target information reply content is determined, and the target message reply order is determined based on the target consensus algorithm.

[0217] In one possible implementation, when the node warning module 540 generates node warning information if the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm, the node warning module 540 is configured to:

[0218] If the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm, for each reply message, a detection result corresponding to that reply message is determined; wherein, the detection result includes information content error, information reply timeout, and information reply order error;

[0219] The detection results of each reply are combined to generate the node warning information.

[0220] The blockchain node testing device provided in this application establishes communication connections between each simulated node and the node under test within a simulated testing framework. Based on the type of target consensus algorithm used by the blockchain to which the node under test belongs, it generates at least one test message for communication with the node under test. Following the communication order indicated by the target consensus algorithm, it controls each simulated node to send at least one test message to the node under test. Based on the content of multiple response messages from the node under test based on at least one test message, the response time of each response message, and the response order between different response messages, it detects whether the information processing flow of the node under test conforms to the expected information processing rules. If not, it generates a node warning message. In this application embodiment, the pre-constructed simulated testing framework containing multiple simulated nodes simulates the information interaction process between the node under test and the node under test. By detecting multiple information dimensions—content, time, and response order between different messages—at the interaction information level, it automatically and accurately tests the internal logic of the consensus algorithm and the node under test, helping to improve the testing efficiency and accuracy of blockchain testing.

[0221] Please see Figure 7 , Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 7 As shown, the electronic device 700 includes a processor 710, a memory 720, and a bus 730.

[0222] The memory 720 stores machine-readable instructions executable by the processor 710. When the electronic device 700 is running, the processor 710 communicates with the memory 720 via the bus 730, causing the processor 710 to execute the following instructions during operation:

[0223] Establish communication connections between each simulated node in the simulation test framework and the node under test, and generate at least one piece of test information for communicating with the node under test based on the algorithm type of the target consensus algorithm used by the blockchain to which the node under test belongs;

[0224] According to the communication interaction order between the nodes of the blockchain to which the node under test belongs, as indicated by the target consensus algorithm, control each simulated node to send at least one test message to the node under test in the order of communication interaction.

[0225] Based on the information response content of multiple reply messages from the node under test in response to at least one test message, the reply time of each reply message, and the reply order between different reply messages, it is detected whether the information processing process of the node under test conforms to the expected information processing rules set by the target consensus algorithm.

[0226] If the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm, a node warning message is generated.

[0227] In one possible implementation, the internal information of the simulation test framework is built based on the TTCN3 language. The processor 710 executes instructions that establish a communication connection between the simulation test framework and the node under test through the following steps:

[0228] Detect whether the node under test contains a TTCN3 language conversion layer;

[0229] If the node under test has a TTCN3 language conversion layer, determine the target language used inside the node under test.

[0230] After the mapping relationship between the target language and the TTCN3 language is set in the simulation test framework, a communication connection is established between each simulation node in the simulation test framework and the node to be tested.

[0231] In one possible implementation, the instructions executed by the processor 710, which specify generating at least one piece of test information for communicating with the node under test based on the algorithm type of the target consensus algorithm used by the blockchain to which the node under test belongs, include:

[0232] Based on the algorithm type of the target consensus algorithm used by the blockchain to which the node to be tested belongs, determine the algorithm flow of the target consensus algorithm, and extract at least one consensus signaling message from the algorithm flow;

[0233] Based on the at least one consensus signaling message, perform message modeling to determine at least one modeling message;

[0234] For each modeling message, based on the mapping relationship between the target language and the TTCN3 language, the modeling message is converted into test information that the node to be tested can recognize.

[0235] In one possible implementation, the simulation testing framework further includes multiple pre-built test scenario cases. The instructions executed by the processor 710 include detecting whether the information processing flow of the node under test conforms to the expected information processing rules set by the target consensus algorithm, based on the information response content of multiple response messages from the node under test in response to at least one received test message, the response time of each response message, and the response order between different response messages.

[0236] Determine the target test scenario use cases for the current settings, and determine the preset target information response content and target message response order under the target test scenario use cases based on the target consensus algorithm;

[0237] Detect whether the response time for each reply exceeds a preset time threshold;

[0238] If the response time of each reply message does not exceed a preset time threshold, check whether the content of each reply message is consistent with the content of the target message reply, and whether the reply order between different reply messages is consistent with the reply order of the target message;

[0239] If multiple messages contain replies whose content is inconsistent with the target message's reply content, or if the reply order of different replies is inconsistent with the target message's reply order, it is determined that the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm.

[0240] In one possible implementation, the instructions executed by processor 710 determine, through the following steps, that the response time for each reply message does not exceed a preset time threshold:

[0241] For each reply message, determine the current time when the corresponding simulated node receives the reply message;

[0242] For each reply message, the information time difference is determined based on the current time and the time when the test message corresponding to that reply message was sent;

[0243] For each reply message, if the time difference between the messages is less than a preset difference threshold, it is determined that the reply time of that reply message has not exceeded the preset time threshold.

[0244] In one possible implementation, the instructions executed by the processor 710, which include determining the preset target information response content and target message response order under the target test scenario use case based on the target consensus algorithm, include:

[0245] Determine the content types of information responses in the target test scenario, as well as the proportion of different content types;

[0246] Based on the content type and the proportion of the same content type, combined with the target consensus algorithm, the preset target information reply content is determined, and the target message reply order is determined based on the target consensus algorithm.

[0247] In one possible implementation, the instructions executed by processor 710 construct at least one simulation node included in the simulation test framework through the following steps:

[0248] Identify at least one communication node in the blockchain to which the node under test belongs that interacts with the node under test;

[0249] For each communication node, based on the target consensus algorithm and the information flow direction in the communication node, a simulated node corresponding to the communication node is constructed using the TTCN3 language.

[0250] In one possible implementation, the instructions executed by the processor 710 further include:

[0251] Based on the information processing efficiency of the node under test, the information response time of each simulated node after receiving the reply information is determined;

[0252] Each simulated node is controlled to respond to the node under test according to the response time after receiving the response information from the node under test, and to conduct information interaction.

[0253] In one possible implementation, the instruction executed by processor 710, which includes generating node warning information if the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm, includes:

[0254] If the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm, for each reply message, a detection result corresponding to that reply message is determined; wherein, the detection result includes information content error, information reply timeout, and information reply order error;

[0255] The detection results of each reply are combined to generate the node warning information.

[0256] In one possible implementation, the instructions executed by the processor 710 further include:

[0257] If the information processing flow of the node under test conforms to the expected information processing rules set by the target consensus algorithm, the node under test is determined to have passed the test, and the simulation test framework is used to test other nodes in the same blockchain as the node under test.

[0258] The pre-built simulation test framework, which includes multiple simulated nodes, simulates the information interaction process between the node under test and the node under test. By detecting multiple information dimensions such as the content, time, and order of responses from different information at the interaction information level, the internal logic of the consensus algorithm and the node under test can be tested automatically and accurately, which helps to improve the testing efficiency and accuracy of blockchain testing.

[0259] The application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the following instructions:

[0260] Establish communication connections between each simulated node in the simulation test framework and the node under test, and generate at least one piece of test information for communicating with the node under test based on the algorithm type of the target consensus algorithm used by the blockchain to which the node under test belongs;

[0261] According to the communication interaction order between the nodes of the blockchain to which the node under test belongs, as indicated by the target consensus algorithm, control each simulated node to send at least one test message to the node under test in the order of communication interaction.

[0262] Based on the information response content of multiple reply messages from the node under test in response to at least one test message, the reply time of each reply message, and the reply order between different reply messages, it is detected whether the information processing process of the node under test conforms to the expected information processing rules set by the target consensus algorithm.

[0263] If the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm, a node warning message is generated.

[0264] In one possible implementation, the internal information of the simulation test framework is built based on the TTCN3 language, and the instructions executable on a computer-readable storage medium establish a communication connection between the simulation test framework and the node under test through the following steps:

[0265] Detect whether the node under test contains a TTCN3 language conversion layer;

[0266] If the node under test has a TTCN3 language conversion layer, determine the target language used inside the node under test.

[0267] After the mapping relationship between the target language and the TTCN3 language is set in the simulation test framework, a communication connection is established between each simulation node in the simulation test framework and the node to be tested.

[0268] In one possible implementation, the instructions executed by the computer-readable storage medium, which specify generating at least one piece of test information for communicating with the node under test based on the algorithm type of the target consensus algorithm used by the blockchain to which the node under test belongs, include:

[0269] Based on the algorithm type of the target consensus algorithm used by the blockchain to which the node to be tested belongs, determine the algorithm flow of the target consensus algorithm, and extract at least one consensus signaling message from the algorithm flow;

[0270] Based on the at least one consensus signaling message, perform message modeling to determine at least one modeling message;

[0271] For each modeling message, based on the mapping relationship between the target language and the TTCN3 language, the modeling message is converted into test information that the node to be tested can recognize.

[0272] In one possible implementation, the simulation testing framework further includes multiple pre-built test scenario cases. The instructions executed by the computer-readable storage medium include, based on the information response content of multiple response messages from the node under test in response to at least one received test message, the response time of each response message, and the response order between different response messages, detecting whether the information processing flow of the node under test conforms to the expected information processing rules set by the target consensus algorithm, including:

[0273] Determine the target test scenario use cases for the current settings, and determine the preset target information response content and target message response order under the target test scenario use cases based on the target consensus algorithm;

[0274] Detect whether the response time for each reply exceeds a preset time threshold;

[0275] If the response time of each reply message does not exceed a preset time threshold, check whether the response content of each reply message is consistent with the response content of the target message, and whether the response order of different reply messages is consistent with the response order of the target message;

[0276] If multiple messages contain replies whose content is inconsistent with the target message's reply content, or if the reply order of different replies is inconsistent with the target message's reply order, it is determined that the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm.

[0277] In one possible implementation, the instructions executed by the computer-readable storage medium determine, through the following steps, that the response time for each reply message does not exceed a preset time threshold:

[0278] For each reply message, determine the current time when the corresponding simulated node receives the reply message;

[0279] For each reply message, the information time difference is determined based on the current time and the time when the test message corresponding to that reply message was sent;

[0280] For each reply message, if the time difference between the messages is less than a preset difference threshold, it is determined that the reply time of that reply message has not exceeded the preset time threshold.

[0281] In one possible implementation, the instructions executed by the computer-readable storage medium, which define the preset target information response content and target message response order based on the target consensus algorithm under the target test scenario use case, include:

[0282] Determine the content types of information responses in the target test scenario, as well as the proportion of different content types;

[0283] Based on the content type and the proportion of the same content type, combined with the target consensus algorithm, the preset target information reply content is determined, and the target message reply order is determined based on the target consensus algorithm.

[0284] In one possible implementation, the instructions executed by the computer-readable storage medium construct at least one simulation node included in the simulation test framework through the following steps:

[0285] Identify at least one communication node in the blockchain to which the node under test belongs that interacts with the node under test;

[0286] For each communication node, based on the target consensus algorithm and the information flow direction in the communication node, a simulated node corresponding to the communication node is constructed using the TTCN3 language.

[0287] In one possible implementation, the instructions executed by the computer-readable storage medium further include:

[0288] Based on the information processing efficiency of the node under test, the information response time of each simulated node after receiving the reply information is determined;

[0289] Each simulated node is controlled to respond to the node under test according to the response time after receiving the response information from the node under test, and to conduct information interaction.

[0290] In one possible implementation, the instructions executed by the computer-readable storage medium, wherein generating node warning information if the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm, includes:

[0291] If the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm, for each reply message, a detection result corresponding to that reply message is determined; wherein, the detection result includes information content error, information reply timeout, and information reply order error;

[0292] The detection results of each reply are combined to generate the node warning information.

[0293] In one possible implementation, the instructions executed by the computer-readable storage medium further include:

[0294] If the information processing flow of the node under test conforms to the expected information processing rules set by the target consensus algorithm, the node under test is determined to have passed the test, and the simulation test framework is used to test other nodes in the same blockchain as the node under test.

[0295] The pre-built simulation test framework, which includes multiple simulated nodes, simulates the information interaction process between the node under test and the node under test. By detecting multiple information dimensions such as the content, time, and order of responses from different information at the interaction information level, the internal logic of the consensus algorithm and the node under test can be tested automatically and accurately, which helps to improve the testing efficiency and accuracy of blockchain testing.

[0296] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0297] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the shown or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.

[0298] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0299] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0300] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0301] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The scope of protection of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for testing blockchain nodes, characterized in that, The blockchain testing system includes a node to be tested and a pre-built simulation testing framework for testing the node to be tested. The simulation testing framework includes at least one simulated node corresponding to a communication node that communicates and interacts with the node to be tested in the same blockchain. The internal information of the simulation testing framework is built based on the TTCN3 language; the testing methods include: Establish communication connections between each simulated node in the simulation test framework and the node under test, and generate at least one piece of test information for communication with the node under test based on the algorithm type of the target consensus algorithm used by the blockchain to which the node under test belongs, test information under different test scenarios, and the mapping relationship between the target language of the node under test and the TTCN3 language. According to the communication interaction order between the nodes of the blockchain to which the node under test belongs, as indicated by the target consensus algorithm, control each simulated node to send at least one test message to the node under test in the order of communication interaction. Based on the information response content of multiple reply messages from the node under test in response to at least one test message, the reply time of each reply message, and the reply order between different reply messages, it is detected whether the information processing process of the node under test conforms to the expected information processing rules set by the target consensus algorithm. If the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm, a node warning message is generated.

2. The test method according to claim 1, characterized in that, The communication connection between the simulation test framework and the node to be tested is established through the following steps: Detect whether the node under test contains a TTCN3 language conversion layer; If the node under test has a TTCN3 language conversion layer, determine the target language used inside the node under test. After the mapping relationship between the target language and the TTCN3 language is set in the simulation test framework, a communication connection is established between each simulation node in the simulation test framework and the node to be tested.

3. The test method according to claim 2, characterized in that, The process of generating at least one piece of test information for communication with the node under test, based on the algorithm type of the target consensus algorithm used by the blockchain to which the node under test belongs, includes: Based on the algorithm type of the target consensus algorithm used by the blockchain to which the node to be tested belongs, determine the algorithm flow of the target consensus algorithm, and extract at least one consensus signaling message from the algorithm flow; Based on the at least one consensus signaling message, perform message modeling to determine at least one modeling message; For each modeling message, based on the mapping relationship between the target language and the TTCN3 language, the modeling message is converted into test information that the node to be tested can recognize.

4. The test method according to claim 1, characterized in that, The simulation testing framework also includes multiple pre-built test scenario cases. The step of detecting whether the information processing flow of the node under test conforms to the expected information processing rules set by the target consensus algorithm, based on the information response content of multiple response messages from the node under test in response to at least one received test message, the response time of each response message, and the response order between different response messages, includes: Determine the target test scenario use cases for the current settings, and determine the preset target information response content and target message response order under the target test scenario use cases based on the target consensus algorithm; Detect whether the response time for each reply exceeds a preset time threshold; If the response time of each reply message does not exceed a preset time threshold, check whether the response content of each reply message is consistent with the response content of the target message, and whether the response order of different reply messages is consistent with the response order of the target message; If multiple messages contain replies whose content is inconsistent with the target message's reply content, or if the reply order of different replies is inconsistent with the target message's reply order, it is determined that the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm.

5. The test method according to claim 4, characterized in that, The following steps are used to determine that the response time for each reply message does not exceed a preset time threshold: For each reply message, determine the current time when the corresponding simulated node receives the reply message; For each reply message, the information time difference is determined based on the current time and the time when the test message corresponding to that reply message was sent; For each reply message, if the time difference between the messages is less than a preset difference threshold, it is determined that the reply time of that reply message has not exceeded the preset time threshold.

6. The test method according to claim 4, characterized in that, The step of determining the preset target information response content and target message response order under the target test scenario test cases based on the target consensus algorithm includes: Determine the content types of information responses in the target test scenario, as well as the proportion of different content types; Based on the content type and the proportion of the same content type, combined with the information length specified by the target consensus algorithm and the important fields included in the information, the preset target information reply content is determined, and the target message reply order is determined based on the target consensus algorithm.

7. The test method according to claim 1, characterized in that, At least one simulation node included in the simulation testing framework is constructed through the following steps: Identify at least one communication node in the blockchain to which the node under test belongs that interacts with the node under test; For each communication node, based on the target consensus algorithm and the information flow direction in the communication node, a simulated node corresponding to the communication node is constructed using the TTCN3 language.

8. The test method according to claim 1, characterized in that, After constructing at least one piece of test information for communication with the node under test, the test method further includes: Based on the information processing efficiency of the node under test, the information response time of each simulated node after receiving the reply information is determined; Each simulated node is controlled to respond to the node under test according to the response time after receiving the response information from the node under test, and to conduct information interaction.

9. The test method according to claim 1, characterized in that, If the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm, a node warning message is generated, including: If the information processing flow of the node under test does not conform to the expected information processing rules set by the target consensus algorithm, for each reply message, a detection result corresponding to that reply message is determined; wherein, the detection result includes information content error, information reply timeout, and information reply order error; The detection results of each reply are combined to generate the node warning information.

10. The test method according to claim 1, characterized in that, The testing method also includes: If the information processing flow of the node under test conforms to the expected information processing rules set by the target consensus algorithm, the node under test is determined to have passed the test, and the simulation test framework is used to test other nodes in the same blockchain as the node under test.

11. A testing device for a blockchain node, characterized in that, The blockchain testing system includes a node to be tested and a pre-built simulation testing framework for testing the node to be tested. The simulation testing framework includes at least one simulated node corresponding to a communication node that communicates and interacts with the node to be tested in the same blockchain. The internal information of the simulation test framework is built based on the TTCN3 language; the test device includes: The communication establishment module is used to establish communication connections between each simulated node in the simulation test framework and the node under test, and to generate at least one piece of test information for communicating with the node under test based on the algorithm type of the target consensus algorithm used by the blockchain to which the node under test belongs, test information under different test scenarios, and the mapping relationship between the target language of the node under test and the TTCN3 language. The information sending module is used to control each simulated node to send at least one test message to the node under test in accordance with the communication interaction order between the nodes of the blockchain to which the node under test belongs, as indicated by the target consensus algorithm. The response detection module is used to detect whether the information processing process of the node under test conforms to the expected information processing rules set by the target consensus algorithm, based on the information response content of multiple response messages fed back by the node under test in response to at least one test message, the response time of each response message, and the response order between different response messages. The node early warning module is used to generate node early warning information if the information processing process of the node under test does not conform to the expected information processing rules set by the target consensus algorithm.

12. An electronic device, characterized in that, include: The device includes a processor, a storage medium, and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the testing method for a blockchain node as described in any one of claims 1 to 10.

13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the testing method for a blockchain node as described in any one of claims 1 to 10.

Citation Information

Patent Citations

  • Method and device for testing blockchain software

    CN110347609A

  • Raft consensus algorithm test system based on NS-3

    CN112527647A