示例#1
0
    def test_invoke(self):
        self.shutdown_test_env()
        self.start_test_env()
        time.sleep(5)
        client = Client()
        chain = client.new_channel(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_invoke_req = create_invocation_proposal_req(
        #     CHAINCODE_NAME, CHAINCODE_VERSION, signing_identity,
        #     args=['move', 'a', 'b', '100'])
        queue = Queue(1)
        #
        # chain.invoke_chaincode(cc_invoke_req) \
        #     .subscribe(lambda x: queue.put(x))

        prop = queue.get(timeout=10)
        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)
        self.shutdown_test_env()
示例#2
0
    def test_create_new_chain(self):
        client = Client()
        client.set_state_store(file_key_value_store(self.kv_store_path))
        test_chain = client.new_chain('test')
        self.assertEqual(test_chain, client.get_chain('test'))

        no_chain = client.get_chain('test1')
        self.assertIsNone(no_chain)
    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
        print(response.status)
        self.assertEqual(404, response.status)
示例#4
0
    def test_create_client(self):
        # TODO impl

        client = Client()
        client.set_state_store(file_key_value_store(self.kv_store_path))
        self.fail()