diff options
author | Dimitry <winsvega@mail.ru> | 2017-01-28 00:31:19 +0800 |
---|---|---|
committer | Dimitry <winsvega@mail.ru> | 2017-01-28 00:31:19 +0800 |
commit | ea7e06b2970a01cd11b3a062425f5c5cafc19ee7 (patch) | |
tree | 82f0dad0a0c0c37591e8c8d542710b8d909f086d /RPCTests/modules/testutils.js | |
parent | bc8ad7422d32a940bab194173083a684adcc2706 (diff) | |
download | tangerine-tests-ea7e06b2970a01cd11b3a062425f5c5cafc19ee7.tar tangerine-tests-ea7e06b2970a01cd11b3a062425f5c5cafc19ee7.tar.gz tangerine-tests-ea7e06b2970a01cd11b3a062425f5c5cafc19ee7.tar.bz2 tangerine-tests-ea7e06b2970a01cd11b3a062425f5c5cafc19ee7.tar.lz tangerine-tests-ea7e06b2970a01cd11b3a062425f5c5cafc19ee7.tar.xz tangerine-tests-ea7e06b2970a01cd11b3a062425f5c5cafc19ee7.tar.zst tangerine-tests-ea7e06b2970a01cd11b3a062425f5c5cafc19ee7.zip |
rpc tests on js
Diffstat (limited to 'RPCTests/modules/testutils.js')
-rw-r--r-- | RPCTests/modules/testutils.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/RPCTests/modules/testutils.js b/RPCTests/modules/testutils.js new file mode 100644 index 000000000..7128c6972 --- /dev/null +++ b/RPCTests/modules/testutils.js @@ -0,0 +1,69 @@ +const fs = require('fs'); +var utils = require('./utils.js'); +var tests = {}; +var testCount = 0; + +module.exports = { + +generateCustomGenesis: function generateCustomGenesis(path, originalPath, accountName, finished) +{ + var onFileRead = function (err, data) {}; + fs.readFile(originalPath, 'utf8', (err, data) => { onFileRead (err,data) }); + + onFileRead = function (err, data) + { + if (err) + throw err; + + data = data.replace("[ADDRESS]", accountName); + fs.writeFile(path, data, (err) => { + if (err) + throw err; + finished(); + }); + } +}, + +readTestsInFolder: function readTestsInFolder(path) +{ + var res = utils.listFiles(path); + res.forEach(function(file) { + var testn = file.indexOf("test"); + var slashn = file.indexOf("_"); + if (testn != -1 && slashn != -1) + { + testNumber = parseInt(file.substring(testn + 4, slashn)); + var noden = file.indexOf("node"); + var slashn = file.indexOf("_", slashn+1); + var tmpFile = file.indexOf("~"); + if (noden != -1 && slashn != -1 && tmpFile == -1) + { + if (tests[testNumber]) + console.log("Error: dublicate test found " + file); + else + { + var testObject = {}; + testObject.file = file; + testObject.node = file.substring(noden + 4, slashn); + tests[testNumber] = testObject; + testCount++; + } + } + } + }); +}, + +getTestCount: function getTestCount() +{ + return testCount; +}, + +getTestNumber: function getTestNumber(n) +{ + if(n < testCount); + return tests[n]; +} + + +}//modules + |