Channel implements Serializable { public BlockInfo queryBlockByHash(byte[] blockHash) throws InvalidArgumentException, ProposalException { checkChannelState(); if (blockHash == null) { throw new InvalidArgumentException("blockHash parameter is null."); } return queryBlockByHash(getRandomLedgerQueryPeer(), blockHash); } private  Channel(String name, HFClient hfClient, Orderer orderer, ChannelConfiguration channelConfiguration, byte[][] signers);   Channel(String name, HFClient client); private  Channel(String name, HFClient client, final boolean systemChannel); Collection<EventHub> getEventHubs(); void updateChannelConfiguration(UpdateChannelConfiguration updateChannelConfiguration, byte[]... signers); void updateChannelConfiguration(UpdateChannelConfiguration updateChannelConfiguration, Orderer orderer, byte[]... signers); boolean isInitialized(); String getName(); Channel addPeer(Peer peer); Channel addPeer(Peer peer, PeerOptions peerOptions); Channel joinPeer(Peer peer); Channel joinPeer(Peer peer, PeerOptions peerOptions); void removePeer(Peer peer); Channel addOrderer(Orderer orderer); PeerOptions getPeersOptions(Peer peer); Channel addEventHub(EventHub eventHub); Collection<Peer> getPeers(); Collection<Peer> getPeers(EnumSet<PeerRole> roles); Channel initialize(); boolean isShutdown(); byte[] getUpdateChannelConfigurationSignature(UpdateChannelConfiguration updateChannelConfiguration, User signer); byte[] getChannelConfigurationBytes(); Collection<Orderer> getOrderers(); Collection<ProposalResponse> sendInstantiationProposal(InstantiateProposalRequest instantiateProposalRequest); Collection<ProposalResponse> sendInstantiationProposal(InstantiateProposalRequest instantiateProposalRequest,
                                                                  Collection<Peer> peers); Collection<ProposalResponse> sendUpgradeProposal(UpgradeProposalRequest upgradeProposalRequest); Collection<ProposalResponse> sendUpgradeProposal(UpgradeProposalRequest upgradeProposalRequest, Collection<Peer> peers); BlockInfo queryBlockByHash(byte[] blockHash); BlockInfo queryBlockByHash(Peer peer, byte[] blockHash); BlockInfo queryBlockByNumber(long blockNumber); BlockInfo queryBlockByNumber(Peer peer, long blockNumber); BlockInfo queryBlockByTransactionID(String txID); BlockInfo queryBlockByTransactionID(Peer peer, String txID); BlockchainInfo queryBlockchainInfo(); BlockchainInfo queryBlockchainInfo(Peer peer); TransactionInfo queryTransactionByID(String txID); TransactionInfo queryTransactionByID(Peer peer, String txID); List<ChaincodeInfo> queryInstantiatedChaincodes(Peer peer); Collection<ProposalResponse> sendTransactionProposal(TransactionProposalRequest transactionProposalRequest); Collection<ProposalResponse> sendTransactionProposal(TransactionProposalRequest transactionProposalRequest, Collection<Peer> peers); Collection<ProposalResponse> queryByChaincode(QueryByChaincodeRequest queryByChaincodeRequest); Collection<ProposalResponse> queryByChaincode(QueryByChaincodeRequest queryByChaincodeRequest, Collection<Peer> peers); CompletableFuture<TransactionEvent> sendTransaction(Collection<ProposalResponse> proposalResponses, User userContext); CompletableFuture<TransactionEvent> sendTransaction(Collection<ProposalResponse> proposalResponses); CompletableFuture<TransactionEvent> sendTransaction(Collection<ProposalResponse> proposalResponses, Collection<Orderer> orderers); CompletableFuture<TransactionEvent> sendTransaction(Collection<ProposalResponse> proposalResponses, Collection<Orderer> orderers, User userContext); String registerBlockListener(BlockListener listener); boolean unregisterBlockListener(String handle); String registerChaincodeEventListener(Pattern chaincodeId, Pattern eventName, ChaincodeEventListener chaincodeEventListener); boolean unregisterChaincodeEventListener(String handle); synchronized void shutdown(boolean force); void serializeChannel(File file); byte[] serializeChannel();  }
@Test public void testChannelBadPeerNull() throws Exception { thrown.expect(InvalidArgumentException.class); thrown.expectMessage("Peer value is null."); final Channel channel = createRunningChannel(null); channel.queryBlockByHash(null, "rick".getBytes()); }
@Test public void testChannelQueryBlockByHashNull() throws Exception { thrown.expect(InvalidArgumentException.class); thrown.expectMessage("blockHash parameter is null."); final Channel channel = createRunningChannel(null); channel.queryBlockByHash(null); }
@Test public void testChannelQueryBlockByHashNotInitialized() throws Exception { thrown.expect(InvalidArgumentException.class); thrown.expectMessage("Channel channel has not been initialized."); final Channel channel = createRunningChannel(null); setField(channel, "initialized", false); channel.queryBlockByHash("hyper this hyper that".getBytes()); }