diff --git a/fabric-client/chain_test.go b/fabric-client/chain_test.go index d487716bb1..0a543d111c 100644 --- a/fabric-client/chain_test.go +++ b/fabric-client/chain_test.go @@ -33,6 +33,23 @@ import ( var testAddress = "0.0.0.0:5244" +var validRootCA = `-----BEGIN CERTIFICATE----- +MIICYjCCAgmgAwIBAgIUB3CTDOU47sUC5K4kn/Caqnh114YwCgYIKoZIzj0EAwIw +fzELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNh +biBGcmFuY2lzY28xHzAdBgNVBAoTFkludGVybmV0IFdpZGdldHMsIEluYy4xDDAK +BgNVBAsTA1dXVzEUMBIGA1UEAxMLZXhhbXBsZS5jb20wHhcNMTYxMDEyMTkzMTAw +WhcNMjExMDExMTkzMTAwWjB/MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZv +cm5pYTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEfMB0GA1UEChMWSW50ZXJuZXQg +V2lkZ2V0cywgSW5jLjEMMAoGA1UECxMDV1dXMRQwEgYDVQQDEwtleGFtcGxlLmNv +bTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABKIH5b2JaSmqiQXHyqC+cmknICcF +i5AddVjsQizDV6uZ4v6s+PWiJyzfA/rTtMvYAPq/yeEHpBUB1j053mxnpMujYzBh +MA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQXZ0I9 +qp6CP8TFHZ9bw5nRtZxIEDAfBgNVHSMEGDAWgBQXZ0I9qp6CP8TFHZ9bw5nRtZxI +EDAKBggqhkjOPQQDAgNHADBEAiAHp5Rbp9Em1G/UmKn8WsCbqDfWecVbZPQj3RK4 +oG5kQQIgQAe4OOKYhJdh3f7URaKfGTf492/nmRmtK+ySKjpHSrU= +-----END CERTIFICATE----- +` + func TestChainMethods(t *testing.T) { client := NewClient() chain, err := NewChain("testChain", client) @@ -268,6 +285,7 @@ func TestChainInitializeFromOrderer(t *testing.T) { org2MSPID, }, OrdererAddress: "localhost:7054", + RootCA: validRootCA, }, Index: 0, LastConfigIndex: 0, @@ -321,6 +339,7 @@ func TestOrganizationUnits(t *testing.T) { org2MSPID, }, OrdererAddress: "localhost:7054", + RootCA: validRootCA, }, Index: 0, LastConfigIndex: 0, @@ -371,6 +390,7 @@ func TestChainInitializeFromUpdate(t *testing.T) { org2MSPID, }, OrdererAddress: "localhost:7054", + RootCA: validRootCA, }, } diff --git a/fabric-client/mocks/mockdata.go b/fabric-client/mocks/mockdata.go index 1a5d5fea67..99186360f0 100644 --- a/fabric-client/mocks/mockdata.go +++ b/fabric-client/mocks/mockdata.go @@ -20,9 +20,6 @@ limitations under the License. package mocks import ( - "io/ioutil" - "log" - "github.com/hyperledger/fabric-sdk-go/fabric-client/util" fabric_config "github.com/hyperledger/fabric/common/config" ledger_util "github.com/hyperledger/fabric/core/ledger/util" @@ -47,6 +44,7 @@ type MockConfigGroupBuilder struct { ModPolicy string OrdererAddress string MSPNames []string + RootCA string } // MockConfigBlockBuilder is used to build a mock Chain configuration block @@ -260,19 +258,11 @@ func (b *MockConfigGroupBuilder) buildfabricMSPConfig(name string) *mb.FabricMSP IntermediateCerts: [][]byte{}, OrganizationalUnitIdentifiers: []*mb.FabricOUIdentifier{}, RevocationList: [][]byte{}, - RootCerts: [][]byte{b.buildRootCertBytes()}, + RootCerts: [][]byte{[]byte(b.RootCA)}, SigningIdentity: nil, } } -func (b *MockConfigGroupBuilder) buildRootCertBytes() []byte { - pem, err := ioutil.ReadFile("../test/fixtures/root.pem") - if err != nil { - log.Fatal(err) - } - return pem -} - func (b *MockConfigGroupBuilder) buildBasicConfigPolicy() *common.ConfigPolicy { return &common.ConfigPolicy{ Version: b.Version,