예제 #1
0
def test_proposal_is_deletable(proposal):
    now = misc.now()
#    assert proposal.is_deletable() is False

    proposal.end_epoch = now - (86400 * 29)
#    assert proposal.is_deletable() is False

    # add a couple seconds for time variance
    proposal.end_epoch = now - ((86400 * 30) + 2)
예제 #2
0
파일: models.py 프로젝트: snw1/sentinel
    def is_expired(self):
        printdbg("In Proposal#is_expired, for Proposal: %s" % self.__dict__)
        now = misc.now()
        printdbg("\tnow = %s" % now)

        # end date < current date
        if (self.end_epoch <= now):
            printdbg("\tProposal end_epoch [%s] <= now [%s] , returning True" % (self.end_epoch, now))
            return True

        printdbg("Leaving Proposal#is_expired, Expired = False")
        return False
예제 #3
0
def test_superblock_size_limit(go_list_proposals):
    import zeroonelib
    import misc
    from zerooned import ZeroOneDaemon
    zerooned = ZeroOneDaemon.from_zeroone_conf(config.zeroone_conf)
    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_zerooned(zerooned, item)

    max_budget = 60
    prop_list = Proposal.approved_and_ranked(proposal_quorum=1, next_superblock_max_budget=max_budget)

    maxgovobjdatasize = 469
    sb = zeroonelib.create_superblock(prop_list, 72000, max_budget, misc.now(), maxgovobjdatasize)
예제 #4
0
def test_proposal_is_expired(proposal):
    cycle = 24  # testnet
    now = misc.now()

    proposal.start_epoch = now - (86400 * 2)  # two days ago
    proposal.end_epoch = now - (60 * 60)  # expired one hour ago
    assert proposal.is_expired(governanceblockcycle=cycle) is False

    # fudge factor + a 24-block cycle == an expiry window of 9086, so...
    proposal.end_epoch = now - 9085
    assert proposal.is_expired(governanceblockcycle=cycle) is False

    proposal.end_epoch = now - 9087
    assert proposal.is_expired(governanceblockcycle=cycle) is True
예제 #5
0
def test_deterministic_superblock_creation(go_list_proposals):
    import pyrklib
    import misc
    from pyrkd import PyrkDaemon
    pyrkd = PyrkDaemon.from_pyrk_conf(config.pyrk_conf)
    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_pyrkd(pyrkd, item)

    max_budget = 60
    prop_list = Proposal.approved_and_ranked(
        proposal_quorum=1, next_superblock_max_budget=max_budget)
    print prop_list

    sb = pyrklib.create_superblock(prop_list, 72000, max_budget, misc.now())
예제 #6
0
def test_proposal_is_expired(proposal):
    cycle = 24  # testnet
    now = misc.now()

    proposal.start_epoch = now - (86400 * 2)  # two days ago
    proposal.end_epoch = now - (60 * 60)  # expired one hour ago
    assert proposal.is_expired(superblockcycle=cycle) is False

    # fudge factor + a 24-block cycle == an expiry window of 8280, so...
    proposal.end_epoch = now - 8279
    assert proposal.is_expired(superblockcycle=cycle) is False

    proposal.end_epoch = now - 8281
    assert proposal.is_expired(superblockcycle=cycle) is True
예제 #7
0
def test_deterministic_superblock_creation(go_list_proposals):
    import zeroonelib
    import misc
    from zerooned import ZeroOneDaemon
    zerooned = ZeroOneDaemon.from_zeroone_conf(config.zeroone_conf)
    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_zerooned(zerooned, item)

    max_budget = 60
    prop_list = Proposal.approved_and_ranked(proposal_quorum=1, next_superblock_max_budget=max_budget)
    print prop_list

    # MAX_GOVERNANCE_OBJECT_DATA_SIZE defined in governance-object.h
    maxgovobjdatasize = 16 * 1024
    sb = zeroonelib.create_superblock(prop_list, 72000, max_budget, misc.now(), maxgovobjdatasize)
