The present application claims priority to Chinese Patent Application No. 201910299220.1, titled “METHOD FOR CONSTRUCTING TEST SCENARIO AND INFORMATION PROCESSING DEVICE”, filed on Apr. 15, 2019 with the Chinese Patent Office, which is incorporated herein by reference in its entirety.
The present disclosure generally relates to the field of application testing, and in particular to a method for constructing a test scenario for an application which is executed in a decentralized manner and an information processing device capable of implementing the method.
In recent days, applications such as blockchains that are executed asynchronously in a decentralized manner gain more and more attention. Previously, execution of traditional applications relies on a central authority, while applications executed asynchronously in the decentralized manner do not require a central authority to perform corresponding functions. Therefore, a network framework that does not require trust is provided, and network users can execute applications without trust.
Since applications executed asynchronously in the decentralized manner may be executed on multiple different nodes, consistency of execution is very important. Accordingly, it is required to confirm that an application is correct internally before executing the application, so as to avoid risk vulnerability.
Therefore, it is desirable to provide a method capable of constructing an appropriate test scenario for an application which is executed asynchronously in a decentralized manner, so as to avoid risk vulnerability in the application through testing.
A brief summary of the present disclosure is given in the following, so as to provide basic understanding on some aspects of the present disclosure. It should be understood that, the summary is not an exhaustive summary of the present disclosure. The summary is neither intended to determine key or important parts of the present disclosure, nor intended to limit the scope of the present disclosure. An object of the summary is to provide some concepts in a simplified form, as preamble of a detailed description later.
In view of need for a method for constructing a test scenario for an application which is executed asynchronously in a decentralized manner, one of objects of the present disclosure is to provide a method for constructing a test scenario and an information processing device capable of implementing the method, which can be used for constructing an appropriate test scenario for a target application which is executed through a plurality of executable applications in distributed nodes in an asynchronous manner.
A method for a computer to construct a test scenario for a target application is provided according to an aspect of the present disclosure, wherein the target application is executed through a plurality of executable applications in distributed nodes in an asynchronous manner. The method includes: constructing an invocation relationship graph representing a plurality of functions included in the plurality of executable applications; determining, according to a code structure of each function of the plurality of functions in the invocation relationship graph, one or more of a plurality of risk types which may cause an operation error for the function; traversing the invocation relationship graph to obtain possible function paths among the functions and determining, based on a plurality of risk types of functions in each function path of the possible function paths, risk types of the function path; and determining, according to the risk types of the function path, a type of a test scenario for the function path.
An information processing device is provided according to another aspect of the present disclosure. The information processing device includes a processor. The processor is configured to: construct an invocation relationship graph representing a plurality of functions included in a plurality of executable applications for a target application, wherein the target application is executed through the plurality of executable applications in distributed nodes in an asynchronous manner; determine, according to a code structure of each function of the plurality of functions in the invocation relationship graph, one or more of a plurality of risk types which may cause an operation error for the function; traverse the invocation relationship graph to obtain possible function paths among the functions and determine, based on a plurality of risk types of functions in each function path of the possible function paths, risk types of the function path; and determine, according to the risk types of the function path, a type of a test scenario for the function path.
A program that causes a computer to implement the above method for constructing a test scenario is further provided according to another aspect of the present disclosure.
A corresponding storage medium is further provided according to another aspect of the present disclosure. The storage medium stores a machine-readable instruction code that, when being read and executed by a machine, causes the machine to perform the above method for constructing a test scenario.
According to the aspects of embodiments of the present disclosure, at least the following benefits can be obtained. With the method for constructing a test scenario, the information processing device, the program, and the storage medium according to the present disclosure, an appropriate test scenario can be constructed for an application which is executed asynchronously in a decentralized manner, so as to effectively detect possible risks in the application.
These and other advantages of the present disclosure are more apparent through the following detailed description of preferred embodiments of the present disclosure with reference to the accompanying drawings.
The present disclosure can be better understood by referring to the detailed description given below in conjunction with the drawings. In the drawings, same or similar reference numerals are used to represent same or similar components. The drawings, together with the following detailed description, are incorporated in and form a part of this specification to further illustrate preferred embodiments of the present disclosure and explain principles and advantages of the present disclosure. In the drawings:
Exemplary embodiments of the present disclosure are described below with reference to the drawings. For clarity and conciseness, not all characteristics of an actual embodiment are described in the specification. However, it should be understood that many embodiment-specific decisions, for example, conforming to restrictions related to system and business, must be made when developing any actual embodiment, so as to achieve a specific goal of a developer. These restrictions may vary depending on embodiments. In addition, it should be understood that, although development work may be complex and time-consuming, the development work is merely a routine task for those skilled in the art who benefit from the present disclosure.
Here, it should be further noted that, in order to avoid obscuring the present disclosure due to unnecessary details, the drawings show only apparatus structures and/or processing steps that are closely related to technical solutions of the present disclosure, and other details have little relevance to the present disclosure are omitted.
A method for constructing a test scenario is provided according to an aspect of the present disclosure.
The method 100 for constructing a test scenario according to this embodiment is capable of constructing a test scenario for a target application which is executed through a plurality of executable applications in distributed nodes in an asynchronous manner. As shown in
Exemplary processing in each step of the method 100 is briefly described below with reference to
Next, in step S103, according to the code structure of each function in the invocation relationship graph 201, one or more of a plurality of risk types R1 to R7 which may cause an operation error are determined for the function, thereby obtaining an invocation relationship graph 203 labeled with risk types. In this example, as shown in the invocation relationship graph 203, functions f1 and f2 involve no risk that may cause the operation error. Functions f3 to f7 are each associated with one or more of the plurality of risk types R1 to R7. The plurality of risk types R1 to R7 as examples may be predefined herein. For example, a risk type of each function may be determined depending on a code language of the function, an invocation relationship with other functions and the like. A correspondence between these risk types and functions is described later with examples.
After each function is labeled with its risk type as described above, in step S105, all possible function paths in the invocation relationship graph 203 are traversed in manners such as depth-first traversal or breadth-first traversal. Breadth-first traversal is taken as an example, and the following function paths may be obtained from the invocation relationship graph 203: {f1; f1→f2; f1→f3; f1→f2→f4; f1→f2→f5; f1→f2→f5→f7; f1→f2→f5→f6}. Then, for the above function paths, based on risk types of functions in each function path, risk types of the function path are determined. That is, a set of risk types of functions in the function path is determined, so as to obtain risk types of each function path as shown in a chart 205. It should be noted that among all function paths traversed from the invocation relationship graph 203, function paths {f1; f1→f2} do not include any risk function. Therefore, these function paths are not included in the chart 205.
Next, in step S107, according to the risk types of each function path shown in the chart 205, types A to D of test scenarios for respective function paths are determined. That is, a correspondence between the function paths and types of test scenarios as shown in a table 207 is obtained. The types A to D of test scenarios as examples may be predefined and are appropriately set based on various factors such as a code structure and a manner of executing a to-be-tested application, so as to detect various risk types of each function path in the application.
In a preferred embodiment, the types of test scenarios may include: a test scenario simulating execution of the application (one or more of the executable applications of the application) on one node for one time (type A), a test scenario simulating execution of concurrent operations by multiple users on the application (one or more of the executable applications of the application) on one node (type B), a test scenario simulating simultaneous execution of the application (one or more of the executable applications of the application) on multiple nodes for one time (type C) and a test scenario simulating execution of concurrent operations by multiple users on the application (one or more of the executable applications of the application) on multiple nodes (type D).
Setting of the above four risk types in this preferred embodiment is particularly beneficial for constructing a test scenario for a target application which is executed through a plurality of executable applications in distributed nodes in an asynchronous manner.
In a traditional application executed through a central authority, accuracy of code is checked by performing unit testing on a single user operation for the central authority (central node). However, in a target application which is executed through a plurality of executable applications in distributed nodes in an asynchronous manner, there may be an intermediate step between the execution of the application (one or more of the executable applications) on each node and confirmation or writing of a final result. Therefore, all risks that may exist in the application cannot be ensured to be tested by only performing the unit testing on a single user operation for a single node.
Accordingly, in this preferred embodiment, four types A to D of test scenario are constructed. Different numbers of nodes (a single node; and multiple nodes) and different numbers of concurrent user operations (operation by only one user, which may also be referred to as execution of the application (one or more of the executable applications) for one time; and concurrent operations by multiple users) are set, so that test scenarios capable of detecting corresponding risks can be appropriately set for different risk types of each function path.
With the above method for constructing a test scenario according to this embodiment, a type of a test scenario for each function path included in an application can be determined according to risk types of functions in the function path, thereby determining an appropriate test scenario for the entire application (that is, all possible function paths in the invocation relationship graph for functions included in the target application), so that effective testing can be performed for all risks that the application may involve.
In an example, the application targeted by the method for constructing a test scenario according to this embodiment described above with reference to
For ease of description, details of preferred embodiments of the present disclosure are described below in combination with examples of the smart contracts. Based on the present disclosure, those skilled in the art can understand that the embodiments of the present disclosure may be appropriately applied to various applications that are executed asynchronously through a plurality of distributed nodes in addition to the smart contract in the blockchain, which is not described in detail herein.
Here, first, the Hyperledger Fabric in the blockchain as an example of the application executed through a plurality of distributed nodes in an asynchronous manner in this embodiment is briefly described with reference to
As shown in
Next, after receiving a verification reply from the endorsing node, the device of user confirms that the verification is successful. After the verification is successfully completed, the device of user may transmit the signed transaction information to the ordering node. The ordering node orders the transaction information based on a certain consensus, packs the ordered transaction information into a block, and transmits the block to the committing node. For the received transaction information, the committing node determines whether an execution result of the application is correct depending on a specific endorsing policy, and signs confirmed transaction information. Regardless of whether the execution result of the application is correct, the ordered and packed transaction information block is written by the committing node into the blockchain, so that a ledger status on multiple nodes can be synchronized. After acquiring confirmation from the committing node that the packed block is written into the ledger, the operation by the user is finally completed.
As described above, in the Hyperledger Fabric as an example of an application which is executed asynchronously in a decentralized manner, there are several intermediate steps between the step of executing the smart contract by the endorsing node and the step of finally writing the execution result of the smart contract to the Hyperledger by the committing node. That is, these two steps are performed asynchronously. Therefore, when constructing a test scenario, the four types described above with reference to
In the following, in combination with the Hyperledger Fabric shown in
R1 represents a risk of calling a function in another smart contract.
In an example, when the invocation relationship graph for functions included in the application is constructed, for example, in step S101 as shown in
APlstub.invokeChaincode( ) in the GO language), which causes a possibility that the function in one smart contract may modify a status of a database (for example, the Hyperledger) of another smart contract. Therefore, a function including this kind of invocation may result in insecurity. The risk of a function calling a function in another smart contract is defined as a risk type Rl.
Accordingly, when the risk type is determined for the function in the invocation relationship graph 201 according to the code structure of the function, for example, in step S103 as shown in
It is found that, for the risk type R1, an error can be detected by executing a smart contract for one time (a single transaction) on a single endorsing node. Therefore, in a preferred embodiment, a type of a test scenario determined with respect to the risk type R1 of a function calling a function in another smart contract may include a test scenario simulating execution of the smart contract on one endorsing node for one time, that is, a type A shown in
R2 represents a risk of a function reading a variable written by the function itself.
Accordingly, when the risk type is determined for the function in the invocation relationship graph 201 according to the code structure of the function, for example, in step S103 as shown in
It is found that, for the risk type R2, similar to the risk type R1, an error can be detected by executing an application (one or more of the executable applications) or a smart contract for one time (a single transaction) on a single endorsing node. Therefore, in a preferred embodiment, a type of a test scenario determined with respect to the risk type R2 of a function reading a variable written by the function itself may include a test scenario simulating execution of the smart contract on one endorsing node for one time, that is, the type A shown in
R3 represents a risk of a function including an operation of updating, in a batch processing manner, values of a plurality of variables that are obtained through a query.
It is found that in an application such as the Hyperledger in a blockchain, if a function includes an operation of updating values of a plurality of variables that are obtained through an operation of query range after the operation of range query (such as using a code
APlstub.GetQueryResult( ) in the GO language), a updated result may be inconsistent with a latest value of the corresponding variable. Due to characteristics of asynchronous execution of the smart contract, values of queried variables may be changed by other transactions by other users, during a process of updating the values of the queried variables. Therefore, a function including this kind of operation may result in insecurity. The risk of a function including an operation of updating, in a batch processing manner, values of a plurality of variables that are obtained through a query is defined as a risk type R3.
Accordingly, when the risk type is determined for the function in the invocation relationship graph 201 according to the code structure of the function, for example, in step S103 as shown in
For the risk type R3 that the function includes the above operation, performance of the function in a case of concurrent transactions is required to be considered. Accordingly, in a preferred embodiment, a type of a test scenario determined with respect to the risk type R3 may include a test scenario simulating execution of concurrent operations by multiple users on the application (one or more of the executable applications) on one node, that is, a type B shown in
R4 represents a risk of a function including an operation that generates an uncertain result.
In an example, the operation that generates an uncertain result may include operations such as random number generation, a temporary value of a node, and key-value pair structure traversal (such as Hashmap, Hashtable). If functions in the application (one or more of the executable applications) or the smart contract include any one of the above operations that generate an uncertain result, execution of these functions on multiple different endorsing nodes may result in different results, resulting in inconsistence of execution results among multiple nodes. Therefore, a function including this kind of operation may result in insecurity. The risk of a function including an operation that generates an uncertain result is defined as a risk type R4.
Accordingly, when the risk type is determined for the function in the invocation relationship graph 201 according to the code structure of the function, for example, in step S103 as shown in
For a function involving the risk type R4, performance of the function executed on multiple nodes is required to be considered. Therefore, in a preferred embodiment, a type of a test scenario determined with respect to the risk type R4 may include a test scenario simulating simultaneous execution of the application (one or more of the executable applications) on multiple nodes for one time, that is, a type C shown in
R5 represents a risk of a function including an operation that calls external resources
In an example, the operation that calls external resources may include, for example,
Web service calling (http://xxx), external library calling, system command line calling. If a function in the application (one or more of the executable applications) or the smart contract includes any one of the above operations that calls external resources, execution of the function on multiple different nodes may result in different results. Therefore, a function including this kind of operation may result in insecurity. The risk of a function including an operation that calls external resources is defined as a risk type R5.
Accordingly, when the risk type is determined for the function in the invocation relationship graph 201 according to the code structure of the function, for example, in step S103 as shown in
For a function involving the risk type R5, performance of the function executed on multiple nodes is required to be considered. Therefore, in a preferred embodiment, a type of a test scenario determined with respect to the risk type R5 may include a test scenario simulating simultaneous execution of the application (one or more of the executable applications) on multiple nodes for one time, that is, a type C shown in
In addition, optionally, in an application example of a smart contract involving a blockchain, such as the Hyperledger shown in
In an example, the first endorsing policy and the second endorsing policy may be any two of the following endorsing policies: an endorsing policy of “AND”, an endorsing policy of “OR”, and an endorsing policy of “M of N”. The endorsing policy of “AND” indicates that it is required to only confirm that the execution results on a plurality of endorsing nodes are consistent and these endorsing nodes all perform signature endorsing, so that the committing node finally confirms the transaction and signs the transaction. The endorsing policy of “OR” indicates that it is required to confirm that any one of the plurality of endorsing nodes performs the signature endorsing, so that the committing node confirms the transaction and signs the transaction. The endorsing policy of “M of N” (where M and N are natural numbers and M is less than N) indicates that it is required to confirm that the execution results of any M endorsing nodes among the N endorsing nodes are consistent and the M endorsing nodes all perform the signature endorsing, so that the committing node finally confirms the transaction and signs the transaction. It is expected that no matter what endorsing policy, the same results can be obtained by executing the smart contract through the plurality of endorsing nodes.
R6 and R7 represent a risk of a function including a write operation on a distributed database.
In an example, the case of a function including a write operation on a distributed database may be a case of the function including an operation of writing after reading.
In addition, the case of a function including a write operation on a distributed database may be a case of the function including a write operation only.
Accordingly, when the risk type is determined for the function in the invocation relationship graph 201 according to the code structure of the function, for example, in step S103 as shown in
It is found that for functions involving the above two risk types R6 and R7, it is best to test consistency of execution results of the functions on a plurality of endorsing nodes in a case of multiple concurrent transactions. Therefore, in a preferred embodiment, with the risk types R6 and R7 that the function includes a write operation on the distributed database, a test scenario of simulating the execution of concurrent operations by multiple users on the application (one or more of the executable applications) on multiple nodes is determined, that is, a type D as shown in Figure3 is determined, so that a risk of read-write conflict or write conflict that possibly exists in the above functions can be detected.
Optionally, in an application example of a smart contract involving a blockchain, such as the Hyperledger shown in
In an example, among a plurality of endorsing nodes used to execute smart contracts, some endorsing nodes may involve no network latency, some endorsing nodes may involve a network latency of 5 milliseconds, and other endorsing nodes may involve a network latency of 10 milliseconds. In this way, performance of endorsing nodes under different network latencies can be tested, and it is expected to obtain consistent results regardless of the network latency.
Various example risk types R1 to R7, which may be applied to an application such as the Hyperledger that is executed through a plurality of distributed nodes in an asynchronous manner, are described above. Preferred embodiments of types A to D of the test scenario corresponding to these risk types are also described. In combination with these examples and preferred embodiments, reference is made back to the example shown in
For example, as shown in a first line of the chart 205 in
Exemplary flows of a method for constructing a test scenario according to the present disclosure are described above with reference to
An information processing apparatus is provided according to another aspect of the present disclosure.
An information processing apparatus 800 may construct a test scenario for a target application which is executed through a plurality of executable applications in distributed nodes in an asynchronous manner. As shown in
The above information processing apparatus and its units can perform, for example, the method for constructing a test scenario described above with reference to
The information processing apparatus according to the embodiment of the present disclosure is described above with reference to
An information processing device is provided according to another aspect of the present disclosure. The information processing device may implement the method for constructing a test scenario according to the embodiment of the present disclosure. The information processing device may include a processor. The processor is configured to: construct an invocation relationship graph for functions included in a plurality of executable applications for a target application, where the target application is executed through the plurality of executable applications on distributed nodes in an asynchronous manner; determine, according to a code structure of each function in the invocation relationship graph, one or more of a plurality of risk types which may cause an operation error, for the function; traverse the invocation relationship graph to obtain all possible function paths and determine, based on risk types of functions in each function path, risk types of the function path; and determine, according to risk types of each function path, a type of a test scenario for the function path.
The processor of the information processing device may be configured, for example, to perform the method for constructing a test scenario described above with reference to
For example, the type of the test scenario may include: a test scenario simulating execution of the application on one node for one time, a test scenario simulating execution of concurrent operations by multiple users on the application on one node, a test scenario simulating simultaneous execution of the application on multiple nodes for one time, and a test scenario simulating execution of concurrent operations by multiple users on the application on multiple nodes.
In an example, the executable applications may be smart contracts in a blockchain. The plurality of distributed nodes may be a plurality of endorsing nodes in the blockchain.
In a preferred embodiment, the plurality of risk types may include a risk of a function including an operation that generates an uncertain result or calls external resources, and the type of the test scenario determined with respect to the risk may include a test scenario simulating simultaneous execution of the application on multiple nodes for one time.
Optionally, in the test scenario of simulating simultaneous execution of the application on multiple nodes for one time, firstly, the plurality of endorsing nodes simultaneously execute the smart contract with a first endorsing policy for one time, and then, the plurality of endorsing nodes simultaneously execute the smart contract with a second endorsing policy for one time.
In a preferred embodiment, the constructing the invocation relationship graph may include constructing an invocation relationship graph for functions included in smart contracts of the whole blockchain. The plurality of risk types include a risk of a function reading a variable written by itself or calling a function of another smart contract. The type of the test scenario determined with respect to the risk may include a test scenario simulating execution of the smart contract on one endorsing node for one time.
In a preferred embodiment, the plurality of risk types may include a risk of a function including a write operation on a distributed database. The type of the test scenario determined with respect to the risk may include a test scenario simulating execution of concurrent operations by multiple users on the application on multiple nodes.
Optionally, in the test scenario of simulating execution of concurrent operations by multiple users on the application on multiple nodes, the multiple nodes involve different network latencies.
In a preferred embodiment, the plurality of risk types may include a risk of a function including an operation of updating, in a batch processing manner, values of a plurality of variables that are obtained through a query, and the type of the test scenario determined with respect to the risk may include a test scenario simulating execution of concurrent operations by multiple users on the application on one node.
In
The following components are connected to the input/output interface 905: an input portion 906 (including a keyboard, a mouse or the like), an output portion 907 (including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), a loudspeaker or the like), a storage portion 908 (including a hard disk or the like), and a communication portion 909 (including a network interface card such as a LAN card, a modem or the like). The communication portion 909 performs communication processing via a network such as the Internet. A driver 910 may also be connected to the input/output interface 905 as needed. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory may be installed on the driver 910 as needed, so that a computer program read from the removable medium 911 is installed into the storage portion 908 as needed.
In addition, a program product that stores a machine-readable instruction code is further provided according to the present disclosure. The instruction code, when being read and executed by a machine, performs the method for constructing a test scenario according to the embodiment of the present disclosure. Accordingly, various storage media such as a magnetic disk, an optical disk, a magneto-optical disk, and a semiconductor memory for carrying the program product are also included in the present disclosure.
That is, a storage medium that stores a machine-readable instruction code is further provided according to the present disclosure. The instruction code, when being read and executed by a machine, causes the machine to execute the above method for constructing a test scenario according to the embodiment of the present disclosure. The instruction code includes an instruction code portion for performing the following operations: constructing an invocation relationship graph for functions included in the application; determining, according to a code structure of each function in the invocation relationship graph, one or more of a plurality of risk types which may cause an operation error, for the function; traversing the invocation relationship graph to obtain all possible function paths and determining, based on risk types of functions in each function path, risk types of the function path; and determining, according to risk types of each function path, a type of a test scenario for the function path.
The above storage medium may include, but is not limited to, a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory and the like.
In the above description of specific embodiments of the present disclosure, the features described and/or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, combined with features in other embodiments or replace features in other embodiments.
In addition, the methods according to the embodiments of the present disclosure are not limited to being performed in the chronological order described in the specification or shown in the drawings, but may also be performed in other chronological order, in parallel, or independently. Therefore, the performing order of the methods described in this specification does not limit the technical scope of the present disclosure.
In addition, it is apparent that each operation process of the above method according to the present disclosure may be implemented in the form of a computer-executable program stored in various machine-readable storage media.
Moreover, the object of the present disclosure may be achieved by directly or indirectly providing a storage medium storing the executable program code described above to a system or device. A computer or a central processing unit (CPU) in the system or device reads and executes the above program code.
In this case, as long as the system or device has a function of executing a program, the embodiments of the present disclosure are not limited to the program. The program may also be in any form, for example, a target program, a program executed by an interpreter, or a script program provided to an operating system.
These above machine-readable storage media include but are not limited to, various memories and storage units, semiconductor devices, magnetic disk units such as optical disks, magnetic disks, and magneto-optical disks, and other media for storing information.
In addition, a client information processing terminal may implement the embodiments of the present disclosure by connecting to a corresponding web site on the Internet and downloading and installing the computer program code according to the present disclosure into the information processing terminal and then executing the program.
In summary, the following solutions are provided according to the embodiments of the present disclosure, but are not limited thereto: According to an example, a method for constructing a test scenario for a target application which is executed through a plurality of executable applications in distributed nodes in an asynchronous manner, including: constructing an invocation relationship graph for functions included in the plurality of executable applications; determining, according to a code structure of each function in the invocation relationship graph, one or more of a plurality of risk types which may cause an operation error, for the function; traversing the invocation relationship graph to obtain all possible function paths and determining, based on risk types of functions in each function path, risk types of the function path; and determining, according to risk types of each function path, a type of a test scenario for the function path.
The type of the test scenario includes: a test scenario simulating execution of the application on one node for one time, a test scenario simulating execution of concurrent operations by multiple users on the application on one node, a test scenario simulating simultaneous execution of the application on multiple nodes for one time, and a test scenario simulating execution of concurrent operations by multiple users on the application on multiple nodes.
The executable applications are smart contracts in a blockchain, and the plurality of distributed nodes are a plurality of endorsing nodes in the blockchain.
The plurality of risk types include a risk of a function including an operation that generates an uncertain result or calls external resources, and the type of the test scenario determined with respect to the risk includes simulating simultaneous execution of the application on multiple nodes for one time.
In the test scenario of simulating simultaneous execution of the application on multiple nodes for one time, firstly, the plurality of endorsing nodes simultaneously execute the smart contract with a first endorsing policy for one time, and then, the plurality of endorsing nodes simultaneously execute the smart contract with a second endorsing policy for one time.
The constructing the invocation relationship graph includes constructing an invocation relationship graph for functions included in smart contracts of the whole blockchain, the plurality of risk types include a risk of a function reading a variable written by itself or calling a function of another smart contract, and the type of the test scenario determined with respect to the risk includes a test scenario simulating execution of the smart contract on one endorsing node for one time.
The plurality of risk types include a risk of a function including a write operation on a distributed database, and the type of the test scenario determined with respect to the risk includes a test scenario simulating execution of concurrent operations by multiple users on the application on multiple nodes.
In the test scenario of simulating execution of concurrent operations by multiple users on the application on multiple nodes, the multiple nodes involve different network latencies.
The plurality of risk types include a risk of a function including an operation of updating, in a batch processing manner, values of a plurality of variables that are obtained through a query, and the type of the test scenario determined with respect to the risk includes a test scenario simulating execution of concurrent operations by multiple users on the application on one node.
According to an example, an information processing device is provided including: a processor configured to: construct an invocation relationship graph for functions included in a plurality of executable applications for a target application, where the target application is executed through the plurality of executable applications on distributed nodes in an asynchronous manner; determine, according to a code structure of each function in the invocation relationship graph, one or more of a plurality of risk types which may cause an operation error, for the function; traverse the invocation relationship graph to obtain all possible function paths and determine, based on risk types of functions in each function path, risk types of the function path; and determine, according to risk types of each function path, a type of a test scenario for the function path.
The type of the test scenario includes: a test scenario simulating execution of the application on one node for one time, a test scenario simulating execution of concurrent operations by multiple users on the application on one node, a test scenario simulating simultaneous execution of the application on multiple nodes for one time, and a test scenario simulating execution of concurrent operations by multiple users on the application on multiple nodes.
The executable applications are smart contracts in a blockchain, and the plurality of distributed nodes are a plurality of endorsing nodes in the blockchain.
The plurality of risk types include a risk of a function including an operation that generates an uncertain result or calls external resources, and the type of the test scenario determined with respect to the risk includes a test scenario simulating simultaneous execution of the application on multiple nodes for one time.
In the test scenario of simulating simultaneous execution of the application on multiple nodes for one time, firstly, the plurality of endorsing nodes simultaneously execute the smart contract with a first endorsing policy for one time, and then, the plurality of endorsing nodes simultaneously execute the smart contract with a second endorsing policy for one time.
The constructing the invocation relationship graph includes constructing an invocation relationship graph for functions included in smart contracts of the whole blockchain, the plurality of risk types include a risk of a function reading a variable written by itself or calling a function of another smart contract, and the type of the test scenario determined with respect to the risk includes a test scenario simulating execution of the smart contract on one endorsing node for one time.
The plurality of risk types include a risk of a function including a write operation on a distributed database, and the type of the test scenario determined with respect to the risk includes a test scenario simulating execution of concurrent operations by multiple users on the application on multiple nodes.
In the test scenario of simulating execution of concurrent operations by multiple users on the application on multiple nodes, the multiple nodes involve different network latencies.
The plurality of risk types include a risk of a function including an operation of updating, in a batch processing manner, values of a plurality of variables that are obtained through a query, and the type of the test scenario determined with respect to the risk includes a test scenario simulating execution of concurrent operations by multiple users on the application on one node.
According to an example, a storage medium storing a machine-readable instruction code that, when being read and executed by a machine, causes the machine to execute a method for constructing a test scenario for a target application which is executed through a plurality of executable applications in distributed nodes in an asynchronous manner, the method including: constructing an invocation relationship graph for a plurality of functions included in the plurality of executable applications; determining, according to a code structure of each function in the invocation relationship graph, one or more of a plurality of risk types which may cause an operation error, for the function; traversing the invocation relationship graph to obtain all possible function paths and determine, based on risk types of functions in each function path, risk types of the function path; and determining, according to risk types of each function path, a type of a test scenario for the function path.
Finally, it should be further noted that the relationship terminologies such as first, second or the like are only used herein to distinguish one entity or operation from another, rather than to necessitate or imply that the actual relationship or order exists between the entities or operations. Furthermore, terms of “include”, “comprise” or any other variants are intended to be non-exclusive. Therefore, a process, method, article or device including a series of elements includes not only the elements but also other elements that are not enumerated, or also includes the elements inherent for the process, method, article or device. Unless expressively limited otherwise, the statement “comprising (including) one . . . ” does not exclude the case that other similar elements may exist in the process, method, article or device.
Although the present disclosure is disclosed above through specific embodiments of the present disclosure, it should be understood that those skilled in the art can make various modifications, improvements or equivalents to the present disclosure within the spirit and scope of the appended claims. These modifications, improvements or equivalents should also be considered to be included in the protection scope of the present disclosure.
Number | Date | Country | Kind |
---|---|---|---|
201910299220.1 | Apr 2019 | CN | national |