diff --git a/libs/actions.py b/libs/actions.py index b99cd30..938e47f 100644 --- a/libs/actions.py +++ b/libs/actions.py @@ -15,6 +15,7 @@ def login(url, pr_key, role=0, ecosystem=1): token, uid = api.getuid(url) + print('UID: ', uid) result = api.login( url=url, token=token, @@ -70,6 +71,7 @@ def tx_status(url, sleep_time, hsh, jvt_token): time.sleep(1) resp = api.tx_status(url, jvt_token, hsh) jresp = resp['results'][hsh] + print(jresp) if (len(jresp['blockid']) > 0 and 'errmsg' not in json.dumps(jresp)) or ('errmsg' in json.dumps(jresp)): break else: @@ -79,6 +81,7 @@ def tx_status(url, sleep_time, hsh, jvt_token): if 'errmsg' not in jresp and int(jresp['blockid']) > 0: return {'blockid': int(jresp['blockid']), 'result': jresp['result'], 'error': None} else: + print('error in block', jresp['errmsg']['error']) return {'blockid': 0, 'error': jresp['errmsg']['error'], 'result': None} def is_sync(config, wait_time, nodes): diff --git a/libs/api.py b/libs/api.py index 8416823..1432121 100644 --- a/libs/api.py +++ b/libs/api.py @@ -55,8 +55,9 @@ def getuid(url): def login(url, token, uid, private_key, role_id=0, ecosystem=1, expire=3600): - + print('net_id: ', tools.read_config('test')['networkID']) signature = sign(private_key, 'LOGIN' + tools.read_config('test')['networkID'] + uid) + print("Private_key", private_key) pubkey = get_public_key(private_key) full_token = 'Bearer ' + token data = { diff --git a/libs/check.py b/libs/check.py index a1112f7..b359623 100644 --- a/libs/check.py +++ b/libs/check.py @@ -50,6 +50,7 @@ def compare_nodes(config): def is_tx_in_block(url, wait, tx, token): status = actions.tx_status(url, wait, tx['hash'], token) + print('status: ', status) if status['blockid'] > 0: return status['blockid'] else: diff --git a/libs/tools.py b/libs/tools.py index e688059..b54316d 100644 --- a/libs/tools.py +++ b/libs/tools.py @@ -39,17 +39,27 @@ def generate_code(contract_name, source_code): def read_config(type): path = '' - if type == 'main': - path = os.path.join(os.getcwd(), 'config.json') - if type == 'nodes': - path = os.path.join(os.getcwd(), 'nodesConfig.json') - if type == 'nodes_ex': - path = os.path.join(os.getcwd(), 'nodesConfig_ex.json') if type == 'test': - path = os.path.join(os.getcwd(), 'testConfig.json') - with open(path, 'r') as f: - data = f.read() - return json.loads(data) + path1 = os.path.join(os.getcwd(), 'testConfig.json') + path2 = os.path.join(os.getcwd(), 'testConfig.default.json') + with open(path1, 'r') as f1: + data1 = f1.read() + conf = json.loads(data1) + with open(path2, 'r') as f2: + data2 = f2.read() + conf_d = json.loads(data2) + conf_d.update(conf) + return conf_d + else: + if type == 'main': + path = os.path.join(os.getcwd(), 'config.json') + if type == 'nodes': + path = os.path.join(os.getcwd(), 'nodesConfig.json') + if type == 'nodes_ex': + path = os.path.join(os.getcwd(), 'nodesConfig_ex.json') + with open(path, 'r') as f: + data = f.read() + return json.loads(data) def write_config(new_conf): diff --git a/link_nodes_x.py b/link_nodes_x.py index 5fbbd7d..2153e55 100644 --- a/link_nodes_x.py +++ b/link_nodes_x.py @@ -9,15 +9,14 @@ if __name__ == '__main__': log.info('Start ' + __name__) + config = tools.read_config('test') + print('TestConfig: ', config) wait = tools.read_config('test')['wait_tx_status'] conf = tools.read_config('nodes') url = conf[0]['url'] pr_key1 = conf[0]['private_key'] pr_key2 = conf[1]['private_key'] pr_key3 = conf[2]['private_key'] - test_config = tools.read_config('test') - test_config.update({'net_work': 'xreg'}) - tools.write_config(test_config) data = actions.login(url, pr_key1, 0) token1 = data['jwtToken'] actions.imp_app('system', url, pr_key1, token1, data['account']) @@ -34,6 +33,7 @@ print("Strt update full_nodes") data = {'Name': 'full_nodes', 'Value': full_nodes} res = actions.call_contract(url, pr_key1, 'UpdateSysParam', data, token1) + print('here') if check.is_tx_in_block(url, wait, {'hash': res}, token1): log.info('Nodes successfully linked') else: diff --git a/scripts/run_three_nodes.py b/scripts/run_three_nodes.py index 7863af2..01991a1 100644 --- a/scripts/run_three_nodes.py +++ b/scripts/run_three_nodes.py @@ -44,7 +44,7 @@ parser.add_argument('-test', default='true') parser.add_argument('-wait', default='3') parser.add_argument('-private', default='true') - +parser.add_argument('-net_type', default='cn') args = parser.parse_args() @@ -66,6 +66,7 @@ # Set centrifugo variables centrifugo_secret = '4597e75c-4376-42a6-8c1f-7e3fc7eb2114' +centKey = '123456' centrifugo_url = 'http://127.0.0.1:8000' cenConfig = os.path.join(args.centrifugo, 'config.json') cenPath = os.path.join(args.centrifugo, 'centrifugo') @@ -74,6 +75,7 @@ # Create config for centrifugo cen_config_string = { 'secret': centrifugo_secret, + "api_key": centKey, 'admin_secret': 'admin' } with open(cenConfig, 'w') as cen_conf_file: @@ -110,6 +112,7 @@ '--dbUser='+args.dbUser, '--centUrl='+centrifugo_url, '--centSecret='+centrifugo_secret, + '--centKey='+centKey, '--tcpPort='+args.tcpPort1, '--httpPort='+args.httpPort1, '--dbName='+args.dbName1, @@ -174,6 +177,7 @@ '--dbPassword='+args.dbPassword, '--centUrl='+centrifugo_url, '--centSecret='+centrifugo_secret, + '--centKey='+centKey, '--nodesAddr='+'127.0.0.1:'+args.tcpPort1, '--mpgt=2000', '--networkID=130186', @@ -206,6 +210,7 @@ '--dbPassword='+args.dbPassword, '--centUrl='+centrifugo_url, '--centSecret='+centrifugo_secret, + '--centKey='+centKey, '--nodesAddr='+'127.0.0.1:'+args.tcpPort1, '--mpgt=2000', '--networkID=130186', @@ -338,11 +343,17 @@ } }] -# Update config for tests +# Update configs for tests confPath = os.path.join(curDir + '/../', 'nodesConfig.json') +confTestPath = os.path.join(curDir + '/../', 'testConfig.json') with open(confPath, 'w') as fconf: fconf.write(json.dumps(config, indent=4)) log.info('Updated file nodesConfig.json') +testConf = {"net_work": args.net_type} +with open(confTestPath, 'w') as tconf: + tconf.write(json.dumps(testConf, indent=4)) +log.info('Updated file testConfig.json') + log.info('Nodes successfully started') diff --git a/testConfig.json b/testConfig.default.json similarity index 100% rename from testConfig.json rename to testConfig.default.json