def setUpClass(cls): super(TestUnclosedWhileLoop, cls).setUpClass() # the following script is a simple contract that is basically `while True` cls.script = binascii.unhexlify(b'00c56b620000') settings.set_loglevel(DEBUG)
def configure(self, args): what = get_arg(args) if what == 'debug': c1 = get_arg(args, 1).lower() if c1 is not None: if c1 == 'on' or c1 == '1': print("debug logging is now enabled") settings.set_loglevel(logging.DEBUG) if c1 == 'off' or c1 == '0': print("debug logging is now disabled") settings.set_loglevel(logging.INFO) else: print("cannot configure log. Please specify on or off") elif what == 'sc-events': c1 = get_arg(args, 1).lower() if c1 is not None: if c1 == 'on' or c1 == '1': print("smart contract event logging is now enabled") settings.set_log_smart_contract_events(True) if c1 == 'off' or c1 == '0': print("smart contract event logging is now disabled") settings.set_log_smart_contract_events(False) else: print("cannot configure log. Please specify on or off") else: print("cannot configure %s " % what) print("Try 'config log on/off'")
def test_no_logging_if_loglevel_not_debug(self, mocked_logger): settings.set_loglevel(INFO) tx, results, total_ops, engine = TestBuild(self.script, [1, ['my_arg0']], self.GetWallet1(), '0210', '07') self.assertEqual(0, mocked_logger.call_count)
def configure(self, args): what = get_arg(args) if what == 'debug': c1 = get_arg(args, 1).lower() if c1 is not None: if c1 == 'on' or c1 == '1': print("Debug logging is now enabled") settings.set_loglevel(logging.DEBUG) if c1 == 'off' or c1 == '0': print("Debug logging is now disabled") settings.set_loglevel(logging.INFO) else: print("Cannot configure log. Please specify on|off") elif what == 'sc-events': c1 = get_arg(args, 1).lower() if c1 is not None: if c1 == 'on' or c1 == '1': print("Smart contract event logging is now enabled") settings.set_log_smart_contract_events(True) if c1 == 'off' or c1 == '0': print("Smart contract event logging is now disabled") settings.set_log_smart_contract_events(False) else: print("Cannot configure log. Please specify on|off") elif what == 'sc-debug-notify': c1 = get_arg(args, 1).lower() if c1 is not None: if c1 == 'on' or c1 == '1': print("Smart contract emit Notify events on execution failure is now enabled") settings.set_emit_notify_events_on_sc_execution_error(True) if c1 == 'off' or c1 == '0': print("Smart contract emit Notify events on execution failure is now disabled") settings.set_emit_notify_events_on_sc_execution_error(False) else: print("Cannot configure log. Please specify on|off") elif what == 'vm-log': c1 = get_arg(args, 1).lower() if c1 is not None: if c1 == 'on' or c1 == '1': print("VM instruction execution logging is now enabled") settings.set_log_vm_instruction(True) if c1 == 'off' or c1 == '0': print("VM instruction execution logging is now disabled") settings.set_log_vm_instruction(False) else: print("Cannot configure VM instruction logging. Please specify on|off") elif what == 'maxpeers': try: c1 = int(get_arg(args, 1).lower()) num_peers = int(c1) if num_peers > 0: old_max_peers = settings.CONNECTED_PEER_MAX settings.set_max_peers(num_peers) NodeLeader.Instance().OnUpdatedMaxPeers(old_max_peers, num_peers) print("set max peers to %s " % num_peers) else: print("Please specify integer greater than zero") except Exception as e: print("Cannot configure max peers. Please specify an integer greater than 0") else: print( "Cannot configure %s try 'config sc-events on|off', 'config debug on|off', 'config sc-debug-notify on|off' or 'config vm-log on|off'" % what)
def configure(self, args): what = get_arg(args) if what == 'debug': c1 = get_arg(args, 1).lower() if c1 is not None: if c1 == 'on' or c1 == '1': print("Debug logging is now enabled") settings.set_loglevel(logging.DEBUG) if c1 == 'off' or c1 == '0': print("Debug logging is now disabled") settings.set_loglevel(logging.INFO) else: print("Cannot configure log. Please specify on|off") elif what == 'sc-events': c1 = get_arg(args, 1).lower() if c1 is not None: if c1 == 'on' or c1 == '1': print("Smart contract event logging is now enabled") settings.set_log_smart_contract_events(True) if c1 == 'off' or c1 == '0': print("Smart contract event logging is now disabled") settings.set_log_smart_contract_events(False) else: print("Cannot configure log. Please specify on|off") elif what == 'sc-debug-notify': c1 = get_arg(args, 1).lower() if c1 is not None: if c1 == 'on' or c1 == '1': print( "Smart contract emit Notify events on execution failure is now enabled" ) settings.set_emit_notify_events_on_sc_execution_error(True) if c1 == 'off' or c1 == '0': print( "Smart contract emit Notify events on execution failure is now disabled" ) settings.set_emit_notify_events_on_sc_execution_error( False) else: print("Cannot configure log. Please specify on|off") elif what == 'vm-log': c1 = get_arg(args, 1).lower() if c1 is not None: if c1 == 'on' or c1 == '1': print("VM instruction execution logging is now enabled") settings.set_log_vm_instruction(True) if c1 == 'off' or c1 == '0': print("VM instruction execution logging is now disabled") settings.set_log_vm_instruction(False) else: print( "Cannot configure VM instruction logging. Please specify on|off" ) else: print( "Cannot configure %s try 'config sc-events on|off', 'config debug on|off', 'config sc-debug-notify on|off' or 'config vm-log on|off'" % what)
def setUpClass(cls): super(InteropTest, cls).setUpClass() settings.set_loglevel(DEBUG)
def configure(self, args): what = get_arg(args) if what == 'debug': c1 = get_arg(args, 1) if c1 is not None: c1 = c1.lower() if c1 == 'on' or c1 == '1': print("Debug logging is now enabled") settings.set_loglevel(logging.DEBUG) elif c1 == 'off' or c1 == '0': print("Debug logging is now disabled") settings.set_loglevel(logging.INFO) else: print("Cannot configure log. Please specify on|off") else: print("Cannot configure log. Please specify on|off") elif what == 'sc-events': c1 = get_arg(args, 1) if c1 is not None: c1 = c1.lower() if c1 == 'on' or c1 == '1': print("Smart contract event logging is now enabled") settings.set_log_smart_contract_events(True) elif c1 == 'off' or c1 == '0': print("Smart contract event logging is now disabled") settings.set_log_smart_contract_events(False) else: print("Cannot configure log. Please specify on|off") else: print("Cannot configure log. Please specify on|off") elif what == 'sc-debug-notify': c1 = get_arg(args, 1) if c1 is not None: c1 = c1.lower() if c1 == 'on' or c1 == '1': print( "Smart contract emit Notify events on execution failure is now enabled" ) settings.set_emit_notify_events_on_sc_execution_error(True) elif c1 == 'off' or c1 == '0': print( "Smart contract emit Notify events on execution failure is now disabled" ) settings.set_emit_notify_events_on_sc_execution_error( False) else: print("Cannot configure log. Please specify on|off") else: print("Cannot configure log. Please specify on|off") elif what == 'vm-log': c1 = get_arg(args, 1) if c1 is not None: c1 = c1.lower() if c1 == 'on' or c1 == '1': print("VM instruction execution logging is now enabled") settings.set_log_vm_instruction(True) elif c1 == 'off' or c1 == '0': print("VM instruction execution logging is now disabled") settings.set_log_vm_instruction(False) else: print( "Cannot configure VM instruction logging. Please specify on|off" ) else: print( "Cannot configure VM instruction logging. Please specify on|off" ) elif what == 'node-requests': if len(args) in [2, 3]: if len(args) == 3: NodeLeader.Instance().setBlockReqSizeAndMax( int(args[1]), int(args[2])) elif len(args) == 2: NodeLeader.Instance().setBlockReqSizeByName(args[1]) else: print("Invalid number of arguments") elif what == 'maxpeers': c1 = get_arg(args, 1) if c1 is not None: print("Maxpeers set to ", c1) settings.set_max_peers(c1) else: print("Maintaining current number of maxpeers") elif what == 'compiler-nep8': c1 = get_arg(args, 1) if c1 is not None: c1 = c1.lower() if c1 == 'on' or c1 == '1': print("Compiler NEP8 instructions on") settings.COMPILER_NEP_8 = True elif c1 == 'off' or c1 == '0': print("Compiler NEP8 instructions off") settings.COMPILER_NEP_8 = False else: print( "Cannot configure compiler NEP8 instructions. Please specify on|off" ) else: print( "Cannot configure compiler NEP8 instructions. Please specify on|off" ) else: print( "Cannot configure %s try 'config sc-events on|off', 'config debug on|off', 'config sc-debug-notify on|off', 'config vm-log on|off', config compiler-nep8 on|off, or 'config maxpeers {num_peers}'" % what)
def tearDownClass(cls): super(TestUnclosedWhileLoop, cls).tearDownClass() settings.set_loglevel(INFO)
def setUpClass(cls): super(TestVMErrors, cls).setUpClass() output = Compiler.instance().load('%s/sc_vm_errors.py' % os.path.dirname(__file__)).default cls.script = output.write() settings.set_loglevel(DEBUG)
def configure(self, args): what = get_arg(args) if what == 'debug': c1 = get_arg(args, 1).lower() if c1 is not None: if c1 == 'on' or c1 == '1': print("Debug logging is now enabled") settings.set_loglevel(logging.DEBUG) if c1 == 'off' or c1 == '0': print("Debug logging is now disabled") settings.set_loglevel(logging.INFO) else: print("Cannot configure log. Please specify on|off") elif what == 'sc-events': c1 = get_arg(args, 1).lower() if c1 is not None: if c1 == 'on' or c1 == '1': print("Smart contract event logging is now enabled") settings.set_log_smart_contract_events(True) if c1 == 'off' or c1 == '0': print("Smart contract event logging is now disabled") settings.set_log_smart_contract_events(False) else: print("Cannot configure log. Please specify on|off") elif what == 'sc-debug-notify': c1 = get_arg(args, 1).lower() if c1 is not None: if c1 == 'on' or c1 == '1': print( "Smart contract emit Notify events on execution failure is now enabled" ) settings.set_emit_notify_events_on_sc_execution_error(True) if c1 == 'off' or c1 == '0': print( "Smart contract emit Notify events on execution failure is now disabled" ) settings.set_emit_notify_events_on_sc_execution_error( False) else: print("Cannot configure log. Please specify on|off") elif what == 'vm-log': c1 = get_arg(args, 1).lower() if c1 is not None: if c1 == 'on' or c1 == '1': print("VM instruction execution logging is now enabled") settings.set_log_vm_instruction(True) if c1 == 'off' or c1 == '0': print("VM instruction execution logging is now disabled") settings.set_log_vm_instruction(False) else: print( "Cannot configure VM instruction logging. Please specify on|off" ) elif what == 'maxpeers': try: c1 = int(get_arg(args, 1).lower()) num_peers = int(c1) if num_peers > 0: old_max_peers = settings.CONNECTED_PEER_MAX settings.set_max_peers(num_peers) NodeLeader.Instance().OnUpdatedMaxPeers( old_max_peers, num_peers) print("set max peers to %s " % num_peers) else: print("Please specify integer greater than zero") except Exception as e: print( "Cannot configure max peers. Please specify an integer greater than 0" ) else: print( "Cannot configure %s try 'config sc-events on|off', 'config debug on|off', 'config sc-debug-notify on|off' or 'config vm-log on|off'" % what)