예제 #8
0
    def getMasternodes(self):
        mnList = {}
        mnList['last_update'] = now()
        score = []
        try:
            self.lock.acquire()
            masternodes = self.conn.listmasternodes()
        except Exception as e:
            err_msg = "error in getMasternodes"
            printException(getCallerName(), getFunctionName(), err_msg, e.args)
            masternodes = []
        finally:
            self.lock.release()

        for mn in masternodes:

            if mn.get('status') == 'ENABLED':
                if mn.get('lastpaid') == 0:
                    mn['score'] = mn.get('activetime')
                else:
                    lastpaid_ago = now() - mn.get('lastpaid')
                    mn['score'] = min(lastpaid_ago, mn.get('activetime'))

            else:
                mn['score'] = 0

            score.append(mn)

        score.sort(key=lambda x: x['score'], reverse=True)

        for mn in masternodes:
            mn['queue_pos'] = score.index(mn)

        mnList['masternodes'] = masternodes

        return mnList
예제 #9
0
def test_deterministic_superblock_creation(go_list_proposals):
    import dynamiclib
    import misc
    from dynamicd import DynamicDaemon
    dynamicd = DynamicDaemon.from_dynamic_conf(config.dynamic_conf)
    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_dynamicd(
            dynamicd, item)

    max_budget = 60
    prop_list = Proposal.approved_and_ranked(
        proposal_quorum=1, next_superblock_max_budget=max_budget)
    sb = dynamiclib.create_superblock(prop_list,
                                      72000,
                                      budget_max=max_budget,
                                      sb_epoch_time=misc.now())
예제 #10
0
 def onSaveConsole(self):
     timestamp = strftime('%Y-%m-%d_%H-%M-%S', gmtime(now()))
     options = QFileDialog.Options()
     options |= QFileDialog.DontUseNativeDialog
     fileName, _ = QFileDialog.getSaveFileName(self,"Save Logs to file","SPMT_Logs_%s.txt" % timestamp,"All Files (*);; Text Files (*.txt)", options=options)
     try:
         if fileName:
             printOK("Saving logs to %s" % fileName)
             log_file = open(fileName, 'w+')
             log_text = self.consoleArea.toPlainText()
             log_file.write(log_text)
             log_file.close()
             
     except Exception as e:
         err_msg = "error writing Log file"
         printException(getCallerName(), getFunctionName(), err_msg, e.args)
예제 #11
0
    def updateAllMasternodes(self):
        # update only after 1 min
        try:
            if now() - self.all_masternodes['last_update'] > 60:
                # Check rpc connection
                if not self.caller.rpcConnected:
                    self.caller.myPopUp2(
                        QMessageBox.Critical, 'SPMT - hw device check',
                        "RPC server must be connected to perform this action.")
                    printDbg("Unable to connect: %s" %
                             self.caller.rpcStatusMess)
                    return
                else:
                    self.all_masternodes = self.caller.rpcClient.getMasternodes(
                    )

        except Exception as e:
            print(e)
예제 #12
0
def test_deterministic_superblock_creation(go_list_proposals):
    import galactrumlib
    import misc
    from galactrumd import GalactrumDaemon
    galactrumd = GalactrumDaemon.from_galactrum_conf(config.galactrum_conf)
    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_galactrumd(galactrumd, item)

    max_budget = 60
    prop_list = Proposal.approved_and_ranked(proposal_quorum=1, next_superblock_max_budget=max_budget)

    sb = galactrumlib.create_superblock(prop_list, 72000, max_budget, misc.now())

    assert sb.event_block_height == 72000
    assert sb.payment_addresses == 'yYe8KwyaUu5YswSYmB3q3ryx8XTUu9y7Ui|yTC62huR4YQEPn9AJHjnQxxreHSbgAoatV'
    assert sb.payment_amounts == '25.75000000|32.01000000'
    assert sb.proposal_hashes == 'dfd7d63979c0b62456b63d5fc5306dbec451180adee85876cbf5b28c69d1a86c|0523445762025b2e01a2cd34f1d10f4816cf26ee1796167e5b029901e5873630'

    assert sb.hex_hash() == 'bb3f33ccf95415c396bd09d35325dbcbc7b067010d51c7ccf772a9e839c1e414'
