Testing method, device and related equipment for executing structured query statements on blockchain
By obtaining test types and information, generating test statements based on the syntax tree and selecting the target test method, the problem of low efficiency in executing structured query statements in blockchain is solved, and rapid generation of diversified statements and comprehensive testing are achieved.
Patent Information
- Application Number
- CN202111574161.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-21
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2041-12-21
AI Technical Summary
The existing testing methods for executing structured query statements on blockchain are inefficient. Constructing statements is time-consuming and labor-intensive. The number of generated statements is small and the coverage is incomplete. Semi-automated testing is also inefficient.
By obtaining test types and information, generating test statements based on the syntax tree, selecting the target test method, and performing on-chain test processing, the diversity and coverage of test statements can be improved.
It realizes the rapid generation of diverse structured query statements, improves test efficiency, and ensures the comprehensiveness and accuracy of the test.
Smart Images

Figure CN114490707B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data testing, and in particular to a method, device, computer equipment, and storage medium for testing the execution of structured query statements on a blockchain. Background Art
[0002] The core concept of the on-chain Structured Query Language (SQL) is to enable a smooth transition of non-blockchain business systems to the blockchain. It has two core functions: 1) migrating historical database data to the blockchain's structured query execution engine. 2) supporting users to add, delete, modify, and query data using structured query statements.
[0003] To verify the correctness of the results of executing structured query statements, a common testing method is to construct statements with a known execution result in advance and compare the execution result with the known result to verify the correctness of the execution. However, this approach has the following disadvantages: constructing structured query statements is time-consuming and labor-intensive; the number of structured query statements generated is small and the coverage is incomplete; and semi-automated testing methods reduce testing efficiency. These shortcomings all lead to low efficiency in testing on-chain structured query statements.
[0004] Therefore, the existing testing method for executing structured query statements on blockchain has the problem of low testing efficiency. Summary of the Invention
[0005] Embodiments of the present invention provide a method, apparatus, computer device, and storage medium for testing the execution of structured query statements on a blockchain, so as to improve the efficiency of testing the execution of structured query statements on a blockchain.
[0006] A method for testing a blockchain executing a structured query statement, comprising:
[0007] Get test type and test information;
[0008] Generate a test statement based on the syntax tree and the test information, wherein the test statement is a structured query statement;
[0009] Obtaining a test method corresponding to the test type from a preset test method set as a target test method;
[0010] Based on the target test method, the test statement is subjected to on-chain test processing to obtain a test result.
[0011] A test device for executing structured query statements on a blockchain, comprising:
[0012] Data acquisition module, used to obtain test type and test information;
[0013] A test statement acquisition module, configured to generate a test statement based on the syntax tree and the test information, wherein the test statement is a structured query statement;
[0014] A target test mode acquisition module is used to acquire a test mode corresponding to the test type from a preset test mode set as a target test mode;
[0015] The test result acquisition module is used to perform on-chain test processing on the test statement based on the target test method to obtain the test result.
[0016] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above-mentioned method for testing the execution of structured query statements on a blockchain are implemented.
[0017] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the above-mentioned method for testing the execution of structured query statements on a blockchain.
[0018] The test method, device, computer equipment, and storage medium for executing structured query statements on a blockchain provided by an embodiment of the present invention obtain test types and test information; generate test statements based on a syntax tree and the test information, wherein the test statements are structured query statements; obtain a test method corresponding to the test type from a preset set of test methods as a target test method; and perform on-chain testing on the test statements based on the target test method to obtain test results. The test information obtained can be diversified, and the structured query statements constructed from the diversified test information are numerous and have a wide coverage. By obtaining diversified test information and constructing structured query statements based on a syntax tree, structured query statements can be quickly generated through the syntax tree, thereby improving the testing efficiency of executing structured query statements on a blockchain. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0020] Figure 1 This is a schematic diagram of an application environment for a method for testing execution of structured query statements in a blockchain according to an embodiment of the present invention;
[0021] Figure 2This is a flow chart of a method for testing a blockchain executing a structured query statement in one embodiment of the present invention;
[0022] Figure 3 1 is a schematic diagram of a test device for executing structured query statements on a blockchain according to an embodiment of the present invention;
[0023] Figure 4 FIG. 1 is a schematic diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0024] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0025] The test method for executing structured query statements in blockchain provided by this application can be applied in Figure 1 In an application environment, a computer device communicates with a server via a network. The computer device may include, but is not limited to, various personal computers, laptops, smartphones, tablet computers, and portable wearable devices. The server may be implemented as a standalone server or a server cluster consisting of multiple servers.
[0026] In one embodiment, if Figure 2 As shown, a test method for executing structured query statements on a blockchain is provided. Figure 1 Taking the server in as an example, the method includes the following steps S10 to S40:
[0027] S10. Obtain test type and test information.
[0028] In step S10, the aforementioned test type refers to a type of test performed on the execution of structured query statements on the blockchain. This test type includes, but is not limited to, correctness testing and fault tolerance testing. Correctness testing tests whether the execution results of structured query statements on the blockchain and in the database are consistent, while fault tolerance testing tests whether the blockchain is capable of identifying abnormal statements when executing structured query statements on the blockchain.
[0029] It should be understood that the above-mentioned database refers to a database that can execute structured query statements, for example, a MySQL database, and no specific limitation is imposed on the type of database.
[0030] The above test information refers to parameter information related to the structured query statement, and includes but is not limited to the number of tables to be generated, the number of fields, the number of indexes, and the number of insert statements.
[0031] It should be understood that the test information may include test information corresponding to one or more structured query statements. This information is stored in a table format, where the test information corresponding to the same structured query statement is stored in columns. Storing the test information in a table or column format is merely illustrative and does not impose any specific limitations on the storage method of the test information.
[0032] Before step S10, the blockchain test method for executing structured query statements further includes:
[0033] Set up a test environment.
[0034] It should be understood that the test environment here includes but is not limited to the blockchain underlying platform, database and database-related services, and JVM (Java Virtual Machine).
[0035] By setting up a test environment and obtaining the test type and test information, we can construct a test statement based on the test information and execute the test corresponding to the test type on the test statement, thus realizing automated testing and improving the test efficiency of executing structured query statements on the blockchain.
[0036] S20. Generate a test statement based on the syntax tree and the test information, where the test statement is a structured query statement.
[0037] In step S20, the syntax tree refers to a method of expressing the syntax structure of the structured query statement in a tree form.
[0038] It should be understood that a syntax tree refers to a method for automatically generating structured query statements. The implementation method of the syntax tree can be to analyze all characters of the structured query statement obtained in advance through a lexical analyzer, convert all words or characters into tokens that meet the specifications, classify the tokens, and perform syntax analysis on tokens of different categories, and obtain syntax nodes through the syntax analysis results to construct an abstract syntax tree. Among them, the above-mentioned syntax nodes include but are not limited to packages, types, modifiers, operators, interfaces, and return values. The above-mentioned method of implementing the syntax tree is only for illustration, and no specific limitation is placed on the method for generating the syntax tree.
[0039] The test statement is a structured query statement generated from a syntax tree based on the test information. It should be understood that the test statement includes but is not limited to one structured query statement, one type of structured query statement, multiple structured query statements, and multiple types of structured query statements.
[0040] In step S20, specifically:
[0041] Generate initialization statements based on test information;
[0042] Based on the syntax tree, the initialization statement is processed to generate a statement to obtain a deletion statement, a modification statement, and a query statement corresponding to the initialization statement, wherein the deletion statement, the modification statement, and the query statement are all structured query statements.
[0043] The initialization statement refers to a structured query statement randomly generated by the syntax tree and matching the test information. The initialization statement includes but is not limited to a table creation statement and an insert statement.
[0044] The above-mentioned delete statement refers to a structured query statement of the delete type corresponding to the initialization statement.
[0045] The above modification statement refers to a structured query statement of the modification type corresponding to the initialization statement.
[0046] The above query statement refers to a structured query statement of the query type corresponding to the initialization statement.
[0047] It should be understood that the above initialization statement and the test information have a one-to-many relationship, and the above deletion statement, modification statement and query statement have a many-to-one relationship with the initialization statement respectively.
[0048] The above steps are explained below with a specific embodiment. For example, when the test information is to randomly generate data based on the Columns information of each table and generate an insert statement: "tbl:=state.choiceTables().one()vals=tbls.GenRandValues(tbl.Columns)", one of the initialization statements is obtained as "select(*|column name)from table name where condition Opt(OrderByLimit)".
[0049] Statement generation is performed on the initialization statement to obtain one of the delete statements "delete from table name where condition", one of the modify statements "update table name set (column 1 = value 1, column 2 = value 2, ...) where condition" or one of the insert statements "insert into table name values (value 1, value 2)", and one of the query statements "select (*|column name) from table name where condition".
[0050] Test statements are generated through syntax trees and test information. The syntax tree supports the random and rapid generation of various structured query statements, which not only ensures the number of structured query statements and the speed of generating structured query statements, but also ensures the comprehensiveness of structured query statement coverage, thereby improving the test efficiency of subsequent blockchain execution of structured query statements.
[0051] S30: Obtain a test method corresponding to the test type from a preset test method set as a target test method.
[0052] In step S30, the preset test method set refers to a method set for testing structured query statements, including but not limited to a correctness test method and a fault tolerance test method.
[0053] The target test method mentioned above refers to a method of testing a test statement.
[0054] In step S30, specifically:
[0055] When the test type is a correctness test, the correctness test mode is obtained as the target test mode;
[0056] When the test type is a fault tolerance test, the fault tolerance test mode is obtained as the target test mode.
[0057] The correctness test method is to test whether the execution results of the structured query statement in the blockchain and the database are consistent, and whether the execution results in the blockchain after the query statement is synonymously converted are consistent.
[0058] The fault tolerance test method refers to a test method that tests whether the blockchain has the ability to identify abnormal statements when abnormalities occur during the execution of structured query statements on the blockchain.
[0059] By obtaining the test method corresponding to the test type from the preset test method set and using it as the target test method, it is beneficial to perform corresponding tests on test statements with different requirements, thereby improving the coverage of the test scope and improving the test efficiency of subsequent blockchain execution of structured query statements.
[0060] S40. Based on the target test method, the test statement is tested on the chain to obtain the test result.
[0061] In step S40, on-chain test processing refers to the process of testing the test statement on the blockchain.
[0062] The above test results include test pass and test fail.
[0063] In step S40, when the target test mode is the correctness test mode, it specifically includes the following steps S401 to S407:
[0064] S401: Input the initialization statement into the blockchain for execution and processing to obtain the blockchain processing result.
[0065] S402: Input the initialization statement into the database for execution processing to obtain the database processing result.
[0066] S403: Compare the blockchain processing result with the database processing result to obtain a first comparison result.
[0067] S404: Perform synonym conversion on the query statement to obtain a converted statement.
[0068] S405: Input the query statement and the conversion statement into the blockchain for execution and processing, and obtain the query result corresponding to the query statement and the conversion result corresponding to the conversion statement.
[0069] S406: Compare the query result with the conversion result to obtain a second comparison result.
[0070] S407. When the first comparison result shows that the blockchain processing result and the database processing result are consistent, and the second comparison result shows that the query result and the conversion result are consistent, the test result is passed; otherwise, the test result is failed.
[0071] For the above step S401, the above blockchain processing result refers to the result obtained after the blockchain runs the initialization statement.
[0072] Regarding the above step S402, the above database processing result refers to the result obtained after the database executes the initialization statement.
[0073] Regarding step S403, the first comparison result includes that the blockchain processing result and the database processing result are consistent, and the blockchain processing result and the database processing result are inconsistent.
[0074] Regarding the above step S404, the above synonymous conversion process refers to a process of changing the format of the query statement but not changing the query content.
[0075] For example, when the query statement is "select SUM(t0.c0)AS s,COUNT(t0.c0)FROM t0", the query statement is converted into "select SUM(t0.c0)AS s,COUNT(t0.c0)FROM t0where t0.c0=t0.c1 UNION ALL select SUM(t0.c0)AS s,COUNT(t0.c0)FROM t0 whereNOT(t0.c0=t0.c1)UNION ALL select SUM(t0.c0)AS s,COUNT(t0.c0)FROM t0 where(t0.c0=t0.c1)IS NULL".
[0076] Preferably, TLP (Ternary Query Partitioning) is used here to perform synonymous conversion on query statements. The implementation process of the TLP method is as follows: a query statement is randomly generated, referred to as Q, the query result corresponding to the query statement is referred to as RS(Q), and the query statement Q is divided into three conversion statements, referred to as Q'(p), Q'(notp), and Q'(p is null). The query results corresponding to the conversion statements Q'(p), Q'(not p), and Q'(p is null) are referred to as RS(Q'(p)), RS(Q'(not p)), and RS(Q'(pis null)). Depending on the type of Q, a specific expression is used to combine the three result sets of Q' and refer to RS(Q'). It is determined whether RS(Q) == RS(Q'). If RS(Q) and RS(Q') are not equal, there is an exception here. If RS(Q) and RS(Q') are equal, the conversion is successful.
[0077] Regarding step S405, the query result refers to the result obtained by executing the query statement on the blockchain. The conversion result refers to the result obtained by executing the conversion result on the blockchain.
[0078] Regarding step S406 , the second comparison result includes that the query result and the conversion result are consistent, and that the query result and the conversion result are inconsistent.
[0079] Through the above steps, the correctness test of structured query statements executed on the blockchain can be quickly performed, thereby improving the efficiency of correctness testing of structured query statements executed on the chain.
[0080] In step S40, when the target test mode is a fault tolerance test mode, it specifically includes the following steps S411 to S415:
[0081] S411. Obtain variation information from the test information.
[0082] S412: Based on the mutation information, perform mutation processing on the test statement to obtain a mutated test statement corresponding to the test statement.
[0083] S413: Input the mutation test statement into the blockchain for execution and processing to obtain the test mutation result corresponding to the mutation test statement.
[0084] S414: Compare the test mutation result with the expected error result to obtain a third comparison result.
[0085] S415. If the third comparison result shows that the test variation result is consistent with the expected error result, the test result is passed; otherwise, the test result is failed.
[0086] Regarding step S411, the variation information includes but is not limited to variation of data type, variation of statement structure, and variation of number of fields. It should be understood that the variation information may include one or more variation types.
[0087] Regarding step S412 , the mutated test statement refers to a structured query statement obtained by performing the same mutation processing as the mutation information on the test statement.
[0088] For step S414, the expected error result refers to the error type stored locally, which can be a type error, a statement structure error, or a field error.
[0089] Through the above steps, you can quickly execute structured query statements on the blockchain to perform fault tolerance testing, thereby improving the efficiency of the blockchain fault tolerance testing.
[0090] After step S40, the blockchain testing method for executing structured query statements further includes:
[0091] When the test result is that the test fails, the test statement and the test result are collected and processed into logs and added to the collected logs.
[0092] The log collection process is to collect the processes and test results involved in the test statements that failed the test, so as to facilitate the subsequent optimization process.
[0093] By performing on-chain testing on test statements, the correctness test and fault tolerance test of structured query statements executed on the blockchain are quickly implemented. At the same time, logs of test statements and test results that fail the test are collected, which makes it easier to analyze the reasons for blockchain execution failure and improves the testing efficiency of structured query statements executed on the blockchain.
[0094] The test method for executing structured query statements on a blockchain provided by an embodiment of the present invention obtains a test type and test information; generates a test statement based on a syntax tree and the test information, wherein the test statement is a structured query statement; obtains a test method corresponding to the test type from a preset test method set as a target test method; and performs on-chain testing on the test statement based on the target test method to obtain a test result. The obtained test information can be diversified, and the structured query statements constructed from the diversified test information are numerous and have a wide coverage. By obtaining diversified test information and constructing structured query statements based on the syntax tree, the structured query statements can be quickly generated through the syntax tree, thereby improving the testing efficiency of executing structured query statements on the blockchain.
[0095] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0096] In one embodiment, a test device for executing a structured query statement on a blockchain is provided. The test device for executing a structured query statement on a blockchain corresponds to the test method for executing a structured query statement on a blockchain in the above embodiment. Figure 3 As shown, the blockchain test device for executing structured query statements includes a data acquisition module 11, a test statement acquisition module 12, a target test method acquisition module 13, and a test result acquisition module 14. The functional modules are described in detail as follows:
[0097] The data acquisition module 11 is used to acquire the test type and test information.
[0098] The test statement acquisition module 12 is used to generate a test statement based on the syntax tree and the test information, wherein the test statement is a structured query statement.
[0099] The target test mode acquisition module 13 is configured to acquire a test mode corresponding to a test type from a preset test mode set as a target test mode.
[0100] The test result acquisition module 14 is used to perform on-chain test processing on the test statement based on the target test method to obtain the test result.
[0101] In one embodiment, the test statement acquisition module includes:
[0102] The initialization statement acquisition unit is used to generate an initialization statement based on the test information.
[0103] The statement generation unit is used to perform statement generation processing on the initialization statement based on the syntax tree to obtain the deletion statement, modification statement and query statement corresponding to the initialization statement, wherein the deletion statement, modification statement and query statement are all structured query statements.
[0104] In one embodiment, the target test mode acquisition module 13 further includes:
[0105] The correctness test unit is used to obtain the correctness test mode as the target test mode when the test type is correctness test.
[0106] The fault tolerance test unit is used to obtain the fault tolerance test mode as the target test mode when the test type is fault tolerance test.
[0107] In one embodiment, in the correctness test unit, the test result acquisition module 14 further includes:
[0108] The blockchain processing result acquisition unit is used to input the initialization statement into the blockchain for operation processing to obtain the blockchain processing result.
[0109] The database processing unit is used to input the initialization statement into the database for operation processing and obtain the database processing result.
[0110] The first comparison unit is used to compare the blockchain processing result with the database processing result to obtain a first comparison result.
[0111] The synonym conversion unit is used to perform synonym conversion on the query statement to obtain a converted statement.
[0112] The conversion result acquisition unit is used to input the query statement and the conversion statement into the blockchain for execution processing, and obtain the query result corresponding to the query statement and the conversion result corresponding to the conversion statement.
[0113] The second comparison unit is used to compare the query result with the conversion result to obtain a second comparison result.
[0114] The test result obtaining unit is configured to determine that the test passes when the first comparison result shows that the blockchain processing result and the database processing result are consistent, and the second comparison result shows that the query result and the conversion result are consistent; otherwise, the test fails.
[0115] In one embodiment, in the fault tolerance test unit, the test result acquisition module 14 further includes:
[0116] The variation information acquisition unit is used to acquire variation information from the test information.
[0117] The mutation processing unit is used to perform mutation processing on the test statement based on the mutation information to obtain a mutated test statement corresponding to the test statement.
[0118] The mutation running unit is used to input the mutation test statement into the blockchain for running processing and obtain the test mutation result corresponding to the mutation test statement.
[0119] The third comparison unit is used to compare the test variation result with the expected error result to obtain a third comparison result.
[0120] The testing unit is configured to determine that if the third comparison result shows that the test variation result is consistent with the expected error result, the test result is a pass; otherwise, the test result is a fail.
[0121] In one embodiment, after the test result acquisition module 14, the blockchain testing device for executing structured query statements further includes:
[0122] The log collection unit is used to collect and process the test statements and test results into the collected log when the test result is that the test fails.
[0123] The meaning of "first" and "second" in the above modules / units is only to distinguish different modules / units, and is not used to limit which module / unit has a higher priority or other limiting meanings. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or modules is not necessarily limited to those steps or modules clearly listed, but may include other steps or modules that are not clearly listed or inherent to these processes, methods, products or devices. The division of modules in this application is only a logical division, and other division methods may be used in actual applications.
[0124] The specific limitations of the blockchain testing device for executing structured query statements can be found in the limitations of the blockchain testing method for executing structured query statements above and will not be further elaborated here. Each module in the aforementioned blockchain testing device for executing structured query statements can be implemented in whole or in part through software, hardware, or a combination thereof. Each of these modules can be embedded in or independent of a processor in a computer device in hardware form, or stored in a computer device memory in software form, so that the processor can call and execute the corresponding operations of each module.
[0125] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 4As shown. The computer device includes a processor, memory, a network interface, and a database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store data involved in a test method for executing structured query statements on a blockchain. The network interface of the computer device is used to communicate with an external terminal via a network connection. When executed by the processor, the computer program implements a test method for executing structured query statements on a blockchain.
[0126] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method for testing the execution of structured query statements by a blockchain in the above embodiment are implemented, for example: Figure 2 Steps S10 to S40 shown in the figure and other extensions of the method and related steps. Alternatively, when the processor executes the computer program, the functions of the modules / units of the test device for executing structured query statements in the blockchain in the above embodiment are realized, for example Figure 3 The functions of modules 11 to 14 are shown in FIG. 3 and will not be described in detail here to avoid repetition.
[0127] The processor may be a central processing unit (CPU), other general-purpose processors, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the computer device, connecting various parts of the entire computer device using various interfaces and lines.
[0128] The memory may be used to store the computer programs and / or modules. The processor implements various functions of the computer device by running or executing the computer programs and / or modules stored in the memory and calling data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store an operating system, at least one application required for a function (such as a sound playback function, an image playback function, etc.); and the data storage area may store data created based on the use of the mobile phone (such as audio data, video data, etc.).
[0129] The memory may be integrated into the processor or may be provided separately from the processor.
[0130] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for testing the execution of structured query statements by a blockchain in the above embodiment are implemented, for example: Figure 2 Steps S10 to S40 shown in the figure and other extensions of the method and related steps are extended. Alternatively, when the computer program is executed by the processor, the functions of the modules / units of the test device for executing structured query statements in the blockchain in the above embodiment are realized, for example Figure 3 The functions of modules 11 to 14 are shown in FIG. 3 and will not be described in detail here to avoid repetition.
[0131] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0132] Those skilled in the art will clearly understand that for the sake of convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0133] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should all be included in the scope of protection of the present invention.
Claims
1. A test method for executing structured query statements on a blockchain, characterized in that: include: Acquire a test type and test information, wherein the test type includes a correctness test and / or a fault tolerance test; generating an initialization statement based on the test information; Based on the syntax tree, the initialization statement is subjected to statement generation processing to obtain a test statement corresponding to the initialization statement, wherein the test statement is a structured query statement, and the test statement includes a delete statement, a modify statement, and a query statement; Obtaining, from a preset test mode set, a test mode corresponding to the test type as a target test mode, wherein, when the test type is the correctness test, obtaining the correctness test mode as the target test mode; when the test type is the fault tolerance test, obtaining the fault tolerance test mode as the target test mode; Based on the target test mode, the test statement is tested on the chain to obtain a test result; When the target test mode is a correctness test mode, the step of performing on-chain test processing on the test statement to obtain a test result includes: Input the initialization statement into the blockchain for execution processing to obtain a blockchain processing result; Inputting the initialization statement into the database for operation processing to obtain the database processing result; Comparing the blockchain processing result with the database processing result to obtain a first comparison result; Performing synonym conversion processing on the query statement to obtain a converted statement; Inputting the query statement and the conversion statement into the blockchain for execution and processing respectively, to obtain a query result corresponding to the query statement and a conversion result corresponding to the conversion statement; Comparing the query result with the conversion result to obtain a second comparison result; When the first comparison result is that the blockchain processing result and the database processing result are consistent, and the second comparison result is that the query result and the conversion result are consistent, then the test result is a test pass; otherwise, the test result is a test fail.
2. The method according to claim 1, characterized in that When the target test mode is a fault tolerance test mode, the step of performing on-chain test processing on the test statement to obtain a test result includes: Obtaining variation information from the test information; Based on the mutation information, the test statement is mutated to obtain a mutated test statement corresponding to the test statement; Inputting the mutation test statement into the blockchain for execution processing to obtain a test mutation result corresponding to the mutation test statement; Comparing the test variation result with the expected error result to obtain a third comparison result; If the third comparison result shows that the test variation result is consistent with the expected error result, the test result is a pass; otherwise, the test result is a fail.
3. The method according to any one of claims 1 to 2, characterized in that After performing on-chain testing on the test statement based on the target test mode and obtaining a test result, the method further includes: When the test result is that the test fails, the test statement and the test result are subjected to log collection processing and added to the collection log.
4. A test device for executing structured query statements on a blockchain, characterized in that: include: A data acquisition module, configured to acquire a test type and test information, wherein the test type includes a correctness test and / or a fault tolerance test; A test statement acquisition module is configured to generate an initialization statement based on the test information; perform statement generation processing on the initialization statement based on a syntax tree to obtain a test statement corresponding to the initialization statement, wherein the test statement is a structured query statement and includes a delete statement, a modify statement, and a query statement; a target test mode acquisition module, configured to acquire a test mode corresponding to the test type from a preset test mode set as a target test mode, wherein when the test type is a correctness test, the correctness test mode is acquired as the target test mode; when the test type is a fault tolerance test, the fault tolerance test mode is acquired as the target test mode; A test result acquisition module is used to perform on-chain test processing on the test statement based on the target test mode to obtain a test result; When the target test mode is a correctness test mode, the step of performing on-chain test processing on the test statement to obtain a test result includes: Input the initialization statement into the blockchain for execution processing to obtain a blockchain processing result; Inputting the initialization statement into the database for operation processing to obtain the database processing result; Comparing the blockchain processing result with the database processing result to obtain a first comparison result; Performing synonym conversion processing on the query statement to obtain a converted statement; Inputting the query statement and the conversion statement into the blockchain for execution and processing respectively, to obtain a query result corresponding to the query statement and a conversion result corresponding to the conversion statement; Comparing the query result with the conversion result to obtain a second comparison result; When the first comparison result is that the blockchain processing result and the database processing result are consistent, and the second comparison result is that the query result and the conversion result are consistent, then the test result is a test pass; otherwise, the test result is a test fail.
5. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the processor implements the steps of the method for testing the execution of structured query statements by a blockchain as described in any one of claims 1 to 3.
6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method for testing the execution of structured query statements by a blockchain as claimed in any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Database backup method and device and database recovery method and device based on block chain
CN110413691A
Data script verification method and device and computer equipment
CN112527661A