Esempio n. 1
0
 def put_into_seq_no_db(txn):
     # If there is no reqId, then it's genesis txn
     if get_req_id(txn) is None:
         return
     txn_new = copy.deepcopy(txn)
     operation = get_payload_data(txn_new)
     operation[TXN_TYPE] = get_type(txn_new)
     dct = {
         f.IDENTIFIER.nm: get_from(txn_new),
         f.REQ_ID.nm: get_req_id(txn_new),
         OPERATION: operation,
     }
     if get_protocol_version(txn_new) is not None:
         dct[f.PROTOCOL_VERSION.nm] = get_protocol_version(txn_new)
     digest = sha256(serialize_msg_for_signing(dct)).hexdigest()
     seq_no = get_seq_no(txn_new)
     ledger_id = get_ledger_id_by_txn_type(operation[TXN_TYPE])
     line_to_record = str(ledger_id) + ReqIdrToTxn.delimiter + str(seq_no)
     dest_seq_no_db_storage.put(digest, line_to_record)
     return digest
Esempio n. 2
0
 def put_into_seq_no_db(txn):
     # If there is no reqId, then it's genesis txn
     if get_req_id(txn) is None:
         return
     txn_new = copy.deepcopy(txn)
     operation = get_payload_data(txn_new)
     operation[TXN_TYPE] = get_type(txn_new)
     dct = {
         f.IDENTIFIER.nm: get_from(txn_new),
         f.REQ_ID.nm: get_req_id(txn_new),
         OPERATION: operation,
     }
     if get_protocol_version(txn_new) is not None:
         dct[f.PROTOCOL_VERSION.nm] = get_protocol_version(txn_new)
     digest = sha256(serialize_msg_for_signing(dct)).hexdigest().encode()
     seq_no = get_seq_no(txn_new)
     ledger_id = get_ledger_id_by_txn_type(operation[TXN_TYPE])
     line_to_record = str(ledger_id) + ReqIdrToTxn.delimiter + str(seq_no)
     dest_seq_no_db_storage.put(digest, line_to_record)
     return digest
Esempio n. 3
0
def test_pool_genesis_txns(bootstrap, pool_genesis_file):
    serializer = JsonSerializer()
    with open(pool_genesis_file) as f:
        for line in store_utils.cleanLines(f.readlines()):
            txn = serializer.deserialize(line)
            assert get_seq_no(txn)
            assert get_txn_id(txn)
            assert get_payload_data(txn)
            assert get_type(txn) == NODE
            assert get_version(txn) == "1"
            assert get_protocol_version(txn) is None
            assert get_payload_data(txn)[TARGET_NYM]
            data = get_payload_data(txn).get(DATA)
            assert data
            assert data[ALIAS]
            assert data[CLIENT_IP]
            assert data[CLIENT_PORT]
            assert data[NODE_IP]
            assert data[NODE_PORT]
            assert data[SERVICES] == [VALIDATOR]
            assert data[BLS_KEY]
def test_pool_genesis_txns(bootstrap, pool_genesis_file):
    serializer = JsonSerializer()
    with open(pool_genesis_file) as f:
        for line in store_utils.cleanLines(f.readlines()):
            txn = serializer.deserialize(line)
            assert get_seq_no(txn)
            assert get_txn_id(txn)
            assert get_payload_data(txn)
            assert get_type(txn) == NODE
            assert get_version(txn) == "1"
            assert get_protocol_version(txn) is None
            assert get_payload_data(txn)[TARGET_NYM]
            data = get_payload_data(txn).get(DATA)
            assert data
            assert data[ALIAS]
            assert data[CLIENT_IP]
            assert data[CLIENT_PORT]
            assert data[NODE_IP]
            assert data[NODE_PORT]
            assert data[SERVICES] == [VALIDATOR]
            assert data[BLS_KEY]
            assert data[BLS_KEY_PROOF]
def test_domain_genesis_txns(bootstrap, domain_genesis_file):
    serializer = JsonSerializer()
    with open(domain_genesis_file) as f:
        i = 0
        for line in store_utils.cleanLines(f.readlines()):
            txn = serializer.deserialize(line)
            assert get_seq_no(txn)
            assert get_payload_data(txn)
            assert get_type(txn) == NYM
            assert get_version(txn) == "1"
            assert get_protocol_version(txn) is None
            assert get_payload_data(txn)[VERKEY]
            assert get_payload_data(txn)[TARGET_NYM]
            assert ALIAS not in get_payload_data(txn)

            # expect Trustees, then Stewards, then Clients
            if 0 <= i < TRUSTEE_COUNT:
                expected_role = TRUSTEE
            elif TRUSTEE_COUNT <= i < TRUSTEE_COUNT + NODE_COUNT:
                expected_role = STEWARD
            else:
                expected_role = None
            assert get_payload_data(txn).get(ROLE) == expected_role
            i += 1
def test_domain_genesis_txns(bootstrap, domain_genesis_file):
    serializer = JsonSerializer()
    with open(domain_genesis_file) as f:
        i = 0
        for line in store_utils.cleanLines(f.readlines()):
            txn = serializer.deserialize(line)
            assert get_seq_no(txn)
            assert get_payload_data(txn)
            assert get_type(txn) == NYM
            assert get_version(txn) == "1"
            assert get_protocol_version(txn) is None
            assert get_payload_data(txn)[VERKEY]
            assert get_payload_data(txn)[TARGET_NYM]
            assert ALIAS not in get_payload_data(txn)

            # expect Trustees, then Stewards, then Clients
            if 0 <= i < TRUSTEE_COUNT:
                expected_role = TRUSTEE
            elif TRUSTEE_COUNT <= i < TRUSTEE_COUNT + NODE_COUNT:
                expected_role = STEWARD
            else:
                expected_role = None
            assert get_payload_data(txn).get(ROLE) == expected_role
            i += 1
def test_get_protocol_version(txn):
    assert get_protocol_version(txn) == "2"
def test_get_protocol_version(txn):
    assert get_protocol_version(txn) == "2"