def test_CMD_007(account_env): node, env = account_env log.info(node.node_mark) return_list = run_ssh_cmd( node.ssh, "{} account list --datadir {}".format(node.remote_bin_file, node.remote_data_dir)) old_counts = len(return_list) - 1 remote_key_file = node.remote_keystore_dir + "/key1.pri" node.upload_file("./deploy/key1.pri", remote_key_file) run_ssh_cmd( node.ssh, "{} account import {} --datadir {}".format(node.remote_bin_file, remote_key_file, node.remote_data_dir), "88888888", "88888888") time.sleep(2) return_list2 = run_ssh_cmd( node.ssh, "{} account list --datadir {}".format(node.remote_bin_file, node.remote_data_dir)) new_counts = len(return_list2) - 1 assert old_counts + 1 == new_counts
def test_CMD_008(account_env): node, env = account_env return_list = run_ssh_cmd( node.ssh, "{} account list --keystore {}".format(node.remote_bin_file, node.remote_keystore_dir)) old_counts = len(return_list) - 1 remote_key_file = node.remote_keystore_dir + "/key4.pri" node.upload_file("./deploy/file.key4.pri", remote_key_file) run_ssh_cmd( node.ssh, "{} account import {} --keystore {} --password {}".format( node.remote_bin_file, remote_key_file, node.remote_keystore_dir, env.remote_pwd_file)) time.sleep(0.2) return_list2 = run_ssh_cmd( node.ssh, "{} account list --keystore {}".format(node.remote_bin_file, node.remote_keystore_dir)) new_counts = len(return_list2) - 1 assert old_counts + 1 == new_counts
def test_CMD_025(global_test_env): global_env = global_test_env node = global_env.consensus_node_list[0] node.stop() # dump export_list = run_ssh_cmd( node.ssh, "sudo -S -p '' {} export-preimages exportPreImage --datadir {}".format( node.remote_bin_file, node.remote_data_dir), node.password) for i in range(len(export_list)): log.info("Serial number:{} result:{}".format(i, export_list[i])) time.sleep(1) import_list = run_ssh_cmd( node.ssh, "sudo -S -p '' {} import-preimages exportPreImage --datadir {}".format( node.remote_bin_file, node.remote_data_dir), node.password) node.start(False) for i in range(len(import_list)): log.info("Serial number:{} result:{}".format(i, import_list[i])) assert len(export_list) == 1 assert len(import_list) == 1
def test_CMD_010_CMD_034(account_env): node, env = account_env return_list = run_ssh_cmd( node.ssh, "{} account list --keystore {}".format(node.remote_bin_file, node.remote_keystore_dir)) old_counts = len(return_list) - 1 remote_key_file = node.remote_keystore_dir + "/key.pri_2" node.upload_file("./deploy/key.pri_2", remote_key_file) run_ssh_cmd( node.ssh, "{} account import {} --keystore {}".format(node.remote_bin_file, remote_key_file, node.remote_keystore_dir), "88888888", "88888888") time.sleep(0.2) return_list2 = run_ssh_cmd( node.ssh, "{} account list --keystore {}".format(node.remote_bin_file, node.remote_keystore_dir)) new_counts = len(return_list2) - 1 assert old_counts + 1 == new_counts
def test_CMD_004(account_env): node, env = account_env return_list = run_ssh_cmd(node.ssh, "{} account list --keystore {}".format(node.remote_bin_file, node.remote_keystore_dir)) old_counts = len(return_list) - 1 run_ssh_cmd(node.ssh, "{} account new --keystore {}".format(node.remote_bin_file, node.remote_keystore_dir), "88888888", "88888888") time.sleep(0.2) return_list2 = run_ssh_cmd(node.ssh, "{} account list --keystore {}".format(node.remote_bin_file, node.remote_keystore_dir)) new_counts = len(return_list2) - 1 assert old_counts + 1 == new_counts
def test_CMD_011(account_env): node, env = account_env return_list1 = run_ssh_cmd(node.ssh, "{} account list --datadir {}".format(node.remote_bin_file, node.remote_data_dir)) counts1 = len(return_list1) - 1 return_list2 = run_ssh_cmd(node.ssh, "{} account list --keystore {}".format(node.remote_bin_file, node.remote_keystore_dir)) counts2 = len(return_list2) - 1 assert counts1 == counts2
def test_CMD_003_2(account_env): node, env = account_env return_list = run_ssh_cmd(node.ssh, "{} account list --datadir {}".format(node.remote_bin_file, node.remote_data_dir)) old_counts = len(return_list) - 1 run_ssh_cmd(node.ssh, "{} account new --datadir {} --password {}".format(node.remote_bin_file, node.remote_data_dir, env.remote_pwd_file)) time.sleep(0.2) return_list2 = run_ssh_cmd(node.ssh, "{} account list --datadir {}".format(node.remote_bin_file, node.remote_data_dir)) new_counts = len(return_list2) - 1 assert old_counts + 1 == new_counts
def test_CMD_033_CMD_034(global_test_env): global_env = global_test_env node = global_env.consensus_node_list[0] node.stop() run_ssh_cmd(node.ssh, "sed -i 's/\"NetworkId\": 1/\"NetworkId\": 111/g' {}".format(node.remote_config_file)) node.start(False) time.sleep(2) ret = node.admin.nodeInfo # print(ret) assert ret["protocols"]["platon"]["network"] == 111
def test_CMD_018(global_test_env): global_env = global_test_env node = global_env.consensus_node_list[0] # dump returnList = run_ssh_cmd(node.ssh, "{} --nodekey {} --cbft.blskey {} dumpconfig".format(node.remote_bin_file, node.remote_nodekey_file, node.remote_blskey_file)) assert returnList[0].strip() == '[Eth]'
def test_NE_P2P_002(global_test_env): log.info("Automatic discovery configuration test") all_node = global_test_env.get_all_nodes() # stop node if global_test_env.running: global_test_env.stop_all() # modify config file config_data = LoadFile(global_test_env.cfg.config_json_tmp).get_data() config_data['node']['P2P']['NoDiscovery'] = True with open(global_test_env.cfg.config_json_tmp, 'w', encoding='utf-8') as f: f.write(json.dumps(config_data, indent=4)) all_node = global_test_env.get_all_nodes() # upload config file global_test_env.executor(one_put_config_task, all_node) # start node global_test_env.cfg.init_chain = False global_test_env.start_all() # run ssh for node in all_node: cmd_list = run_ssh_cmd(node.ssh, "netstat -unlp | grep 16789 |wc -l") assert 0 == int(cmd_list[0][0])
def test_NE_P2P_001(global_test_env): log.info("Node maximum link quantity test") all_node = global_test_env.get_all_nodes() # stop node if global_test_env.running: global_test_env.stop_all() # modify config file config_data = LoadFile(global_test_env.cfg.config_json_tmp).get_data() config_data['node']['P2P']['MaxPeers'] = 2 with open(global_test_env.cfg.config_json_tmp, 'w', encoding='utf-8') as f: f.write(json.dumps(config_data, indent=4)) # upload config file global_test_env.executor(one_put_config_task, all_node) # start node global_test_env.cfg.init_chain = False global_test_env.start_all() # run ssh static_number = len(global_test_env.get_static_nodes()) for node in all_node: cmd_list = run_ssh_cmd(node.ssh, "netstat -an | grep 16789 | grep ESTABLISHED |wc -l") assert int(cmd_list[0][0]) <= 2 + static_number
def test_CMD_019(global_test_env): global_env = global_test_env node = global_env.consensus_node_list[0] # dump return_list = run_ssh_cmd(node.ssh, "{} --nodekey {} --cbft.blskey {} dumpconfig --networkid 1500".format(node.remote_bin_file, node.remote_nodekey_file, node.remote_blskey_file)) assert return_list[1].strip() == 'NetworkId = 1500'
def test_CMD_026(global_test_env): global_env = global_test_env node = global_env.consensus_node_list[0] return_list = run_ssh_cmd(node.ssh, "{} license".format(node.remote_bin_file)) # for i in range(len(returnList)): # log.info("Serial number:{} result:{}".format(i, returnList[i])) assert return_list[0].strip() == "platon is free software: you can redistribute it and/or modify"
def test_CMD_016(global_test_env): global_env = global_test_env node = global_env.consensus_node_list[0] log.info("test copydb on host: {}".format(node.host)) node.stop() # copy deploy data to bak bakremote_data_dir = node.remote_node_path + "/data_bak" run_ssh_cmd( node.ssh, "sudo -S -p '' cp -r {} {}".format(node.remote_data_dir, bakremote_data_dir), node.password) run_ssh_cmd(node.ssh, "sudo -S -p '' rm -rf {}/platon".format(node.remote_data_dir), node.password) # run_ssh_cmd(node.ssh, "sudo -S -p '' rm -rf {}/platon/chaindata".format(node.remote_data_dir), node.password) # re-init run_ssh_cmd( node.ssh, "sudo -S -p '' {} init {} --datadir {}".format( node.remote_bin_file, node.remote_genesis_file, node.remote_data_dir), node.password) time.sleep(10) # copyDb from bak run_ssh_cmd( node.ssh, "sudo -S -p '' {} copydb {}/platon/chaindata/ {}/platon/snapshotdb/ --datadir {}" .format(node.remote_bin_file, bakremote_data_dir, bakremote_data_dir, node.remote_data_dir), node.password) time.sleep(10) node.start(False) time.sleep(5) blockNumber = node.run_ssh("{} attach {} --exec platon.blockNumber".format( node.remote_bin_file, node.url)) for i in range(len(blockNumber)): print("Serial number:{}".format(i), "result:{}".format(blockNumber[i])) bn = int(blockNumber[0]) assert is_integer(bn) assert bn > 0
def test_CMD_029(global_test_env): global_env = global_test_env node = global_env.consensus_node_list[0] return_list = run_ssh_cmd(node.ssh, "{} version".format(node.remote_bin_file)) # for i in range(len(returnList)): # log.info("Serial number:{} Result: {}".format(i, returnList[i])) assert return_list[0].strip() == "PlatON" assert "Version:" in return_list[1]
def test_CMD_005(account_env): node, env = account_env returnList = run_ssh_cmd( node.ssh, "{} account update {} --datadir {}".format(node.remote_bin_file, env.remote_account_address, node.remote_data_dir), "88888888", "88888888", "88888888") log.info(f'returnList is {returnList}') assert len(returnList) == 6 assert returnList[5].strip() == "Repeat passphrase:"
def test_CMD_006(account_env): node, env = account_env returnList = run_ssh_cmd( node.ssh, "{} account update {} --keystore {}".format(node.remote_bin_file, env.remote_account_address, node.remote_keystore_dir), "88888888", "88888888", "88888888") assert len(returnList) == 6 assert returnList[5].strip() == "Repeat passphrase:"
def test_CMD_017(global_test_env): global_env = global_test_env node = global_env.consensus_node_list[0] node.stop() # dump return_list = run_ssh_cmd(node.ssh, "sudo -S -p '' {} --datadir {} dump 0".format(node.remote_bin_file, node.remote_data_dir), node.password) node.start(False) assert len(return_list) > 0 and "root" in return_list[1]