Example #1
0
def test_deterministic_superblock_creation(go_list_proposals):
    import emralslib
    import misc
    from emralsd import EmralsDaemon
    emralsd = EmralsDaemon.from_emrals_conf(config.emrals_conf)
    for item in go_list_proposals:
        (go,
         subobj) = GovernanceObject.import_gobject_from_emralsd(emralsd, 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 = emralslib.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'
Example #2
0
def test_superblock_size_limit(go_list_proposals):
    import emralslib
    import misc
    from emralsd import EmralsDaemon
    emralsd = EmralsDaemon.from_emrals_conf(config.emrals_conf)
    for item in go_list_proposals:
        (go,
         subobj) = GovernanceObject.import_gobject_from_emralsd(emralsd, item)

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

    maxgovobjdatasize = 469
    sb = emralslib.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'
Example #3
0
def test_approved_and_ranked(go_list_proposals):
    from emralsd import EmralsDaemon
    emralsd = EmralsDaemon.from_emrals_conf(config.emrals_conf)

    for item in go_list_proposals:
        (go, subobj) = GovernanceObject.import_gobject_from_emralsd(emralsd, item)

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

    assert prop_list[0].object_hash == u'dfd7d63979c0b62456b63d5fc5306dbec451180adee85876cbf5b28c69d1a86c'
    assert prop_list[1].object_hash == u'0523445762025b2e01a2cd34f1d10f4816cf26ee1796167e5b029901e5873630'