예제 #13
0
def test_deterministic_superblock_creation(go_list_proposals):
    import bitgreenlib
    import misc
    from bitgreend import BitgreenDaemon
    bitgreend = BitgreenDaemon.from_bitgreen_conf(config.bitgreen_conf)
    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_bitgreend(bitgreend, item)

    max_budget = 60
    prop_list = Proposal.approved_and_ranked(proposal_quorum=1, next_superblock_max_budget=max_budget)

    sb = bitgreenlib.create_superblock(prop_list, 72000, max_budget, misc.now())

    assert sb.event_block_height == 72000
    assert sb.payment_addresses == 'gXcKEE2cr7gXxaupoSU7J2iwjGvGDUtKi7|gXcKEE2cr7gXxaupoSU7J2iwjGvGDUtKi7'
    assert sb.payment_amounts == '25.75000000|25.75000000'
    assert sb.proposal_hashes == 'dfd7d63979c0b62456b63d5fc5306dbec451180adee85876cbf5b28c69d1a86c|0523445762025b2e01a2cd34f1d10f4816cf26ee1796167e5b029901e5873630'

    assert sb.hex_hash() == '6e1c7df4ff9c2c55b0d4847ec4f28af0841220f89ab71678bd9fa3ab61368b1f'
예제 #14
0
def test_deterministic_superblock_creation(go_list_proposals):
    import historialib
    import misc
    from historiad import HistoriaDaemon
    historiad = HistoriaDaemon.from_historia_conf(config.historia_conf)
    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_historiad(historiad, item)

    max_budget = 60
    prop_list = Proposal.approved_and_ranked(proposal_quorum=1, next_superblock_max_budget=max_budget)

    sb = historialib.create_superblock(prop_list, 72000, max_budget, misc.now())

    assert sb.event_block_height == 72000
    assert sb.payment_addresses == 'TwBnvi9FfwBSuq5ck9LEG7i8ZfdEK55L3L|TwThXv2jrUuk4HG2YD2bxg1RUFzi4Fn4XQ'
    assert sb.payment_amounts == '25.75000000|32.01000000'
    assert sb.proposal_hashes == 'dfd7d63979c0b62456b63d5fc5306dbec451180adee85876cbf5b28c69d1a86c|0523445762025b2e01a2cd34f1d10f4816cf26ee1796167e5b029901e5873630'

    print('hash:', sb.hex_hash())
    assert sb.hex_hash() == '5be985920dbbd92689f3dd301b29391239cf8ba4c1babc5547e7d980854925a6'
예제 #15
0
def test_deterministic_superblock_creation(go_list_proposals):
    import chaincoinlib
    import misc
    from chaincoind import ChaincoinDaemon
    chaincoind = ChaincoinDaemon.from_chaincoin_conf(config.chaincoin_conf)
    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_chaincoind(chaincoind, item)

    max_budget = 384
    prop_list = Proposal.approved_and_ranked(proposal_quorum=1, next_superblock_max_budget=max_budget)

    # MAX_GOVERNANCE_OBJECT_DATA_SIZE defined in governance-object.h
    maxgovobjdatasize = 16 * 1024
    sb = chaincoinlib.create_superblock(prop_list, 72000, max_budget, misc.now(), maxgovobjdatasize)

    assert sb.event_block_height == 72000
    assert sb.payment_addresses == 'ZHJV7jhBWgaB1uxazbVsnQU5HUDAqX14Bz|ZH6bt95skGVco2t3gRuHggcSUrtRZ5BUsr'
    assert sb.payment_amounts == '315.75000000|21.05000000'
    assert sb.proposal_hashes == '7fa2798fee8ea74c3a369db72ae872096bd4e4714f1f5027c730ccfbf58aac02|d1ce73527d7cd6f2218f8ca893990bc7d5c6b9334791ce7973bfa22f155f826e'

    assert sb.hex_hash() == 'bb3f33ccf95415c396bd09d35325dbcbc7b067010d51c7ccf772a9e839c1e414'
