def test_from_tx_with_ctransaction_argument(self): tx = CTransaction() chainparams.set_to_preset('Peercoin') self.assertRaises(AttributeError, getattr, tx, 'Timestamp') tx2 = Transaction.from_tx(tx) self.assertIs(tx.__class__, CTransaction) self.assertEqual(tx2.Timestamp, 0)
def test_from_tx_with_transaction_argument(self): tx = Transaction() chainparams.set_to_preset('Peercoin') self.assertRaises(AttributeError, getattr, tx, 'Timestamp') tx2 = Transaction.from_tx(tx) self.assertIsNot(tx, tx2) self.assertEqual(tx2.Timestamp, 0)
def test_clams_fields(self): chainparams.set_to_preset('Clams') blk = Block.deserialize(clams_raw_block) self.assertEqual(clams_raw_block.encode('hex'), blk.as_hex()) self.assertEqual( '3045022100b4e1b24eff6f0c7945c1cabc2d37ac88df861fe37f9bc22ac3c8594bac58f6f9022044e8dfde90dc28d06ba17d5c2b9b3a65ad1cdc03c3e0f8f5655d1f5b9c8cfa0b', b2x(blk.blockSig))
def change_params(self): # Don't do anything if this is called because we cleared the combobox. if self.currentIndex() < 0: return new_name = str(self.currentText()) # Don't do anything if nothing would really change. if new_name == chainparams.active_preset.name and new_name == self.config.get_option('chainparams', ''): return chainparams.set_to_preset(new_name) self.config.set_option('chainparams', new_name) self.paramsChanged.emit()
def __init__(self, app): super(HashmalMain, self).__init__() self.app = app self.app.setStyleSheet(hashmal_style) self.changes_saved = True # {Qt.DockWidgetArea: [dock0, dock1, ...], ...} self.dock_orders = defaultdict(list) self.setCorner(QtCore.Qt.BottomRightCorner, QtCore.Qt.RightDockWidgetArea) self.config = Config() QtCore.QCoreApplication.setOrganizationName('mazaclub') QtCore.QCoreApplication.setApplicationName('hashmal') self.qt_settings = QtCore.QSettings() active_params = self.config.get_option('chainparams', 'Bitcoin') chainparams.set_to_preset(active_params) self.download_controller = DownloadController() self.setDockNestingEnabled(True) # Plugin Handler loads plugins and handles their dock widgets. self.plugin_handler = PluginHandler(self) self.plugin_handler.load_plugins() self.plugin_handler.do_default_layout() # Filename of script being edited. self.filename = '' # The last text that we saved. self.last_saved = '' self.create_script_editor() # Set up script editor font. script_font = self.qt_settings.value('editor/font', defaultValue=QtCore.QVariant('default')).toString() if script_font == 'default': font = monospace_font else: font = QFont() font.fromString(script_font) self.script_editor.setFont(font) self.create_menubar() self.create_toolbar() self.create_actions() self.new_script() self.statusBar().setVisible(True) self.statusBar().messageChanged.connect(self.change_status_bar) self.restoreState(self.qt_settings.value('toolLayout/default/state').toByteArray()) self.restoreGeometry(self.qt_settings.value('toolLayout/default/geometry').toByteArray()) self.script_editor.setFocus() if self.qt_settings.value('quickTipsOnStart', defaultValue=QtCore.QVariant(True)).toBool(): QtCore.QTimer.singleShot(500, self.do_quick_tips)
def __init__(self, app): super(HashmalMain, self).__init__() self.app = app self.app.setStyleSheet(hashmal_style) self.changes_saved = True # {Qt.DockWidgetArea: [dock0, dock1, ...], ...} self.dock_orders = defaultdict(list) self.config = Config() QtCore.QCoreApplication.setOrganizationName('mazaclub') QtCore.QCoreApplication.setApplicationName('hashmal') self.qt_settings = QtCore.QSettings() active_params = self.config.get_option('chainparams', 'Bitcoin') chainparams.set_to_preset(active_params) self.setDockNestingEnabled(True) # Plugin Handler loads plugins and handles their dock widgets. self.plugin_handler = PluginHandler(self) self.plugin_handler.load_plugins() self.plugin_handler.do_default_layout() # Filename of script being edited. self.filename = '' # The last text that we saved. self.last_saved = '' self.create_script_editor() # Set up script editor font. script_font = self.qt_settings.value( 'editor/font', defaultValue=QtCore.QVariant('default')).toString() if script_font == 'default': font = monospace_font else: font = QFont() font.fromString(script_font) self.script_editor.setFont(font) self.create_menubar() self.create_toolbar() self.create_actions() self.new_script() self.statusBar().setVisible(True) self.statusBar().messageChanged.connect(self.change_status_bar) self.restoreState( self.qt_settings.value('toolLayout/default').toByteArray()) self.script_editor.setFocus() if self.qt_settings.value('quickTipsOnStart', defaultValue=QtCore.QVariant(True)).toBool(): QtCore.QTimer.singleShot(500, self.do_quick_tips)
def test_preset_chainparams(self): chainparams.set_to_preset('Bitcoin') tx = Transaction.deserialize(maza_raw_tx) self.assertRaises(Exception, Transaction.deserialize, clams_raw_tx) self.assertRaises(Exception, Transaction.deserialize, ppc_raw_tx) chainparams.set_to_preset('Clams') tx = Transaction.deserialize(clams_raw_tx) self.assertRaises(Exception, Transaction.deserialize, maza_raw_tx) chainparams.set_to_preset('Peercoin') tx = Transaction.deserialize(ppc_raw_tx) self.assertRaises(Exception, Transaction.deserialize, clams_raw_tx) self.assertRaises(Exception, Transaction.deserialize, maza_raw_tx)
def setUp(self): super(TransactionTest, self).setUp() chainparams.set_to_preset('Bitcoin')
def setUp(self): super(TransactionTest, self).setUp() chainparams.set_to_preset("Decred")
def setUp(self): super(BlockTest, self).setUp() chainparams.set_to_preset('Bitcoin')
def __init__(self, app): super(HashmalMain, self).__init__() self.app = app self.app.setStyleSheet(hashmal_style()) self.changes_saved = True # {Qt.DockWidgetArea: [dock0, dock1, ...], ...} self.dock_orders = defaultdict(list) self.setCorner(QtCore.Qt.BottomRightCorner, QtCore.Qt.RightDockWidgetArea) self.config = Config() self.init_logger() self.config.optionChanged.connect(self.on_option_changed) QtCore.QCoreApplication.setOrganizationName('mazaclub') QtCore.QCoreApplication.setApplicationName('hashmal') self.qt_settings = QtCore.QSettings() active_params = self.config.get_option('chainparams', 'Bitcoin') # True if chainparams needs to be set after plugins load. needs_params_change = False # An exception is thrown if the last-active chainparams preset # only exists due to a plugin that defines it. try: chainparams.set_to_preset(active_params) except KeyError: chainparams.set_to_preset('Bitcoin') needs_params_change = True self.download_controller = DownloadController() self.setDockNestingEnabled(True) # Plugin Handler loads plugins and handles their dock widgets. self.plugin_handler = PluginHandler(self) self.plugin_handler.load_plugins() self.plugin_handler.do_default_layout() # Attempt to load chainparams preset again if necessary. if needs_params_change: try: chainparams.set_to_preset(active_params) except KeyError: self.log_message( 'Core', 'Chainparams preset "%s" does not exist. Setting chainparams to Bitcoin.', logging.ERROR) self.config.set_option('chainparams', 'Bitcoin') # Filename of script being edited. self.filename = '' # The last text that we saved. self.last_saved = '' self.create_script_editor() # Set up script editor font. script_font = self.qt_settings.value( 'editor/font', defaultValue=QtCore.QVariant('default')).toString() if script_font == 'default': font = monospace_font else: font = QFont() font.fromString(script_font) self.script_editor.setFont(font) self.settings_dialog = SettingsDialog(self) self.create_menubar() self.create_toolbar() self.create_actions() self.new_script() self.statusBar().setVisible(True) self.statusBar().messageChanged.connect(self.change_status_bar) self.restoreState( self.qt_settings.value('toolLayout/default/state').toByteArray()) self.restoreGeometry( self.qt_settings.value( 'toolLayout/default/geometry').toByteArray()) self.script_editor.setFocus() if self.qt_settings.value('quickTipsOnStart', defaultValue=QtCore.QVariant(True)).toBool(): QtCore.QTimer.singleShot(500, self.do_quick_tips)
def __init__(self, app): super(HashmalMain, self).__init__() self.app = app self.app.setStyleSheet(hashmal_style()) self.changes_saved = True # {Qt.DockWidgetArea: [dock0, dock1, ...], ...} self.dock_orders = defaultdict(list) self.setCorner(QtCore.Qt.BottomRightCorner, QtCore.Qt.RightDockWidgetArea) self.config = Config() self.init_logger() self.config.optionChanged.connect(self.on_option_changed) QtCore.QCoreApplication.setOrganizationName('mazaclub') QtCore.QCoreApplication.setApplicationName('hashmal') self.qt_settings = QtCore.QSettings() active_params = self.config.get_option('chainparams', 'Bitcoin') # True if chainparams needs to be set after plugins load. needs_params_change = False # An exception is thrown if the last-active chainparams preset # only exists due to a plugin that defines it. try: chainparams.set_to_preset(active_params) except KeyError: chainparams.set_to_preset('Bitcoin') needs_params_change = True self.download_controller = DownloadController() self.setDockNestingEnabled(True) # Plugin Handler loads plugins and handles their dock widgets. self.plugin_handler = PluginHandler(self) self.plugin_handler.load_plugins() self.plugin_handler.do_default_layout() # Attempt to load chainparams preset again if necessary. if needs_params_change: try: chainparams.set_to_preset(active_params) except KeyError: self.log_message('Core', 'Chainparams preset "%s" does not exist. Setting chainparams to Bitcoin.', logging.ERROR) self.config.set_option('chainparams', 'Bitcoin') # Filename of script being edited. self.filename = '' # The last text that we saved. self.last_saved = '' self.create_script_editor() # Set up script editor font. script_font = self.qt_settings.value('editor/font', defaultValue=QtCore.QVariant('default')).toString() if script_font == 'default': font = monospace_font else: font = QFont() font.fromString(script_font) self.script_editor.setFont(font) self.settings_dialog = SettingsDialog(self) self.create_menubar() self.create_toolbar() self.create_actions() self.new_script() self.statusBar().setVisible(True) self.statusBar().messageChanged.connect(self.change_status_bar) self.restoreState(self.qt_settings.value('toolLayout/default/state').toByteArray()) self.restoreGeometry(self.qt_settings.value('toolLayout/default/geometry').toByteArray()) self.script_editor.setFocus() if self.qt_settings.value('quickTipsOnStart', defaultValue=QtCore.QVariant(True)).toBool(): QtCore.QTimer.singleShot(500, self.do_quick_tips)
def test_chainparams_tx_serializer(self): chainparams.set_to_preset('Clams') tx = Transaction.deserialize(clams_raw_tx) self.assertEqual(clams_raw_tx, tx.serialize()) tx2 = Transaction.deserialize(clams_v1_raw_tx) self.assertEqual(clams_v1_raw_tx, tx2.serialize())
def test_clams_fields(self): chainparams.set_to_preset('Clams') blk = Block.deserialize(clams_raw_block) self.assertEqual(clams_raw_block.encode('hex'), blk.as_hex()) self.assertEqual('3045022100b4e1b24eff6f0c7945c1cabc2d37ac88df861fe37f9bc22ac3c8594bac58f6f9022044e8dfde90dc28d06ba17d5c2b9b3a65ad1cdc03c3e0f8f5655d1f5b9c8cfa0b', b2x(blk.blockSig))
def setUp(self): chainparams.set_to_preset('Bitcoin')
def change_params(self): new_name = str(self.currentText()) chainparams.set_to_preset(new_name) self.config.set_option('chainparams', new_name) self.paramsChanged.emit()
import unittest, sys, __builtin__ from PyQt4.QtGui import QApplication from PyQt4.QtCore import Qt from PyQt4.QtTest import QTest from hashmal_lib.core import chainparams from hashmal_lib.main_window import HashmalMain __builtin__.use_local_modules = False app = QApplication(sys.argv) chainparams.set_to_preset('Bitcoin') class TxAnalyzerTest(unittest.TestCase): @classmethod def setUpClass(cls): cls.gui = HashmalMain(app) cls.gui.testing_mode = True @classmethod def tearDownClass(cls): cls.gui.close() def setUp(self): self.ui = self.gui.plugin_handler.get_plugin('Transaction Analyzer').ui self.params_changer = self.gui.settings_dialog.params_combo self._set_chainparams('Bitcoin')