Method, device, equipment and storage medium for storing data based on blockchain
By storing encrypted simulation test data and data cleaning rules on the blockchain, the problem of test data isolation is solved, data sharing and circulation is realized, and the accuracy and coverage of system testing are improved.
Patent Information
- Application Number
- CN202110740279.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-30
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2041-06-30
AI Technical Summary
In the existing technology, the test data is isolated, resulting in inaccurate system test results, and the effective sharing and circulation of test data cannot be achieved.
Use the Mock testing tool to simulate tests on the preset system, generate simulated test data and data cleaning rules, encrypt them using a hash algorithm and store them in the blockchain to achieve data sharing and circulation, and then decrypt and use them in the system to be tested.
It enriches the types of test data, avoids malicious tampering and leakage of data, improves the accuracy and coverage of test results, and ensures the completeness of test functions.
Smart Images

Figure CN113472883B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of blockchain technology, and in particular, relates to a method, device, equipment and storage medium for storing data based on blockchain. Background Art
[0002] At present, when testing a system, the test environment is incomplete and needs to be simulated with the help of test tools. In order to ensure the security of test data, the existing technology only simulates test data through test tools, and does not share and circulate test data, resulting in isolation of test data used for system testing, which in turn leads to inaccurate system test results. Summary of the invention
[0003] In view of this, the embodiments of the present application provide a method, apparatus, device and storage medium for storing data based on blockchain to solve the problem in the prior art that test data is only simulated by test tools without sharing and circulating the test data, resulting in isolation of the test data used for system testing, and further leading to inaccurate system test results.
[0004] A first aspect of an embodiment of the present application provides a method for storing data based on blockchain, the method comprising:
[0005] Perform simulation tests on each preset system respectively through the Mock test tool to generate simulation test data for each preset system;
[0006] Obtaining data cleaning rules corresponding to each of the preset systems;
[0007] The simulation test data and data cleaning rules corresponding to each of the preset systems are encrypted respectively, and the encrypted simulation test data and data cleaning rules are stored in the blockchain.
[0008] Optionally, the encrypting the simulation test data and data cleaning rules corresponding to each of the preset systems respectively, and storing the encrypted simulation test data and data cleaning rules in the blockchain, includes:
[0009] For each preset system, a hash algorithm is used to encrypt the simulation test data and data cleaning rules corresponding to the preset system to obtain encrypted simulation test data and encrypted data cleaning rules;
[0010] The encrypted simulation test data and the encrypted data cleaning rules are stored in the blockchain node corresponding to the preset system.
[0011] Optionally, after encrypting the simulation test data and data cleaning rules corresponding to each of the preset systems respectively and storing the encrypted simulation test data and data cleaning rules in the blockchain, the method further includes:
[0012] Receiving request information initiated by the system to be tested, wherein the request information includes a request identifier;
[0013] According to the request identifier, searching for target data in the blockchain, wherein the target data includes encrypted simulation test data corresponding to the target system, encrypted data cleaning rules, and a decryption method;
[0014] Feeding back the target data to the system to be tested, wherein the target data is used to instruct the system to be tested to decrypt the encrypted simulation test data and the encrypted data cleaning rules according to the decryption method to obtain the decrypted simulation test data and data cleaning rules;
[0015] Clean the decrypted simulation test data according to the decrypted data cleaning rules to obtain the target test data;
[0016] The system to be tested is tested according to the target test data.
[0017] Optionally, the decrypted simulation test data includes a return parameter, and the decrypted simulation test data is cleansed according to a decrypted data cleaning rule to obtain target test data, including:
[0018] According to the data cleaning rule, filtering parameters that conform to a preset data type from the return parameters;
[0019] The target test data is generated based on the parameters that conform to the preset data type.
[0020] Optionally, after receiving the request information initiated by the system to be tested, the method further includes:
[0021] Verifying the identity of the system to be tested;
[0022] When the identity of the system to be tested fails to pass the verification, a reminder message is generated and fed back to the system to be tested.
[0023] Optionally, after encrypting the simulation test data and data cleaning rules corresponding to each of the preset systems respectively and storing the encrypted simulation test data and data cleaning rules in the blockchain, the method further includes:
[0024] Obtain the model file corresponding to the AI model of each of the preset systems;
[0025] Each of the model files is encrypted respectively, and the encrypted model files are stored in the blockchain.
[0026] Optionally, the AI model includes an image recognition model. After encrypting each of the model files and storing the encrypted model files in the blockchain, the method further includes:
[0027] Obtaining a target file corresponding to the system to be tested in the blockchain, wherein the target file includes a model file corresponding to the image recognition model;
[0028] Based on the model file corresponding to the image recognition model, the image recognition model in the system to be tested is optimized.
[0029] A second aspect of an embodiment of the present application provides a device for storing data based on blockchain, including:
[0030] A generating unit, used to perform simulation tests on each preset system respectively through a Mock test tool to generate simulation test data for each preset system;
[0031] An acquisition unit, used to acquire data cleaning rules corresponding to each of the preset systems;
[0032] The storage unit is used to encrypt the simulation test data and data cleaning rules corresponding to each of the preset systems respectively, and store the encrypted simulation test data and data cleaning rules in the blockchain.
[0033] A third aspect of an embodiment of the present application provides a device for storing data based on blockchain, 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 steps of the method for storing data based on blockchain as described in the first aspect above are implemented.
[0034] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for storing data based on blockchain as described in the first aspect above are implemented.
[0035] A fifth aspect of an embodiment of the present application provides a computer program product. When the computer program product is run on a device that stores data based on blockchain, the device executes the steps of the method for storing data based on blockchain described in the first aspect above.
[0036] The method, device, equipment and storage medium for storing data based on blockchain provided in the embodiments of the present application have the following beneficial effects:
[0037] Through the Mock test tool, each preset system is simulated and tested respectively to generate simulated test data for each preset system; the data cleaning rules corresponding to each preset system are obtained; the simulated test data and data cleaning rules corresponding to each preset system are encrypted respectively, and the encrypted simulated test data and data cleaning rules are stored in the blockchain. In the above scheme, the simulated test data and data cleaning rules corresponding to multiple preset systems are encrypted and stored in the blockchain, which realizes the sharing and circulation of test data, enriches the types of test data, avoids malicious tampering and leakage of test data, ensures the security of test data, and avoids test data isolation; and when the system to be tested obtains these test data in the blockchain for system testing, the test data is rich, comprehensive, and has a wide coverage, thereby improving the accuracy of the test results and making the test functions more complete. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0039] Figure 1 is a schematic flow chart of a method for storing data based on blockchain provided by an exemplary embodiment of the present application;
[0040] Figure 2 This is a specific process of step S101 of a method for storing data based on blockchain as shown in an exemplary embodiment of the present application;
[0041] Figure 3 It is a specific flow chart of step S103 of the method for storing data based on blockchain shown in an exemplary embodiment of the present application;
[0042] Figure 4 is a schematic flow chart of a method for storing data based on blockchain, shown in an exemplary embodiment of the present application;
[0043] Figure 5 This is a schematic diagram of a device for storing data based on blockchain provided by an embodiment of the present application;
[0044] Figure 6 This is a schematic diagram of a device for storing data based on blockchain provided by another embodiment of the present application. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0046] In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0047] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "plurality" means two or more.
[0048] See also Figure 1 , Figure 1 This is a schematic flow chart of a method for storing data based on blockchain provided by an exemplary embodiment of the present application. The execution subject of the method for storing data based on blockchain provided by the present application is a device for storing data based on blockchain, wherein the device includes but is not limited to a domain name server (Domain Name Server, DNS), an independent server, a distributed server, a server cluster or a cloud server, etc. The device can also be a mobile terminal such as a smart phone, a tablet computer, a computer, a personal digital assistant (Personal Digital Assistant, PDA), a desktop computer, etc. Figure 1 The method for storing data based on blockchain may include: S101 to S103, which are as follows:
[0049] S101: Performing simulation tests on each preset system respectively through a Mock test tool to generate simulation test data for each preset system.
[0050] The preset system in this example refers to any system that can provide simulated test data and data cleaning rules, and there is no limitation on the type of the preset system.
[0051] Simulation test data is data used to test whether the preset system can operate normally, whether various functions are normal, and whether the functions are complete. Simulation test data can include interface test data and functional test data. Among them, interface test data includes test interface identification, test request (request method), attribute parameters, return parameters (returned data type and returned data content), etc. Functional test data includes test cases, test steps and expected results, etc.
[0052] The simulation test data includes the test interface identifier, attribute parameters and return parameters corresponding to the preset system.
[0053] Exemplarily, the Mock test tool is used to simulate the test environment for the preset system, perform Mock testing, and then generate simulation test data corresponding to the preset system. The simulation test data corresponding to each preset system is uploaded to the server. Mock testing is a test method that uses a virtual object (Mock object) to create a test method for some complex objects that are not easy to construct or obtain during the test process.
[0054] For example, in actual applications, there are often situations where the development progress of the front-end and back-end is inconsistent, the test front-end needs to write interface test scripts in advance, and some scenarios are uncertain or difficult to reproduce. In order to avoid these situations affecting the normal testing of the system, the test environment and test data are usually simulated.
[0055] For example, the Mock test tool can be used to simulate the test environment and test data. For example, a system needs to call a post request to obtain a response to determine whether the current system can correctly process the returned "response", but this post request will cause data pollution in the database. At this time, the Mock test tool can be fully utilized to construct a virtual post request and customize the specified return.
[0056] For example, there is an interface to be tested in the system, which has 100 different types of returns. It is necessary to test whether the system can respond normally under different returns. However, some returns will not occur under normal circumstances. For example, it is necessary to test whether the system will crash when a 500 error occurs in the interface. However, it is not realistic to change the server code to return a 500 error. In this case, the Mock test tool can be used to simulate the specified return data to improve the test coverage.
[0057] Take any preset system as an example to explain, use the Mock test tool to configure the test interface uniform resource locator (Uniform Resource Locator, URL), request method, attribute parameters, return parameters (returned data type and returned data content) for the preset system, and generate the test data corresponding to the preset system according to the configured information. Among them, the test interface URL can include IP address, port number, interface path, etc.
[0058] Optionally, when the data type is text, the source of the returned data content can be a database (such as database connection, table, field, etc.), and the returned data content can also be a custom input string data. When the data type is JSON, Excel, or picture, the returned data content must include JSON files, Excel files, and picture files. This is only an example and is not limited to this.
[0059] Optionally, the simulation test data corresponding to each preset system may be pre-stored in a database, and when the simulation test data corresponding to a preset system needs to be obtained, the simulation test data corresponding to the preset system is searched in the database. This is only an exemplary description and is not limited to this.
[0060] In the above implementation, the Mock test tool is used to simulate the real and effective test data corresponding to each system, enriching the test scenarios and test data types, storing each simulated test data in the blockchain, realizing the sharing of simulated test data, avoiding malicious tampering and leakage of simulated test data, ensuring the security of simulated test data, and avoiding the isolation of simulated test data. Simulated test data can be obtained in the blockchain later, and the system to be tested can be tested by simulated test data, which can make the test scenarios of the system to be tested rich and comprehensive, and the test data coverage wide, so that the system test results are more accurate, the test functions are more complete, and the test efficiency is improved.
[0061] Optionally, interface test data and functional test data can be set for each preset system by the traditional method of setting test data without the help of the Mock test tool. Take the setting of interface test data corresponding to a preset system as an example to illustrate, obtain a test request initiated by a certain interface to be tested of the preset system, pass the attribute parameters corresponding to the preset interface to be tested into the interface to be tested, and obtain the data returned by the interface to be tested for the attribute parameters. Among them, the test request contains the test interface identifier corresponding to the interface to be tested. According to the test request, the attribute parameters corresponding to the preset interface to be tested and the returned data, generate the simulation test data corresponding to the preset system, and upload the simulation test data to the server. This is only an exemplary description and is not limited to this.
[0062] Optionally, the simulation test data corresponding to each preset system may be pre-stored in a database, and when the simulation test data corresponding to a preset system needs to be obtained, the simulation test data corresponding to the preset system is searched in the database. This is only an exemplary description and is not limited to this.
[0063] S102: Obtain data cleaning rules corresponding to each preset system.
[0064] Data cleaning rules are used to filter data that meets preset requirements in simulated test data. Data cleaning rules are set for each preset system and may be used when filtering the simulated test data corresponding to each preset system. Different codes are set according to different data cleaning rules. Running these codes can filter data that meets preset requirements in simulated test data.
[0065] Data cleaning rules may include data type cleaning rules, code mapping methods, and regular expressions. Among them, data type cleaning rules are used to filter parameters that meet preset data types in the return parameters in the simulated test data. For example, the return parameters in a simulated test data include text type parameters, numeric type parameters, date type parameters, and string type parameters. When the actual system is tested, only numeric type parameters are returned. At this time, the data type cleaning rules can be used to filter out parameters other than numeric types, and only numeric type return parameters are retained.
[0066] The code mapping method may include a mapping method corresponding to the code in the test request and the return parameter, which is used to convert the code in the test request and the return parameter according to the mapping method. The regular expression is composed of custom functions and is a logical formula for string and special character operations, which is used to perform custom cleaning of test data. This is only an exemplary description and is not limited to this.
[0067] Exemplarily, the data type cleaning rules may include value range limitation rules, text range limitation rules, date range limitation rules, etc. Among them, the value range limitation rules may include limiting the range to which the value corresponding to the return parameter belongs, which is used to perform data cleaning (data screening) when the return parameter contains a value. The text range limitation rules may include limiting the range to which the text corresponding to the return parameter belongs, which is used to perform data cleaning when the return parameter contains text. The date range limitation rules may include limiting the range to which the date corresponding to the return parameter belongs, which is used to perform data cleaning when the return parameter contains a date.
[0068] Optionally, the data cleaning rules corresponding to each preset system may be pre-stored in a database, and when the data cleaning rules corresponding to a preset system need to be obtained, the data cleaning rules corresponding to the preset system are searched in the database. This is only an exemplary description and is not limited to this.
[0069] In the above implementation, data cleaning rules can be used to filter data that meets preset requirements in the simulated test data, so that the obtained test data better meets the system test requirements, and then when the cleaned data is used for system testing, the system test results are more accurate.
[0070] S103: Encrypt the simulation test data and data cleaning rules corresponding to each preset system respectively, and store the encrypted simulation test data and data cleaning rules in the blockchain.
[0071] The simulation test data and data cleaning rules corresponding to each preset system are encrypted respectively, and the encrypted simulation test data and data cleaning rules corresponding to each preset system are stored in the blockchain through a decentralized distributed storage method.
[0072] In the above method, each preset system is simulated and tested by the Mock test tool to generate simulated test data for each preset system; the data cleaning rules corresponding to each preset system are obtained; the simulated test data and data cleaning rules corresponding to each preset system are encrypted, and the encrypted simulated test data and data cleaning rules are stored in the blockchain. In the above scheme, the simulated test data and data cleaning rules corresponding to multiple preset systems are encrypted and stored in the blockchain, which realizes the sharing and circulation of simulated test data, enriches the types of simulated test data, avoids malicious tampering and leakage of simulated test data, ensures the security of simulated test data, and avoids the isolation of simulated test data; and when the system to be tested obtains these simulated test data in the blockchain for system testing, the rich, comprehensive and wide coverage of simulated test data improves the accuracy of the test results and makes the test functions more complete.
[0073] Figure 2 It is a specific flow chart of step S103 of the method for storing data based on blockchain shown in an exemplary embodiment of the present application; optionally, in some possible implementations of the present application, the above S103 may include S1031~S1032, which are as follows:
[0074] S1031: For each preset system, a hash algorithm is used to encrypt the simulation test data and data cleaning rules corresponding to the preset system to obtain encrypted simulation test data and encrypted data cleaning rules.
[0075] S1032: Store the encrypted simulation test data and encrypted data cleaning rules in the blockchain node corresponding to the preset system.
[0076] Exemplarily, the simulation test data corresponding to each preset system is encrypted using a hash algorithm to obtain encrypted simulation test data corresponding to each simulation test data, and the encrypted simulation test data corresponding to each preset system is stored in the blockchain node corresponding to each preset system.
[0077] For example, for one of the preset systems, the encrypted simulation test data corresponding to the preset system is stored in the block of the blockchain node corresponding to the preset system. During the storage process, the hash value corresponding to the simulation test data is calculated, the hash value is used as the identification information of the simulation test data, the hash value is stored in the block header contained in the block, and the encrypted simulation test data is stored in the block body. Among them, the hash algorithm can include the SHA-256 algorithm, the MD5 encryption algorithm, etc. This is only an exemplary description and is not limited to this.
[0078] Similarly, the data cleaning rules corresponding to each preset system are encrypted using a hash algorithm to obtain encrypted data cleaning rules corresponding to each data cleaning rule, and the encrypted data cleaning rules corresponding to each preset system are stored in the blockchain node corresponding to each preset system.
[0079] For example, for one of the preset systems, the encrypted data cleaning rules corresponding to the preset system are stored in the block of the blockchain node corresponding to the preset system. During the storage process, the hash value corresponding to the data cleaning rule is calculated, the hash value is used as the identification information of the data cleaning rule, the hash value is stored in the block header contained in the block, and the encrypted data cleaning rule is stored in the block body. Among them, the hash algorithm can include the SHA-256 algorithm, the MD5 encryption algorithm, etc. This is only an exemplary description and is not limited to this.
[0080] Optionally, in a possible implementation, based on a storage system of a certain blockchain, data shards are first created, and the simulation test data and data cleaning rules corresponding to each preset system are a shard.
[0081] Encrypt each shard, that is, the storage system encrypts each data shard on the local system. The owner of each preset system can fully control this process, which can further ensure the simulation test data and data cleaning rules corresponding to each preset system. No one except the owner can view or access the data in the shard.
[0082] Generate a hash value for each shard, that is, the blockchain storage system generates a unique hash for the simulated test data and data cleaning rules corresponding to each preset system, that is, an encrypted output string of fixed length.
[0083] Replicate each shard, that is, the storage system will replicate the simulation test data and data cleaning rules corresponding to each preset system. Therefore, there are enough redundant copies to ensure the availability and performance of the simulation test data and data cleaning rules corresponding to each preset system, and prevent performance degradation and data loss. The owner of each preset system decides the number of copies of each shard and where these shards are located. In this process, the owner of each preset system can establish a threshold for the minimum number of copies that need to be maintained to ensure that no data is lost.
[0084] Distribute the replicated shards, i.e., the peer-to-peer (P2P) network distributes the simulated test data and data cleaning rules corresponding to each replicated preset system to geographically dispersed storage nodes, whether regionally or globally. The storage system records the data content, data identification information, storage location, etc. stored in each node of the blockchain.
[0085] Optionally, in a possible implementation, the method for storing data based on blockchain provided in the present application may also include: obtaining model files corresponding to the AI models of each preset system; encrypting each model file respectively, and storing the encrypted model files in the blockchain.
[0086] In layman's terms, an artificial intelligence (AI) model refers to a model obtained by machine learning on big data, and a model is also an algorithm used in machine learning. AI models can be models in various fields. For example, AI models can include natural language processing models, image processing models, image recognition models, video processing models, text processing models, identity recognition models, etc.
[0087] Exemplarily, each preset system trains its corresponding AI model to obtain a model file corresponding to the trained AI model. The AI model is used to test the preset function of the preset system. For example, a system is used to identify employee identities, and it can train an employee identity recognition model, which is used to test the employee identity recognition function of the preset system. This is only an exemplary description and is not limited to this.
[0088] Encrypt the model files corresponding to the AI model of each preset system respectively, and use the hash algorithm to encrypt them to obtain the encrypted files corresponding to the AI model of each preset system. Store the encrypted files corresponding to each preset system in the blockchain node corresponding to each preset system.
[0089] Exemplarily, for any of the preset systems, during the storage process, the hash value corresponding to the model file corresponding to the AI model of the preset system is calculated, the hash value is used as the identification information of the model file corresponding to the AI model, the hash value is stored in the block header contained in the block, and the encrypted file is stored in the block body. Among them, the hash algorithm can include the SHA-256 algorithm, the MD5 encryption algorithm, etc. This is only an exemplary description and is not limited to this.
[0090] Optionally, in a possible implementation, a storage system based on a certain blockchain first creates data shards, and the model file corresponding to the AI model of each preset system is a shard. Encrypt each shard, that is, the storage system encrypts each data shard on the local system. The owner of each preset system can fully control this process, which can further ensure that the file corresponding to the AI model of each preset system, except for the owner, cannot view or access the data in the shard.
[0091] Generate a hash value for each shard, that is, the blockchain storage system generates a unique hash for the model file corresponding to the AI model of each preset system - that is, an encrypted output string of fixed length. Copy each shard, that is, the storage system will copy the model file corresponding to the AI model of each preset system. Therefore, there are enough redundant copies to ensure the availability and performance of the model file corresponding to the AI model of each preset system, and prevent performance degradation and data loss. The owner of each preset system decides the number of copies of each shard and where these shards are located. In this process, the owner of each preset system can establish a threshold for the minimum number of copies that need to be maintained to ensure that no data is lost.
[0092] Distribute the replicated shards, that is, the P2P network distributes the model files corresponding to the AI models of each preset system to geographically dispersed storage nodes, whether regionally or globally. The storage system records the data content, data identification information, storage location, etc. stored in each node of the blockchain.
[0093] Optionally, after storing the encrypted model file in the blockchain, the method for storing data based on blockchain provided in the present application also includes: obtaining a target file corresponding to the system to be tested in the blockchain, wherein the target file includes a model file corresponding to the image recognition model; based on the model file corresponding to the image recognition model, optimizing the image recognition model in the system to be tested.
[0094] Exemplarily, a model request information initiated by the system to be tested is received, wherein the request information includes a model request identifier; according to the model request identifier, a target file is searched in the blockchain, wherein the target file includes a model file corresponding to the image recognition model and a decryption method; the target file is fed back to the system to be tested, and the system to be tested decrypts the encrypted model file according to the decryption method in the target file to obtain a model file corresponding to the decrypted image recognition model; according to the parameters of the image recognition model, the parameters of the image recognition model in the system to be tested are adjusted. For example, the output of the image recognition model in the blockchain is used as supervision to train the image recognition model in the system to be tested. For example, for the same set of training samples, the images in the training samples are first input into the image recognition model in the blockchain, and the results output by the image recognition model in the blockchain are used as the learning target of the image recognition model in the system to be tested. During the training process, the parameters of the image recognition model in the system to be tested are continuously adjusted until the image recognition model in the system to be tested can also output output results of the same quality as the image recognition model in the blockchain.
[0095] Optionally, the accuracy of the image recognition model in the system to be tested can also be determined by the image recognition model in the blockchain. For example, if a system to be tested needs to test the accuracy of image recognition, a trained image recognition model can be obtained in the blockchain, and the image in the system to be tested can be input into the image recognition model for processing to obtain the corresponding recognition result. The accuracy of the image recognition of the system to be tested is determined based on the recognition result. This is only an exemplary description and is not limited to this.
[0096] In this embodiment, the model file corresponding to the AI model of each preset system is uploaded to the blockchain, which can ensure its security and fairness and transparency to users. And the model file corresponding to the AI model of each preset system is uploaded to the blockchain. With the characteristics that the files on the blockchain cannot be tampered with at will, the model file corresponding to the AI model of each preset system can be prevented from being maliciously tampered with, which is convenient for the subsequent system to be tested to obtain the AI model in the blockchain, and the relevant functions of the system to be tested are tested by the obtained AI model, which improves the accuracy of the system test. And there is no need for the system to be tested to retrain the relevant AI model, which improves the test efficiency.
[0097] Optionally, in a possible implementation, the method for storing data based on blockchain provided by the present application may further include: storing algorithm expressions in the blockchain. For example, expressions such as addition, subtraction, multiplication, division, summation, average, maximum value, and minimum value are stored in the blockchain. The algorithm expression is processed using a hash algorithm to obtain an encrypted algorithm expression corresponding to the algorithm expression, and the encrypted algorithm expression is stored in the blockchain node. The process of storing the algorithm expression can refer to the specific process of storing the simulation test data and data cleaning rules mentioned above, which will not be repeated here.
[0098] Optionally, in actual use, if a system to be tested needs to calculate the test data it obtains, the corresponding algorithm expression can be obtained in the blockchain, and the test data can be calculated according to the algorithm expression stored in the blockchain.
[0099] In this embodiment, uploading the algorithm expression to the blockchain can ensure its security and fairness and transparency to users. And uploading the algorithm expression to the blockchain can avoid malicious tampering of the algorithm expression by virtue of the fact that the files on the blockchain cannot be tampered with at will, so that the subsequent system to be tested can obtain the algorithm expression in the blockchain, and the test data of the system to be tested can be calculated by the obtained algorithm expression, thereby improving the accuracy of system testing.
[0100] Figure 3 is a schematic flow chart of a method for storing data based on blockchain, shown in an exemplary embodiment of the present application; it mainly involves executing Figure 1 After the method of storing data based on blockchain is shown, the process of testing the system. The method includes: S201~S205, which are as follows:
[0101] S201: Receive request information initiated by a system to be tested, where the request information includes a request identifier.
[0102] The system to be tested is a system that needs to be tested. In this embodiment, the system to be tested can initiate a request message to the server, and the server responds to the request message, and the request message is used to find the target data in the blockchain. The request message may include a request identifier, which is used to indicate which type of preset system corresponding to the simulation test data and / or data cleaning rules is desired to be obtained.
[0103] S202: According to the request identifier, search for target data in the blockchain, where the target data includes encrypted simulation test data corresponding to the target system, encrypted data cleaning rules, and a decryption method.
[0104] The server responds to the request information, and according to the request identifier in the request information, searches the blockchain node where the target system requested by the request identifier is located in the blockchain storage system, forwards the request information to the blockchain node, and searches the target data in the blockchain node. The target data includes the encrypted simulation test data corresponding to the target system, the encrypted data cleaning rules, and the decryption method.
[0105] S203: Feeding back the target data to the system to be tested, the target data is used by the system to be tested to decrypt the encrypted simulation test data and the encrypted data cleaning rule according to the decryption method to obtain the decrypted simulation test data and data cleaning rule.
[0106] Optionally, each request identifier corresponds to a target system. The decryption method may include a first decryption method corresponding to the encrypted simulation test data, and a second decryption method corresponding to the encrypted data cleaning rule.
[0107] The first decryption method is a decryption method corresponding to the encryption method used when encrypting the simulation test data, and the encrypted simulation test data can be decrypted by the first decryption method. The second decryption method is a decryption method corresponding to the encryption method used when encrypting the data cleaning rule, and the encrypted data cleaning rule can be decrypted by the second decryption method.
[0108] Optionally, if the request information contains a request identifier, the corresponding target data is obtained in the blockchain node according to the request identifier, and the target data is returned to the system to be tested. If the request information may contain multiple different request identifiers, each request identifier corresponds to a target system. According to different request identifiers, the target data corresponding to different target systems are obtained in the blockchain node, and the target data corresponding to these target systems are uniformly returned to the system to be tested.
[0109] Exemplarily, the encrypted simulation test data is decrypted by the first decryption method to obtain the decrypted simulation test data. The encrypted data cleaning rule is decrypted by the second decryption method to obtain the decrypted data cleaning rule. This is only an exemplary description and is not limited to this.
[0110] S204: Clean the decrypted simulation test data according to the decrypted data cleaning rule to obtain target test data.
[0111] Data type cleaning rules may include numerical range limitation rules, text range limitation rules, date range limitation rules, etc. According to the actual needs of the system to be tested, appropriate cleaning rules are selected from the decrypted data cleaning rules, and the decrypted simulated test data is cleaned to obtain the target test data.
[0112] For example, if the system to be tested needs to test whether certain returned dates can be processed normally, the return parameters in the simulated test data can be cleaned by using the date range restriction rule. The date range corresponding to the return parameters in the simulated test data is made within the range we set, and other returned parameters that do not fall within the date range are removed.
[0113] The target test data may include the target test request (request method), target attribute parameters, target return parameters (the type of data returned and the content of the returned data), etc. Optionally, the target test data may be adjusted to generate a variety of test data. For example, if the target test data contains a positive test case, the target attribute parameters may be adjusted to generate a corresponding abnormal test case. This is only an exemplary description and is not limited to this.
[0114] In this example, the simulated test data can be cleaned through data cleaning rules to obtain target test data suitable for different systems to be tested, enriching the test data of the systems to be tested, supporting the testing of various normal data and abnormal data of the systems to be tested, thereby making the test results of the systems to be tested more comprehensive and indirectly improving the accuracy of the testing of the systems to be tested.
[0115] S205: Testing the system to be tested according to the target test data.
[0116] The system to be tested is tested using the target test data to obtain a test result corresponding to the system to be tested, and the system to be tested is optimized according to the test result.
[0117] The system to be tested is tested using the target test data. For example, a target test data is as follows
[0118] this.axios
[0119] .post(this.$url.queryPageConsulting, { page: 1, limit: 4})
[0120] .then((data) => {
[0121] this.yxVideos = data.data;
[0122] });
[0123] Among them, this.$url.queryPageConsulting represents the interface identifier corresponding to the system to be tested, page:1, limit: 4 represents the attribute parameters, and this.yxVideos = data.data represents the return parameters. The attribute parameters are passed into the system to be tested, the data returned by the system to be tested for the attribute parameters is obtained, and the returned data is compared with the return parameters in the target test data to see if they are the same. If the data returned during the test is the same as the return parameters in the target test data, it proves that this function of the system to be tested is normal; if the data returned during the test is different from the return parameters in the target test data, it proves that this function of the system to be tested is abnormal. In order to ensure the accuracy of the test, the system to be tested can be tested repeatedly. When the test result shows that a function of the system to be tested is abnormal, a prompt message can be generated, which is used to prompt the developer to adjust the code corresponding to the function of the system to be tested.
[0124] Figure 4 is a specific flow chart of step S204 of the method for storing data based on blockchain, shown in an exemplary embodiment of the present application; optionally, in some possible implementations of the present application, the above S204 may include S2041~S2042, as follows:
[0125] S2041: According to the data cleaning rules, filter the parameters that meet the preset data types in the returned parameters.
[0126] S2042: Generate target test data based on parameters that conform to preset data types.
[0127] Exemplarily, the decrypted simulation test data includes return parameters, test interface identifiers, test requests (request methods), attribute parameters, etc. Data type cleaning rules may include numerical range limitation rules, text range limitation rules, date range limitation rules, etc. According to the actual needs of the system to be tested, appropriate cleaning rules are selected from the decrypted data cleaning rules to clean the decrypted simulation test data to obtain target test data. For example, the system to be tested needs to test whether certain returned specific dates can be processed normally. The return parameters in the simulation test data can be cleaned by date range limitation rules. Make the range of dates corresponding to the return parameters in the simulation test data within the range we set, and remove other returned parameters that do not belong to the date range. Generate target test data based on parameter test interface identifiers, test requests (request methods), attribute parameters, etc. that meet the preset data types. This is only an exemplary description and is not limited to this.
[0128] Optionally, in some possible implementations of the present application, after S201, the identity of the system to be tested may be verified; when the identity of the system to be tested fails to pass the verification, a reminder message is generated and fed back to the system to be tested.
[0129] Exemplarily, a smart contract is written in the blockchain. According to the smart contract of the blockchain storage platform, it is determined whether the user of the system to be tested has the authority to obtain the target data. If the user has the authority to obtain the target data, S202 to S205 are executed; if the user does not have the authority to obtain the target data, a reminder message is generated and fed back to the system to be tested. The reminder message is used to remind the user of the system to be tested that the user does not have the authority to obtain the target data in the blockchain.
[0130] Among them, smart contracts are computer protocols that transmit, verify or execute contracts in an information-based manner, allowing trusted transactions without a third party, which are traceable and irreversible. Smart contracts are digital, stored in the blockchain, and use encrypted code to enforce the agreement. Smart contracts can negotiate the terms in the agreement, automatically verify the fulfillment, and also execute the agreed terms. The characteristics of smart contracts are: (1) high autonomy, that is, when the preset conditions on the smart contract are triggered, the contract will be automatically executed; (2) decentralization, that is, no centralized server is required, which can reduce transaction costs and solve the trust problem. Since all data on the blockchain is open and transparent, the data processing of smart contracts is also open and transparent, and any party can view its code and data during operation. All data on the blockchain itself cannot be tampered with, so the smart contract code deployed on the blockchain and the data output generated by the operation are also tamper-proof. Nodes running smart contracts do not have to worry about other nodes maliciously modifying the code and data. Specifically, smart contracts can be used for any exchange between data users and data providers, and their code contains some conditions that will trigger the automatic execution of the contract. Therefore, when the data user (the user of the system to be tested) needs to obtain the target data from the blockchain, the request information of the data user can be obtained. By checking the request information of the data user and judging whether it has the authority to obtain the target data according to the rights and obligations of the data user agreed in the smart contract.
[0131] In the above implementation, the identity of the system to be tested is verified, which further ensures the security of obtaining the target data.
[0132] See also Figure 5 , Figure 5 Schematic diagram of a device for storing data based on blockchain provided in one embodiment of the present application. The device includes units for executing Figure 1~Figure 4 For details, please refer to the steps in the corresponding embodiment. Figure 1~Figure 4For the convenience of explanation, only the parts related to this embodiment are shown. Figure 5 ,include:
[0133] The generating unit 310 is used to perform simulation tests on each preset system respectively through a Mock test tool to generate simulation test data for each preset system;
[0134] An acquisition unit 320 is used to acquire data cleaning rules corresponding to each of the preset systems;
[0135] The storage unit 330 is used to encrypt the simulation test data and data cleaning rules corresponding to each of the preset systems, and store the encrypted simulation test data and data cleaning rules in the blockchain.
[0136] Optionally, the storage unit 330 is specifically used for:
[0137] For each preset system, a hash algorithm is used to encrypt the simulation test data and data cleaning rules corresponding to the preset system to obtain encrypted simulation test data and encrypted data cleaning rules;
[0138] The encrypted simulation test data and the encrypted data cleaning rules are stored in the blockchain node corresponding to the preset system.
[0139] Optionally, the device further comprises:
[0140] A model file acquisition unit, used to acquire a model file corresponding to the AI model of each of the preset systems;
[0141] The encryption unit is used to encrypt each of the model files respectively and store the encrypted model files in the blockchain.
[0142] Optionally, the device further comprises a testing unit, wherein the testing unit is specifically used for:
[0143] Receiving request information initiated by the system to be tested, wherein the request information includes a request identifier;
[0144] According to the request identifier, searching for target data in the blockchain, wherein the target data includes encrypted simulation test data corresponding to the target system, encrypted data cleaning rules, and a decryption method;
[0145] Feeding back the target data to the system to be tested, wherein the target data is used to instruct the system to be tested to decrypt the encrypted simulation test data and the encrypted data cleaning rules according to the decryption method to obtain the decrypted simulation test data and data cleaning rules;
[0146] Clean the decrypted simulation test data according to the decrypted data cleaning rules to obtain the target test data;
[0147] The system to be tested is tested according to the target test data.
[0148] Optionally, the decrypted simulation test data includes a return parameter, and the test unit is further used to:
[0149] According to the data cleaning rule, filtering parameters that conform to a preset data type from the return parameters;
[0150] The target test data is generated based on the parameters that conform to the preset data type.
[0151] Optionally, the device further includes a verification unit, and the verification unit is specifically used to:
[0152] Verifying the identity of the system to be tested;
[0153] When the identity of the system to be tested fails to pass the verification, a reminder message is generated and fed back to the system to be tested.
[0154] Optionally, the device further comprises an optimization unit, wherein the optimization unit is specifically configured to:
[0155] Obtaining a target file corresponding to the system to be tested in the blockchain, wherein the target file includes a model file corresponding to the image recognition model;
[0156] Based on the model file corresponding to the image recognition model, the image recognition model in the system to be tested is optimized.
[0157] See also Figure 6 , Figure 6 Schematic diagram of a device for storing data based on blockchain provided by another embodiment of the present application. Figure 6 As shown, the device 4 of this embodiment includes: a processor 40, a memory 41, and a computer program 42 stored in the memory 41 and executable on the processor 40. When the processor 40 executes the computer program 42, the steps in the above-mentioned various embodiments of the method for storing data based on blockchain are implemented, such as Figure 1 Alternatively, when the processor 40 executes the computer program 42, the functions of each unit in the above embodiments are realized, for example, Figure 5 The functions of units 310 to 330 are shown.
[0158] Exemplarily, the computer program 42 may be divided into one or more units, which are stored in the memory 41 and executed by the processor 40 to complete the present application. The one or more units may be a series of computer instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 42 in the device 4. For example, the computer program 42 may be divided into a generation unit, an acquisition unit, and a storage unit, and the specific functions of each unit are as described above.
[0159] The device may include, but is not limited to, a processor 40 and a memory 41. Those skilled in the art will appreciate that Figure 6 It is only an example of device 4 and does not constitute a limitation of the device. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the device may also include input and output devices, network access devices, buses, etc.
[0160] The processor 40 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (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.
[0161] The memory 41 may be an internal storage unit of the device, such as a hard disk or memory of the device. The memory 41 may also be an external storage terminal of the device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the device. Further, the memory 41 may include both an internal storage unit of the device and an external storage terminal. The memory 41 is used to store the computer instructions and other programs and data required by the terminal. The memory 41 may also be used to temporarily store data that has been output or is to be output.
[0162] The embodiments of the present application also provide a computer storage medium, which may be non-volatile or volatile. The computer storage medium stores a computer program, which, when executed by a processor, implements the steps in the above-mentioned various embodiments of the method for storing data based on blockchain.
[0163] The present application also provides a computer program product. When the computer program product is run on a device, the device executes the steps in each of the above-mentioned methods for storing data based on blockchain.
[0164] An embodiment of the present application also provides a chip or integrated circuit, which includes: a processor, which is used to call and run a computer program from a memory, so that a device equipped with the chip or integrated circuit executes the steps in the above-mentioned method embodiments for storing data based on blockchain.
[0165] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be 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. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0166] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0167] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0168] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features can be replaced by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for storing data based on blockchain, characterized in that: include: Perform simulation tests on each preset system respectively through the Mock test tool to generate simulation test data for each preset system; The simulation test data includes interface test data and functional test data, the interface test data includes test interface identification, test request, attribute parameters, return parameters, and the functional test data includes test cases, test steps and expected results; Obtaining data cleaning rules corresponding to each of the preset systems; the data cleaning rules include data type cleaning rules, code mapping methods, and regular expressions; The code mapping method is used to convert the codes in the test request and the return parameter according to the code mapping method; Encrypting the simulation test data and data cleaning rules corresponding to each of the preset systems respectively, and storing the encrypted simulation test data and data cleaning rules in the blockchain; Receive request information initiated by the system to be tested, wherein the request information includes a request identifier; search for target data in the blockchain according to the request identifier, wherein the target data includes encrypted simulation test data, encrypted data cleaning rules, and a decryption method corresponding to the target system; feed back the target data to the system to be tested, wherein the target data is used to instruct the system to be tested to decrypt the encrypted simulation test data and the encrypted data cleaning rules according to the decryption method to obtain decrypted simulation test data and data cleaning rules; clean the decrypted simulation test data according to the decrypted data cleaning rules to obtain target test data; Testing the system to be tested according to the target test data; Obtain model files corresponding to the AI models of each of the preset systems; encrypt each of the model files respectively, and store the encrypted model files in the blockchain; the AI model includes an image recognition model; obtain a target file corresponding to the system to be tested in the blockchain, the target file includes a model file corresponding to the image recognition model; based on the model file corresponding to the image recognition model, optimize the image recognition model in the system to be tested.
2. The method according to claim 1, characterized in that Before receiving the request information initiated by the system to be tested, the method further includes: For each preset system, a hash algorithm is used to encrypt the simulation test data and data cleaning rules corresponding to the preset system to obtain encrypted simulation test data and encrypted data cleaning rules; The encrypted simulation test data and the encrypted data cleaning rules are stored in the blockchain node corresponding to the preset system.
3. The method according to claim 1, characterized in that The decrypted simulation test data includes a return parameter, and the decrypted simulation test data is cleaned according to the decrypted data cleaning rule to obtain the target test data, including: According to the data cleaning rule, filtering parameters that conform to a preset data type from the return parameters; The target test data is generated based on the parameters that conform to the preset data type.
4. The method according to claim 1, characterized in that After receiving the request information initiated by the system to be tested, the method further includes: Verifying the identity of the system to be tested; When the identity of the system to be tested fails to pass the verification, a reminder message is generated and fed back to the system to be tested.
5. A device for storing data based on blockchain, characterized in that: include: A generating unit, used to perform simulation tests on each preset system respectively through a Mock test tool to generate simulation test data for each preset system; The simulation test data includes interface test data and functional test data, the interface test data includes test interface identification, test request, attribute parameters, return parameters, and the functional test data includes test cases, test steps and expected results; An acquisition unit, used to acquire data cleaning rules corresponding to each of the preset systems; Data cleaning rules include data type cleaning rules, code mapping methods, and regular expressions; The code mapping method is used to convert the codes in the test request and the return parameter according to the code mapping method; A storage unit, used to encrypt the simulation test data and data cleaning rules corresponding to each of the preset systems, and store the encrypted simulation test data and data cleaning rules in the blockchain; Receive request information initiated by the system to be tested, wherein the request information includes a request identifier; search for target data in the blockchain according to the request identifier, wherein the target data includes encrypted simulation test data, encrypted data cleaning rules, and a decryption method corresponding to the target system; feed back the target data to the system to be tested, wherein the target data is used to instruct the system to be tested to decrypt the encrypted simulation test data and the encrypted data cleaning rules according to the decryption method to obtain decrypted simulation test data and data cleaning rules; clean the decrypted simulation test data according to the decrypted data cleaning rules to obtain target test data; Testing the system to be tested according to the target test data; Obtain model files corresponding to the AI models of each of the preset systems; encrypt each of the model files respectively, and store the encrypted model files in the blockchain; the AI model includes an image recognition model; obtain a target file corresponding to the system to be tested in the blockchain, the target file includes a model file corresponding to the image recognition model; based on the model file corresponding to the image recognition model, optimize the image recognition model in the system to be tested.
6. A device for storing data based on blockchain, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 4 is implemented.
7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