예제 #16
0
def test_deterministic_superblock_creation(go_list_proposals):
    import securetaglib
    import misc
    from securetagd import SecuretagDaemon
    securetagd = SecuretagDaemon.from_securetag_conf(config.securetag_conf)
    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_securetagd(securetagd, item)

    max_budget = 60
    prop_list = Proposal.approved_and_ranked(proposal_quorum=1, next_superblock_max_budget=max_budget)

    # MAX_GOVERNANCE_OBJECT_DATA_SIZE defined in governance-object.h
    maxgovobjdatasize = 16 * 1024
    sb = securetaglib.create_superblock(prop_list, 72000, max_budget, misc.now(), maxgovobjdatasize)

    assert sb.event_block_height == 72000
    assert sb.payment_addresses == 'TXDSaTXerg68SCyLkWw2ERsqoTMWRBZiZQ|TDWz9KfMo55wzj2brbgaXxnDz28nAbdPcY'
    assert sb.payment_amounts == '25.75000000|32.01000000'
    assert sb.proposal_hashes == 'dfd7d63979c0b62456b63d5fc5306dbec451180adee85876cbf5b28c69d1a86c|0523445762025b2e01a2cd34f1d10f4816cf26ee1796167e5b029901e5873630'

    assert sb.hex_hash() == '93f37147fb086c1948f2d73f29e4a20f846cdaeef515c2c8701925b664bae024'
예제 #17
0
def test_deterministic_superblock_creation(go_list_proposals):
    import brixcoinlib
    import misc
    from brixcoind import BrixcoinDaemon
    brixcoind = BrixcoinDaemon.from_brixcoin_conf(config.brixcoin_conf)
    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_brixcoind(brixcoind, item)

    max_budget = 60
    prop_list = Proposal.approved_and_ranked(proposal_quorum=1, next_superblock_max_budget=max_budget)

    # MAX_GOVERNANCE_OBJECT_DATA_SIZE defined in governance-object.h
    maxgovobjdatasize = 16 * 1024
    sb = brixcoinlib.create_superblock(prop_list, 72000, max_budget, misc.now(), maxgovobjdatasize)

    assert sb.event_block_height == 72000
    assert sb.payment_addresses == 'yYe8KwyaUu5YswSYmB3q3ryx8XTUu9y7Ui|yTC62huR4YQEPn9AJHjnQxxreHSbgAoatV'
    assert sb.payment_amounts == '25.75000000|32.01000000'
    assert sb.proposal_hashes == 'dfd7d63979c0b62456b63d5fc5306dbec451180adee85876cbf5b28c69d1a86c|0523445762025b2e01a2cd34f1d10f4816cf26ee1796167e5b029901e5873630'

    assert sb.hex_hash() == 'bb3f33ccf95415c396bd09d35325dbcbc7b067010d51c7ccf772a9e839c1e414'
