def getTests(self, path): content = listdir(path) tests = [] for file in content: if isfile(path + '/' + file) and re.fullmatch( '[a-zA-Z0-9.]*Test.py', file): test = file[:-3] if self.skipTest(test): eprint("Skipped test: " + test) else: tests.append(test) eprint("Found test: " + test) return tests
def prepareExecutables(self): args, unknown = self.argParser.parse_known_args() self.skip = args.skip self.contractsManager = ContractsManager(args.contracts) self.apiClient = ApiClient("127.0.0.1", 8888, args.apiClientDialog) if args.nodeos == None: return args, unknown eprint("Starting a nodeos instance...") self.nodeos = Nodeos(args.nodeos, args.mongo, args.nodeosOutput) atexit.register(self.nodeos.stop) eprint("The nodeos is ready") return args, unknown
def sendRequest(self, function, params): requestUrl = self.url + function jsonParams = json.dumps(params) if self.apiClientDialog == True: eprint(requestUrl + " " + jsonParams) response = requests.post(url=requestUrl, data=jsonParams) if response.status_code == 200 or response.status_code == 202: object = json.loads(response.content) if self.apiClientDialog == True: eprint(object) return object raise NameError("The request executed with error: " + str(json.loads(response.content)))
def startNodeos(self, path, mongo): self.nodeos = subprocess.Popen([ path, '--chaindb_address', "mongodb://" + mongo, "--contracts-console", "--config-dir", self.workingDir, "-d", self.dataDir, "-e", "--producer-name", "cyber", "--plugin", "eosio::chain_api_plugin" ], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) for line in self.nodeos.stdout: stringLine = line.decode("UTF-8") if self.enableOutput == True: eprint(stringLine) if "Produced block" in stringLine: return
def runUnitTests(self, args): sys.argv = [sys.argv[0]] sys.argv.extend(args) suites = [] for test in self.tests: try: suites.append( (test, unittest.defaultTestLoader.loadTestsFromName(test))) except ModuleNotFoundError: eprint("Could not execute test: " + test) testRunner = unittest.TextTestRunner( resultclass=unittest.TextTestResult) successful = True for testName, suite in suites: eprint("Starting test: " + testName) result = testRunner.run(suite) successful = successful and result.wasSuccessful() return successful
def exec(self, params): execTuple = (self.path, '-u', "http://" + self.remoteHost) + tuple( shlex.split(params)) if self.printDialog == True: self.showCommand(execTuple) cleos = subprocess.Popen(execTuple, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) output = [] for line in cleos.stdout: stringLine = line.decode("UTF-8") if self.printDialog == True: eprint(stringLine) output.append(stringLine) cleos.stdout.close() cleos.wait() return output
def prepareExecutables(self): args, unknown = CleosTestSuite.prepareExecutables(self) eprint("Preparing a wallet...") self.wallet = Wallet(self.cleos) eprint("The wallet is ready") return args, unknown
def showCommand(self, execTuple): printString = "" for element in execTuple: printString += element + " " eprint(printString)