Beispiel #1
0
    def test_instantiate(self):
        start_test_env()
        time.sleep(5)
        client = Client()
        chain = client.new_chain(CHAIN_ID)
        client.set_state_store(file_key_value_store(self.kv_store_path))
        chain.add_peer(Peer())

        submitter = get_submitter()
        signing_identity = submitter.signing_identity
        cc_instantiate_req = create_instantiation_proposal_req(
            CHAINCODE_NAME,
            CHAINCODE_PATH,
            CHAINCODE_VERSION,
            signing_identity,
            args=['a', '100', 'b', '200'])
        queue = Queue(1)

        chain.instantiate_chaincode(cc_instantiate_req) \
            .subscribe(lambda x: queue.put(x))

        prop = queue.get()
        proposal_bytes = prop.proposal_bytes
        sig = prop.signature

        # verify the signature against the hash of proposal_bytes
        digest = signing_identity.msp.crypto_suite.hash(proposal_bytes)
        self.assertEqual(
            signing_identity.verify(str.encode(digest.hexdigest()), sig), True)
        shutdown_test_env()
Beispiel #2
0
    def test_instantiate(self):
        start_test_env()
        time.sleep(5)
        grpc_addr = os.environ.get('GRPC_ADDR', 'localhost:7050')
        client = Client()
        chain = client.new_chain(CHAIN_ID)
        client.set_state_store('test_store')
        chain.add_peer(Peer(endpoint=grpc_addr))

        submitter = get_submitter()
        signing_identity = submitter.get_signing_identity()
        cc_instantiate_req = create_instantiate_proposal_req(
            CHAINCODE_NAME, CHAINCODE_PATH, CHAINCODE_VERSION,
            signing_identity)
        queue = Queue(1)

        chain.instantiate_chaincode(cc_instantiate_req) \
            .subscribe(lambda x: queue.put(x))

        prop = queue.get()
        proposal_bytes = prop.proposal_bytes
        sig = prop.signature

        # verify the signature against the hash of proposal_bytes
        digest = signing_identity.msp.crypto_suite.hash(proposal_bytes)
        self.assertEqual(
            signing_identity.verify(str.encode(digest.hexdigest()), sig), True)
        shutdown_test_env()
 def test_deploy(self):
     self.start_test_env()
     time.sleep(5)
     grpc_addr = os.environ.get('GRPC_ADDR', 'localhost:7050')
     client = Client()
     chain = client.new_chain(CHAIN_ID)
     client.set_state_store('test_store')
     chain.add_peer(Peer(endpoint=grpc_addr))
     proposal = chain.create_deploy_proposal(chaincode_path=CHAINCODE_PATH,
                                             chaincode_name=CHAINCODE_NAME,
                                             fcn=FCN, args=F_ARGS,
                                             chain_id=CHAIN_ID, tx_id=TX_ID)
     self.assertIsNotNone(proposal)
     self.shutdown_test_env()
Beispiel #4
0
    def test_install(self):
        start_test_env()
        time.sleep(5)
        client = Client()
        chain = client.new_chain(CHAIN_ID)
        client.set_state_store(file_key_value_store(self.kv_store_path))
        chain.add_peer(Peer())

        submitter = get_submitter()
        signing_identity = submitter.signing_identity
        cc_install_req = create_installment_proposal_req(
            CHAINCODE_NAME, CHAINCODE_PATH, CHAINCODE_VERSION,
            signing_identity)
        queue = Queue(1)

        chain.install_chaincode(cc_install_req) \
            .subscribe(lambda x: queue.put(x))

        response, _ = queue.get()
        self.assertEqual(200, response.response.status)
        shutdown_test_env()
    def test_install(self):
        time.sleep(5)
        client = Client()
        chain = client.new_chain(CHAIN_ID)
        client.set_state_store(file_key_value_store(self.kv_store_path))
        chain.add_peer(Peer())
        chain.add_orderer(Orderer())

        submitter = get_submitter()
        signing_identity = submitter.signing_identity
        cc_install_req = create_installment_proposal_req(
            CHAINCODE_NAME, CHAINCODE_PATH, CHAINCODE_VERSION)
        queue = Queue(1)

        chain.install_chaincode(cc_install_req, signing_identity) \
            .subscribe(on_next=lambda x: queue.put(x),
                       on_error=lambda x: queue.put(x))

        response, _ = queue.get(timeout=5)
        # TODO: create channel not implement yet
        self.assertEqual(404, response.status)
    def test_deploy(self):
        # self.start_test_env()
        # time.sleep(5)
        grpc_addr = os.environ.get('GRPC_ADDR', 'localhost:7050')
        client = Client()
        chain = client.new_chain(CHAIN_ID)
        client.set_state_store('test_store')
        chain.add_peer(Peer(endpoint=grpc_addr))

        signing_identity = SigningIdentity(None, None, None, None, None)
        cc_deployment_req = \
            ChaincodeDeploymentRequest(CHAINCODE_PATH,
                                       CHAINCODE_NAME,
                                       FCN, CHAIN_ID, TX_ID,
                                       F_ARGS,
                                       signing_identity=signing_identity)
        queue = Queue(1)

        chain.send_deployment_proposal(cc_deployment_req) \
            .subscribe(lambda x: queue.put(x))

        self.assertIsNotNone(queue.get())