예제 #18
0
def test_superblock_size_limit(go_list_proposals):
    import exiliumlib
    import misc
    from exiliumd import ExiliumDaemon
    exiliumd = ExiliumDaemon.from_exilium_conf(config.exilium_conf)
    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_exiliumd(
            exiliumd, item)

    max_budget = 60
    prop_list = Proposal.approved_and_ranked(
        proposal_quorum=1, next_superblock_max_budget=max_budget)

    # mock maxgovobjdatasize by setting equal to the size of a trigger
    # (serialized) if only the first proposal had been included... anything
    # larger should break the limit
    single_proposal_sb = Superblock(
        event_block_height=72000,
        payment_addresses=prop_list[0].payment_address,
        payment_amounts="{0:.8f}".format(prop_list[0].payment_amount),
        proposal_hashes=prop_list[0].object_hash,
    )
    maxgovobjdatasize = len(single_proposal_sb.serialise())

    # now try and create a Superblock with the entire proposal list
    sb = exiliumlib.create_superblock(prop_list, 72000, max_budget, misc.now(),
                                      maxgovobjdatasize)

    # two proposals in the list, but...
    assert len(prop_list) == 2

    # only one should have been included in the SB, because the 2nd one is over the size limit
    assert sb.event_block_height == 72000
    assert sb.payment_addresses == 'yYe8KwyaUu5YswSYmB3q3ryx8XTUu9y7Ui'
    assert sb.payment_amounts == '25.75000000'
    assert sb.proposal_hashes == 'dfd7d63979c0b62456b63d5fc5306dbec451180adee85876cbf5b28c69d1a86c'

    assert sb.hex_hash(
    ) == '6b8cababf797644f1d62003e4cc68c1c40a8c1873c8a68ed0fc88772ea77cc44'
예제 #19
0
파일: taskloader.py 프로젝트: smallmeet/dns
    def save_result(self, func, result):
        """保存结果"""
        g_lock.acquire()

        sql = '''
            INSERT INTO
                `system_subdomain_result` (`domain_id`, `subdomain`, `ip`, `last_commit_time`, `origin`, `location`)
            SELECT
                `system_domain`.`id`, %s, %s, %s, %s, %s
            FROM
                `system_domain`
            WHERE
                `system_domain`.`domain` = %s
            ON DUPLICATE KEY UPDATE
                `ip` = VALUES(`ip`),
                `last_commit_time` = VALUES(`last_commit_time`)
        '''
        time_now = now()
        logging.info('start saving.')
        logging.info(func.im_class.__name__)
        logging.info(result)
        try:
            for per_domain in result['data'].keys():
                per_domain_data = result['data'][per_domain]
                db.insert(sql,
                          per_domain,
                          per_domain_data['ip'],
                          time_now,
                          result['origin'],
                          per_domain_data['location'],
                          self.target)
                # 存入 cms 信息
                # port_scan_event_service.sync_cms_info(per_domain, json.dumps(per_domain_data['cms']))
            logging.info('saving over.')
        except Exception as e:
            logging.error(traceback.format_exc())
            logging.error('caught an error when saving result:\n%s (%s)`' % (str(e), func))
        finally:
            g_lock.release()
예제 #20
0
def entrypoint():
    # ensure another instance of Sentinel pointing at the same config
    # is not currently running
    mutex_key = 'SENTINEL_RUNNING_' + config.dash_conf

    atexit.register(cleanup, mutex_key)
    signal.signal(signal.SIGINT, signal_handler)

    # assume that all processes expire after 'timeout_seconds' seconds
    timeout_seconds = 90

    is_running = Transient.get(mutex_key)
    if is_running:
        printdbg("An instance of Sentinel is already running -- aborting.")
        sys.exit(1)
    else:
        Transient.set(mutex_key, misc.now(), timeout_seconds)

    # locked to this instance -- perform main logic here
    main()

    Transient.delete(mutex_key)
예제 #21
0
    def is_valid(self, dashd):
        import dashlib
        now = misc.now()

        # proposal name exists and is not null/whitespace
        if (len(self.name.strip()) == 0):
            return False

        # proposal name is normalized (something like "[a-zA-Z0-9-_]+")
        if not re.match(r'^[-_a-zA-Z0-9]+$', self.name):
            return False

        # end date < start date
        if (self.end_epoch <= self.start_epoch):
            return False

        # end date < current date
        if (self.end_epoch <= now):
            return False

        # budget check
        max_budget = dashd.next_superblock_max_budget()
        if (max_budget and (self.payment_amount > max_budget)):
            return False

        # amount can't be negative or 0
        if (self.payment_amount <= 0):
            return False

        # payment address is valid base58 dash addr, non-multisig
        if not dashlib.is_valid_dash_address(self.payment_address,
                                             config.network):
            return False

        # URL
        if (len(self.url.strip()) < 4):
            return False

        return True
