示例#1
0
def req(request, looper, sdk_wallet_client, endorser):
    op = {'type': '1', 'something': 'nothing'}
    taaa = {'a': 'b', 'c': 3}
    if request.param.endswith('_sdk'):
        request.param = request.param[:-4]
        if request.param == 'sigs_only':
            req = sdk_multisign_request_from_dict(looper,
                                                  sdk_wallet_client,
                                                  op,
                                                  reqId=1513945121191691,
                                                  taa_acceptance=taaa,
                                                  endorser=endorser)
        else:
            req = sdk_sign_request_from_dict(looper,
                                             sdk_wallet_client,
                                             op,
                                             reqId=1513945121191691,
                                             taa_acceptance=taaa,
                                             endorser=endorser)

        if request.param == 'no_protocol_vers':  # TODO INDY-2072 always false here
            req.pop('protocolVersion')
        req = Request(req.get(f.IDENTIFIER.nm, None),
                      req.get(f.REQ_ID.nm, None), req.get(OPERATION, None),
                      req.get(f.SIG.nm, None), req.get(f.SIGS.nm, None),
                      req.get(f.PROTOCOL_VERSION.nm, None),
                      req.get(f.TAA_ACCEPTANCE.nm, None),
                      req.get(f.ENDORSER.nm, None))
    else:
        req = Request(operation=op,
                      reqId=1513945121191691,
                      protocolVersion=CURRENT_PROTOCOL_VERSION,
                      identifier="6ouriXMZkLeHsuXrN1X1fd",
                      taaAcceptance=taaa,
                      endorser=endorser)
        sign = "2DaRm3nt6H5fJu2TP5vxqbaDCtABPYmUTSX4ocnY8fVGgyJMVNaeh2z6JZhcW1gbmGKJcZopZMKZJwADuXFFJobM"
        req.signature = sign
        req.add_signature("6ouriXMZkLeHsuXrN1X1fd", sign)
        if request.param == 'sig_only':
            req.signatures = None
        if request.param == 'sigs_only':
            req.signature = None
        if request.param == 'no_protocol_vers':
            req.protocolVersion = None

    return req
示例#2
0
def req_and_expected(request, looper, sdk_wallet_client, endorser):
    op = {'type': '1',
          'something': 'nothing'}
    taaa = {
        'a': 'b',
        'c': 3
    }
    if request.param.endswith('_sdk'):
        request.param = request.param[:-4]
        if request.param == 'sigs_only':
            req = sdk_multisign_request_from_dict(looper, sdk_wallet_client,
                                                  op, reqId=1513945121191691,
                                                  taa_acceptance=taaa,
                                                  endorser=endorser)
        else:
            req = sdk_sign_request_from_dict(looper, sdk_wallet_client,
                                             op, reqId=1513945121191691,
                                             taa_acceptance=taaa,
                                             endorser=endorser)
        if request.param == 'no_protocol_vers':  # TODO INDY-2072 always false here
            req.pop('protocolVersion')
        r = Request(
            req.get(f.IDENTIFIER.nm, None),
            req.get(f.REQ_ID.nm, None),
            req.get(OPERATION, None),
            req.get(f.SIG.nm, None),
            req.get(f.SIGS.nm, None),
            req.get(f.PROTOCOL_VERSION.nm, None),
            req.get(f.TAA_ACCEPTANCE.nm, None),
            req.get(f.ENDORSER.nm, None)
        )
        digest = r.digest
        payload_digest = r.payload_digest
        sign = req.get(f.SIG.nm) if request.param != 'sigs_only' else next(iter(req.get(f.SIGS.nm).values()))
    else:
        req = Request(operation=op, reqId=1513945121191691,
                      protocolVersion=CURRENT_PROTOCOL_VERSION, identifier="6ouriXMZkLeHsuXrN1X1fd",
                      taaAcceptance=taaa, endorser=endorser)
        sign = "2DaRm3nt6H5fJu2TP5vxqbaDCtABPYmUTSX4ocnY8fVGgyJMVNaeh2z6JZhcW1gbmGKJcZopZMKZJwADuXFFJobM"
        req.signature = sign
        req.add_signature("6ouriXMZkLeHsuXrN1X1fd",
                          sign)
        if request.param == 'sig_only':
            req.signatures = None
        if request.param == 'sigs_only':
            req.signature = None
        if request.param == 'no_protocol_vers':
            req.protocolVersion = None
        digest = req.digest
        payload_digest = req.payload_digest

    new_expected = SortedDict({
        "reqSignature": {
            "type": "ED25519",
            "values": [{
                "from": "6ouriXMZkLeHsuXrN1X1fd",
                "value": sign
            }]
        },
        "txn": {
            "data": {
                "something": "nothing",
            },

            "metadata": {
                "from": "6ouriXMZkLeHsuXrN1X1fd",
                "reqId": 1513945121191691,
                "taaAcceptance": {
                    "a": "b",
                    "c": 3
                }
            },

            "protocolVersion": CURRENT_PROTOCOL_VERSION,
            "type": "1",
        },
        "txnMetadata": {
            "txnTime": 1513945121,
        },
        "ver": CURRENT_TXN_VERSION

    })

    if request.param == 'no_protocol_vers':
        new_expected["txn"].pop("protocolVersion", None)
    if digest is not None:
        new_expected["txn"]["metadata"]["digest"] = digest
    if payload_digest is not None:
        new_expected["txn"]["metadata"]["payloadDigest"] = payload_digest
    if endorser is not None:
        new_expected["txn"]["metadata"]["endorser"] = endorser

    return req, new_expected
