Beispiel #1
0
 def run_ssh(self, ssh, cmd, password=None):
     """
     执行ssh命令,sudo -S -p '' cmd 时,可以添加password字段
     :param ssh: 连接对象
     :param cmd: 需要执行的命令
     :param password: 密码,或者后续输入
     :return:
     """
     return run_ssh(ssh, cmd, password)
 def setup_class(self):
     self.auto.start_all_node(self.node_yml,
                              genesis_file=conf.GENESIS_TMP,
                              static_node_file=conf.STATIC_NODE_FILE)
     # 等一下,同步块高
     collusion, _ = get_node_list(conf.NODE_YML)
     collusion_w3 = connect_web3(collusion[0]["url"])
     collusion_block = collusion_w3.eth.blockNumber
     _, nocollusion = get_node_list(self.node_yml)
     self.url = nocollusion[0]['url']
     self.ip = nocollusion[0]["host"]
     self.wt = PlatonContractTransaction(self.url)
     self.password = conf.PASSWORD
     nocollusion_block = self.wt.eth.blockNumber
     if collusion_block - nocollusion_block >= 100:
         time.sleep(20)
     elif 100 > collusion_block - nocollusion_block >= 50:
         time.sleep(10)
     else:
         time.sleep(5)
     addrress = self.wt.w3.toChecksumAddress(conf.ADDRESS)
     self.wt.w3.personal.unlockAccount(addrress, self.password, 999999)
     """部署合约"""
     resp = self.wt.contract_deploy(
         get_byte_code(abspath('./data/contract/vccMain.wasm')),
         get_abi_bytes(abspath(r'./data/contract/vccMain.cpp.abi.json')),
         addrress)
     result = self.wt.eth.waitForTransactionReceipt(resp)
     self.contract_address = result['contractAddress']
     log.info(self.contract_address)
     if len(self.wt.eth.getCode(self.contract_address)) < 10:
         raise Exception("合约部署失败")
     node = nocollusion[0]
     ssh, sftp, t = connect_linux(node['host'],
                                  username=node['username'],
                                  password=node['password'])
     pwd_list = run_ssh(ssh, "pwd")
     pwd = pwd_list[0].strip("\r\n")
     account = 'UTC--2018-10-04T09-02-39.439063439Z--493301712671ada506ba6ca7891f436d29185821'
     self.wallet_path = '{}/{}/data16789/keystore/{}'.format(
         pwd, conf.DEPLOY_PATH, account)
     cmd = '''nohup java -jar ./vc_tool/vctool-1.0.jar  > ./vc_tool/nohup.out 2>&1 &'''
     run_ssh(ssh, cmd)
     self.get_url = 'http://{}:8112/test/getResult'.format(self.ip)
 def test_platon_versions(self):
     collusion_list, _ = get_node_list(self.node_yml)
     node = collusion_list[0]
     ssh, sftp, t = connect_linux(node['host'],
                                  username=node['username'],
                                  password=node['password'])
     cmd_list = run_ssh(
         ssh, "{}/node-{}/platon version".format(conf.DEPLOY_PATH,
                                                 node["port"]))
     versions = conf.VERSION
     assert versions in cmd_list[1], "版本号不正确"
Beispiel #4
0
 def run_ssh(self, cmd, need_password=False):
     if need_password:
         return run_ssh(self.ssh, cmd, self.password)
     return run_ssh(self.ssh, cmd)
Beispiel #5
0
def file_is_exist(ssh, path, file_name):
    cmd_list = run_ssh(ssh, "find {} -name {}".format(path, file_name))
    if len(cmd_list) > 0:
        return file_name in cmd_list[0]
    return False