예제 #22
0
def test_deterministic_superblock_creation(go_list_proposals):
    import gobytelib
    import misc
    from gobyted import GoByteDaemon
    gobyted = GoByteDaemon.from_gobyte_conf(config.gobyte_conf)
    for item in go_list_proposals:
        (go,
         subobj) = GovernanceObject.import_gobject_from_gobyted(gobyted, item)

    max_budget = 60
    prop_list = Proposal.approved_and_ranked(
        proposal_quorum=1, next_superblock_max_budget=max_budget)

    sb = gobytelib.create_superblock(prop_list, 72000, max_budget, misc.now())

    assert sb.event_block_height == 72000
    assert sb.payment_addresses == 'nLLGSuauCV21NBpHJpLHKevWpwE3t6CHGc|nLLGSuauCV21NBpHJpLHKevWpwE3t6CHGc'
    assert sb.payment_amounts == '25.75000000|32.01000000'
    assert sb.proposal_hashes == 'e966911624df92b90582ef9cdd2b3d8c1ed5c06ee2847aadc68ad0442c22ea6a|2b6b4aee7bea18b38a928ef8c50aa74dac58787e850d990881daf5c1341c9bf8'

    assert sb.hex_hash(
    ) == '5534e9fa4a51423820b9e19fa6d4770c12ea0a5663e8adff8223f5e8b6df641c'
예제 #23
0
def test_deterministic_superblock_creation(go_list_proposals):
    import dtmilib
    import misc
    from dtmid import DtmiDaemon
    dtmid = DtmiDaemon.from_dtmi_conf(config.dtmi_conf)
    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_dtmid(dtmid, item)

    max_budget = 60
    prop_list = Proposal.approved_and_ranked(
        proposal_quorum=1, next_superblock_max_budget=max_budget)
    sb = dtmilib.create_superblock(prop_list,
                                   72000,
                                   budget_max=max_budget,
                                   sb_epoch_time=misc.now())

    assert sb.event_block_height == 72000
    assert sb.payment_addresses == 'yYe8KwyaUu5YswSYmB3q3ryx8XTUu9y7Ui|yTC62huR4YQEPn9AJHjnQxxreHSbgAoatV'
    assert sb.payment_amounts == '25.75000000|32.01000000'
    assert sb.proposal_hashes == 'dfd7d63979c0b62456b63d5fc5306dbec451180adee85876cbf5b28c69d1a86c|0523445762025b2e01a2cd34f1d10f4816cf26ee1796167e5b029901e5873630'

    assert sb.hex_hash(
    ) == '5534e9fa4a51423820b9e19fa6d4770c12ea0a5663e8adff8223f5e8b6df641c'
예제 #24
0
def test_deterministic_superblock_creation(go_list_proposals):
    import trivechainlib
    import misc
    from trivechaind import TrivechainDaemon
    trivechaind = TrivechainDaemon.from_trivechain_conf(config.trivechain_conf)
    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_trivechaind(
            trivechaind, item)

    max_budget = 60
    prop_list = Proposal.approved_and_ranked(
        proposal_quorum=1, next_superblock_max_budget=max_budget)

    sb = trivechainlib.create_superblock(prop_list, 72000, max_budget,
                                         misc.now())

    assert sb.event_block_height == 72000
    assert sb.payment_addresses == 'tCa7rDMXs1KeqaqmcFoXxXMmwT9eq9r7oK|t7RKTBNZsTbjwAoXYfsSsTSwimxzDKh5Fu'
    assert sb.payment_amounts == '25.75000000|32.01000000'
    assert sb.proposal_hashes == 'dfd7d63979c0b62456b63d5fc5306dbec451180adee85876cbf5b28c69d1a86c|0523445762025b2e01a2cd34f1d10f4816cf26ee1796167e5b029901e5873630'

    assert sb.hex_hash(
    ) == 'bb3f33ccf95415c396bd09d35325dbcbc7b067010d51c7ccf772a9e839c1e414'
