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

Commit db2b8eb

Browse files
author
Baha Shaaban
committed
[FAB-12464] z build failing due to Integration error
It seems the z build returns a deterministic random value when calling rand.Intn(n) which results in tests generating the same values for install/instantiate CCs. This fix adds a time based seed to ensure the random value is non deterministic Change-Id: I88dd8a31bca6acd563b41ca68ba5e9c0d03784be Signed-off-by: Baha Shaaban <baha.shaaban@securekey.com>
1 parent e0602c4 commit db2b8eb

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

ci.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#
2+
# Copyright SecureKey Technologies Inc. All Rights Reserved.
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
17
GO_VER=1.10
28
GO_MIN_VER=1.10
39
GO_MAX_VER=1.10.4

test/integration/utils.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"os"
1313
"strings"
1414
"testing"
15+
"time"
1516

1617
mspclient "github.com/hyperledger/fabric-sdk-go/pkg/client/msp"
1718
"github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt"
@@ -40,8 +41,10 @@ func GenerateRandomID() string {
4041
func randomString(strlen int) string {
4142
const chars = "abcdefghijklmnopqrstuvwxyz0123456789"
4243
result := make([]byte, strlen)
44+
seed := rand.NewSource(time.Now().UnixNano())
45+
rnd := rand.New(seed)
4346
for i := 0; i < strlen; i++ {
44-
result[i] = chars[rand.Intn(len(chars))]
47+
result[i] = chars[rnd.Intn(len(chars))]
4548
}
4649
return string(result)
4750
}

0 commit comments

Comments
 (0)