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

Commit c981b55

Browse files
committed
[FAB-8247] Improve instantiated chaincodes test
Change-Id: I1fbf55377b61fc4d3c977ea658f8852794697b53 Signed-off-by: Sandra Vrtikapa <sandra.vrtikapa@securekey.com>
1 parent 07808ad commit c981b55

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

test/integration/fab/channel_ledger_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func TestLedgerQueries(t *testing.T) {
106106

107107
testQueryBlock(t, ledger, targets)
108108

109-
testInstantiatedChaincodes(t, ledger, targets)
109+
testInstantiatedChaincodes(t, chaincodeID, ledger, targets)
110110

111111
}
112112

@@ -211,19 +211,27 @@ func testQueryBlock(t *testing.T, ledger fab.ChannelLedger, targets []fab.Propos
211211
}
212212
}
213213

214-
func testInstantiatedChaincodes(t *testing.T, ledger fab.ChannelLedger, targets []fab.ProposalProcessor) {
214+
func testInstantiatedChaincodes(t *testing.T, ccID string, ledger fab.ChannelLedger, targets []fab.ProposalProcessor) {
215215

216216
// Test Query Instantiated chaincodes
217217
chaincodeQueryResponses, err := ledger.QueryInstantiatedChaincodes(targets)
218218
if err != nil {
219219
t.Fatalf("QueryInstantiatedChaincodes return error: %v", err)
220220
}
221221

222+
found := false
222223
for _, chaincodeQueryResponse := range chaincodeQueryResponses {
223224
for _, chaincode := range chaincodeQueryResponse.Chaincodes {
224225
t.Logf("**InstantiatedCC: %s", chaincode)
226+
if chaincode.Name == ccID {
227+
found = true
228+
}
225229
}
226230
}
231+
232+
if !found {
233+
t.Fatalf("QueryInstantiatedChaincodes failed to find instantiated %s chaincode", ccID)
234+
}
227235
}
228236

229237
// MoveFundsAndGetTxID ...

test/integration/fab/channel_queries_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestChannelQueries(t *testing.T) {
2323

2424
testQueryChannels(t, testSetup.Channel, testSetup.Client)
2525

26-
testInstalledChaincodes(t, testSetup.Channel, testSetup.Client)
26+
testInstalledChaincodes(t, chaincodeID, testSetup.Channel, testSetup.Client)
2727

2828
testQueryByChaincode(t, testSetup.SDK.Config(), testSetup.Channel)
2929
}
@@ -60,7 +60,7 @@ func testQueryChannels(t *testing.T, channel fab.Channel, client fab.Resource) {
6060

6161
}
6262

63-
func testInstalledChaincodes(t *testing.T, channel fab.Channel, client fab.Resource) {
63+
func testInstalledChaincodes(t *testing.T, ccID string, channel fab.Channel, client fab.Resource) {
6464

6565
// Our target will be primary peer on this channel
6666
target := channel.PrimaryPeer()
@@ -71,10 +71,17 @@ func testInstalledChaincodes(t *testing.T, channel fab.Channel, client fab.Resou
7171
t.Fatalf("QueryInstalledChaincodes return error: %v", err)
7272
}
7373

74+
found := false
7475
for _, chaincode := range chaincodeQueryResponse.Chaincodes {
7576
t.Logf("**InstalledCC: %s", chaincode)
77+
if chaincode.Name == ccID {
78+
found = true
79+
}
7680
}
7781

82+
if !found {
83+
t.Fatalf("QueryInstalledChaincodes failed to find installed %s chaincode", ccID)
84+
}
7885
}
7986

8087
func testQueryByChaincode(t *testing.T, config apiconfig.Config, channel fab.Channel) {

0 commit comments

Comments
 (0)