예제 #25
0
def test_superblock_size_limit(go_list_proposals):
    import brixcoinlib
    import misc
    from brixcoind import BrixcoinDaemon
    brixcoind = BrixcoinDaemon.from_brixcoin_conf(config.brixcoin_conf)
    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_brixcoind(brixcoind, item)

    max_budget = 60
    prop_list = Proposal.approved_and_ranked(proposal_quorum=1, next_superblock_max_budget=max_budget)

    maxgovobjdatasize = 469
    sb = brixcoinlib.create_superblock(prop_list, 72000, max_budget, misc.now(), maxgovobjdatasize)

    # two proposals in the list, but...
    assert len(prop_list) == 2

    # only one should have been included in the SB, because the 2nd one is over the limit
    assert sb.event_block_height == 72000
    assert sb.payment_addresses == 'yYe8KwyaUu5YswSYmB3q3ryx8XTUu9y7Ui'
    assert sb.payment_amounts == '25.75000000'
    assert sb.proposal_hashes == 'dfd7d63979c0b62456b63d5fc5306dbec451180adee85876cbf5b28c69d1a86c'

    assert sb.hex_hash() == '6b8cababf797644f1d62003e4cc68c1c40a8c1873c8a68ed0fc88772ea77cc44'
예제 #26
0
def test_deterministic_superblock_creation(go_list_proposals):
    import terracoinlib
    import misc
    from terracoind import TerracoinDaemon
    terracoind = TerracoinDaemon.from_terracoin_conf(config.terracoin_conf)
    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_terracoind(
            terracoind, item)

    max_budget = 60
    prop_list = Proposal.approved_and_ranked(
        proposal_quorum=1, next_superblock_max_budget=max_budget)
    sb = terracoinlib.create_superblock(prop_list,
                                        72000,
                                        budget_max=max_budget,
                                        sb_epoch_time=misc.now())

    assert sb.event_block_height == 72000
    assert sb.payment_addresses == 'mtHjXMx6dvTwgcvkDvsuWftiyNPi26RqDq|mocfCW5mUWLdcqphNxbcsVKjzqTgdKckW6'
    assert sb.payment_amounts == '25.75000000|32.01000000'
    assert sb.proposal_hashes == 'dfd7d63979c0b62456b63d5fc5306dbec451180adee85876cbf5b28c69d1a86c|0523445762025b2e01a2cd34f1d10f4816cf26ee1796167e5b029901e5873630'

    assert sb.hex_hash(
    ) == 'b88f34fafc02f604c59b7714d6446d893d0f83faeb45831513177b3da9335ad7'
예제 #27
0
def test_deterministic_superblock_creation(go_list_proposals):
    import nextlib
    import misc
    from nextd import NextcoinDaemon
    nextd = NextcoinDaemon.from_next_conf(config.next_conf)
    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_nextd(nextd, item)

    max_budget = 60
    prop_list = Proposal.approved_and_ranked(
        proposal_quorum=1, next_superblock_max_budget=max_budget)

    # MAX_GOVERNANCE_OBJECT_DATA_SIZE defined in governance-object.h
    maxgovobjdatasize = 16 * 1024
    sb = nextlib.create_superblock(prop_list, 72000, max_budget, misc.now(),
                                   maxgovobjdatasize)

    assert sb.event_block_height == 72000
    assert sb.payment_addresses == 'TSTfeMeWwQiCDwMSTWRaj9wwVGNjZFfvFk|TEjMnhB5mAPrpg7R4CUCSGQNnJqPeAFBTH'
    assert sb.payment_amounts == '25.75000000|32.01000000'
    assert sb.proposal_hashes == 'dfd7d63979c0b62456b63d5fc5306dbec451180adee85876cbf5b28c69d1a86c|0523445762025b2e01a2cd34f1d10f4816cf26ee1796167e5b029901e5873630'

    assert sb.hex_hash(
    ) == '1503598424dddb4aa78f0f0ffddc9371386c9692ab35f8f82065672d5d94f870'