示例#3
0
 def do_multi_sig_on_req(self, request: Request, identifier: str):
     idr = self.requiredIdr(idr=identifier)
     signature = self.signMsg(msg=request.signingState(identifier),
                              identifier=idr)
     request.add_signature(idr, signature)
def req_and_expected(request, looper, sdk_wallet_client):
    op = {'type': '1',
          'something': 'nothing'}
    if request.param.endswith('_sdk'):
        req = sdk_sign_request_from_dict(looper, sdk_wallet_client,
                                         op, reqId=1513945121191691)
        request.param = request.param[:-4]
        # TODO: support multi-sig in SDK
        # if request.param == 'sig_only':
        #     req.pop('signatures')
        # if request.param == 'sigs_only':
        #     req.pop('signature')
        if request.param == 'no_protocol_vers':
            req.pop('protocolVersion')
        r = Request(
            req.get(f.IDENTIFIER.nm, None),
            req.get(f.REQ_ID.nm, None),
            req.get(OPERATION, None),
            req.get(f.SIG.nm, None),
            req.get(f.SIGS.nm, None),
            req.get(f.PROTOCOL_VERSION.nm, None)
        )
        digest = r.digest
        payload_digest = r.payload_digest
        sign = req.get(f.SIG.nm)
    else:
        req = Request(operation=op, reqId=1513945121191691,
                      protocolVersion=CURRENT_PROTOCOL_VERSION, identifier="6ouriXMZkLeHsuXrN1X1fd")
        sign = "2DaRm3nt6H5fJu2TP5vxqbaDCtABPYmUTSX4ocnY8fVGgyJMVNaeh2z6JZhcW1gbmGKJcZopZMKZJwADuXFFJobM"
        req.signature = sign
        req.add_signature("6ouriXMZkLeHsuXrN1X1fd",
                          sign)
        if request.param == 'sig_only':
            req.signatures = None
        if request.param == 'sigs_only':
            req.signature = None
        if request.param == 'no_protocol_vers':
            req.protocolVersion = None
        digest = req.digest
        payload_digest = req.payload_digest

    new_expected = SortedDict({
        "reqSignature": {
            "type": "ED25519",
            "values": [{
                "from": "6ouriXMZkLeHsuXrN1X1fd",
                "value": sign
            }]
        },
        "txn": {
            "data": {
                "something": "nothing",
            },

            "metadata": {
                "from": "6ouriXMZkLeHsuXrN1X1fd",
                "reqId": 1513945121191691
            },

            "protocolVersion": CURRENT_PROTOCOL_VERSION,
            "type": "1",
        },
        "txnMetadata": {
            "txnTime": 1513945121,
        },
        "ver": "1"

    })

    if request.param == 'no_protocol_vers':
        new_expected["txn"].pop("protocolVersion", None)
    if digest is not None:
        new_expected["txn"]["metadata"]["digest"] = digest
    if payload_digest is not None:
        new_expected["txn"]["metadata"]["payloadDigest"] = payload_digest

    return req, new_expected
示例#5
0
 def do_multi_sig_on_req(self, request: Request, identifier: str):
     idr = self.requiredIdr(idr=identifier)
     signature = self.signMsg(msg=request.signingState(identifier),
                              identifier=idr)
     request.add_signature(idr, signature)
def req_and_expected(request, looper, sdk_wallet_client):
    op = {'type': '1',
          'something': 'nothing'}
    if request.param.endswith('_sdk'):
        req = sdk_sign_request_from_dict(looper, sdk_wallet_client,
                                         op, reqId=1513945121191691)
        request.param = request.param[:-4]
        # TODO: support multi-sig in SDK
        # if request.param == 'sig_only':
        #     req.pop('signatures')
        # if request.param == 'sigs_only':
        #     req.pop('signature')
        if request.param == 'no_protocol_vers':
            req.pop('protocolVersion')
        digest = Request(
            req.get(f.IDENTIFIER.nm, None),
            req.get(f.REQ_ID.nm, None),
            req.get(OPERATION, None),
            req.get(f.SIG.nm, None),
            req.get(f.SIGS.nm, None),
            req.get(f.PROTOCOL_VERSION.nm, None)
        ).digest
        sign = req.get(f.SIG.nm)
    else:
        req = Request(operation=op, reqId=1513945121191691,
                      protocolVersion=CURRENT_PROTOCOL_VERSION, identifier="6ouriXMZkLeHsuXrN1X1fd")
        sign = "2DaRm3nt6H5fJu2TP5vxqbaDCtABPYmUTSX4ocnY8fVGgyJMVNaeh2z6JZhcW1gbmGKJcZopZMKZJwADuXFFJobM"
        req.signature = sign
        req.add_signature("6ouriXMZkLeHsuXrN1X1fd",
                          sign)
        if request.param == 'sig_only':
            req.signatures = None
        if request.param == 'sigs_only':
            req.signature = None
        if request.param == 'no_protocol_vers':
            req.protocolVersion = None
        digest = req.digest

    new_expected = SortedDict({
        "reqSignature": {
            "type": "ED25519",
            "values": [{
                "from": "6ouriXMZkLeHsuXrN1X1fd",
                "value": sign
            }]
        },
        "txn": {
            "data": {
                "something": "nothing",
            },

            "metadata": {
                "from": "6ouriXMZkLeHsuXrN1X1fd",
                "reqId": 1513945121191691
            },

            "protocolVersion": CURRENT_PROTOCOL_VERSION,
            "type": "1",
        },
        "txnMetadata": {
            "txnTime": 1513945121,
        },
        "ver": "1"

    })

    if request.param == 'no_protocol_vers':
        new_expected["txn"].pop("protocolVersion", None)
    if digest is not None:
        new_expected["txn"]["metadata"]["digest"] = digest

    return req, new_expected