Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 8eaa4fc

Browse files
committed
[FAB-8344] Remove Channel from integration tests
Change-Id: I158828755474855176a665bd20fed6278a262fa3 Signed-off-by: Troy Ronda <troy@troyronda.com>
1 parent ff9b6bf commit 8eaa4fc

File tree

5 files changed

+78
-166
lines changed

5 files changed

+78
-166
lines changed

api/apifabclient/channel.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ type ChannelLedger interface {
6363
QueryBlockByHash(blockHash []byte, targets []ProposalProcessor) ([]*common.Block, error)
6464
QueryTransaction(transactionID string, targets []ProposalProcessor) ([]*pb.ProcessedTransaction, error)
6565
QueryInstantiatedChaincodes(targets []ProposalProcessor) ([]*pb.ChaincodeQueryResponse, error)
66+
QueryConfigBlock(targets []ProposalProcessor, minResponses int) (*common.ConfigEnvelope, error) // TODO: generalize minResponses
6667
}
6768

6869
// OrgAnchorPeer contains information about an anchor peer on this channel

test/integration/base_test_setup.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ type BaseSetupImpl struct {
3131
Client fab.Resource
3232
Transactor fab.Transactor
3333
Targets []fab.ProposalProcessor
34-
Channel fab.Channel
3534
EventHub fab.EventHub
3635
ConnectEventHub bool
3736
ConfigFile string
@@ -119,12 +118,6 @@ func (setup *BaseSetupImpl) Initialize() error {
119118
}
120119
setup.Transactor = transactor
121120

122-
channel, err := chService.Channel()
123-
if err != nil {
124-
return errors.WithMessage(err, "channel client creation failed")
125-
}
126-
setup.Channel = channel
127-
128121
eventHub, err := chService.EventHub()
129122
if err != nil {
130123
return errors.WithMessage(err, "eventhub client creation failed")

test/integration/fab/channel_ledger_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ func TestLedgerQueries(t *testing.T) {
108108

109109
testInstantiatedChaincodes(t, chaincodeID, ledger, targets)
110110

111+
testQueryConfigBlock(t, ledger, targets)
111112
}
112113

113114
func changeBlockState(t *testing.T, channel chclient.ChannelClient, chaincodeID string) (string, error) {
@@ -253,3 +254,17 @@ func moveFundsAndGetTxID(t *testing.T, channel chclient.ChannelClient, chaincode
253254

254255
return resp.TransactionID.ID, nil
255256
}
257+
258+
func testQueryConfigBlock(t *testing.T, ledger fab.ChannelLedger, targets []fab.ProposalProcessor) {
259+
260+
// Retrieve current channel configuration
261+
cfgEnvelope, err := ledger.QueryConfigBlock(targets, 1)
262+
if err != nil {
263+
t.Fatalf("QueryConfig return error: %v", err)
264+
}
265+
266+
if cfgEnvelope.Config == nil {
267+
t.Fatalf("QueryConfig config data is nil")
268+
}
269+
270+
}

test/integration/fab/channel_queries_test.go

Lines changed: 0 additions & 159 deletions
This file was deleted.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
Copyright SecureKey Technologies Inc. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package fab
8+
9+
import (
10+
"testing"
11+
12+
fab "github.com/hyperledger/fabric-sdk-go/api/apifabclient"
13+
"github.com/hyperledger/fabric-sdk-go/test/integration"
14+
)
15+
16+
func TestChannelQueries(t *testing.T) {
17+
chaincodeID := integration.GenerateRandomID()
18+
testSetup := initializeTests(t, chaincodeID)
19+
20+
testQueryChannels(t, testSetup.Client, testSetup.Targets[0])
21+
22+
testInstalledChaincodes(t, chaincodeID, testSetup.Client, testSetup.Targets[0])
23+
24+
}
25+
26+
func testQueryChannels(t *testing.T, client fab.Resource, target fab.ProposalProcessor) {
27+
28+
// Our target will be primary peer on this channel
29+
t.Logf("****QueryChannels for %s", target)
30+
channelQueryResponse, err := client.QueryChannels(target)
31+
if err != nil {
32+
t.Fatalf("QueryChannels return error: %v", err)
33+
}
34+
35+
for _, channel := range channelQueryResponse.Channels {
36+
t.Logf("**Channel: %s", channel)
37+
}
38+
39+
}
40+
41+
func testInstalledChaincodes(t *testing.T, ccID string, client fab.Resource, target fab.ProposalProcessor) {
42+
43+
// Our target will be primary peer on this channel
44+
t.Logf("****QueryInstalledChaincodes for %s", target)
45+
46+
chaincodeQueryResponse, err := client.QueryInstalledChaincodes(target)
47+
if err != nil {
48+
t.Fatalf("QueryInstalledChaincodes return error: %v", err)
49+
}
50+
51+
found := false
52+
for _, chaincode := range chaincodeQueryResponse.Chaincodes {
53+
t.Logf("**InstalledCC: %s", chaincode)
54+
if chaincode.Name == ccID {
55+
found = true
56+
}
57+
}
58+
59+
if !found {
60+
t.Fatalf("QueryInstalledChaincodes failed to find installed %s chaincode", ccID)
61+
}
62+
}

0 commit comments

Comments
 (0)