예제 #28
0
def test_superblock_size_limit(go_list_proposals):
    import historialib
    import misc
    from historiad import HistoriaDaemon
    historiad = HistoriaDaemon.from_historia_conf(config.historia_conf)
    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_historiad(historiad, item)

    max_budget = 60
    prop_list = Proposal.approved_and_ranked(proposal_quorum=1, next_superblock_max_budget=max_budget)

    maxgovobjdatasize = 469
    sb = historialib.create_superblock(prop_list, 72000, max_budget, misc.now(), maxgovobjdatasize)

    # two proposals in the list, but...
    assert len(prop_list) == 2

    # only one should have been included in the SB, because the 2nd one is over the limit
    assert sb.event_block_height == 72000
    assert sb.payment_addresses == 'TwBnvi9FfwBSuq5ck9LEG7i8ZfdEK55L3L'
    assert sb.payment_amounts == '25.75000000'
    assert sb.proposal_hashes == 'dfd7d63979c0b62456b63d5fc5306dbec451180adee85876cbf5b28c69d1a86c'

    assert sb.hex_hash() == '4009e9abd1a0b3c20848e875586222e395739dfbf0153db15f205a12b5ddb8b7'
예제 #29
0
def test_deterministic_superblock_creation(go_list_proposals):
    import digitslatelib
    import misc
    from digitslated import DigitSlateDaemon
    digitslated = DigitSlateDaemon.from_digitslate_conf(config.digitslate_conf)
    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_digitslated(
            digitslated, item)

    max_budget = 60
    prop_list = Proposal.approved_and_ranked(
        proposal_quorum=1, next_superblock_max_budget=max_budget)
    sb = digitslatelib.create_superblock(prop_list,
                                         72000,
                                         budget_max=max_budget,
                                         sb_epoch_time=misc.now())

    assert sb.event_block_height == 72000
    assert sb.payment_addresses == 'ScHeMAQrdB2BAMZ5V8hfrd9Xveosj2F8DN|mocfCW5mUWLdcqphNxbcsVKjzqTgdKckW6'
    assert sb.payment_amounts == '25.75000000|32.01000000'
    assert sb.proposal_hashes == 'dfd7d63979c0b62456b63d5fc5306dbec451180adee85876cbf5b28c69d1a86c|0523445762025b2e01a2cd34f1d10f4816cf26ee1796167e5b029901e5873630'

    assert sb.hex_hash(
    ) == 'b88f34fafc02f604c59b7714d6446d893d0f83faeb45831513177b3da9335ad7'
예제 #30
0
def test_deterministic_superblock_creation(go_list_proposals):
    import paccoinlib
    import misc
    from paccoind import PaccoinDaemon
    paccoind = PaccoinDaemon.from_paccoin_conf(config.paccoin_conf)
    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_paccoind(
            paccoind, item)

    max_budget = 600000
    prop_list = Proposal.approved_and_ranked(
        proposal_quorum=1, next_superblock_max_budget=max_budget)
    sb = paccoinlib.create_superblock(prop_list,
                                      72000,
                                      budget_max=max_budget,
                                      sb_epoch_time=misc.now())

    assert sb.event_block_height == 72000
    assert sb.payment_addresses == 'qfvtZk8GYfeM37gwZiHPZgVJGnwREsXkoT|qaSQZnZyVz5CEwpFVJkAdByf6tKfu9ejTo'
    assert sb.payment_amounts == '25000.75000000|32000.01000000'
    assert sb.proposal_hashes == 'dfd7d63979c0b62456b63d5fc5306dbec451180adee85876cbf5b28c69d1a86c|0523445762025b2e01a2cd34f1d10f4816cf26ee1796167e5b029901e5873630'

    assert sb.hex_hash(
    ) == '9acf934c982b2f4411d22caf32a59dad5c2d301f9383af2e031cf49262379a49'