github.com/tenywen/fabric@v1.0.0-beta.0.20170620030522-a5b1ed380643/common/configtx/test/helper_test.go (about)

     1  /*
     2  Copyright IBM Corp. 2017 All Rights Reserved.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8                   http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package test
    18  
    19  import (
    20  	"os"
    21  	"path/filepath"
    22  	"testing"
    23  
    24  	"github.com/hyperledger/fabric/core/config"
    25  	"github.com/hyperledger/fabric/msp"
    26  	logging "github.com/op/go-logging"
    27  )
    28  
    29  func init() {
    30  	// Configuration is always specified relative to $GOPATH/github.com/hyperledger/fabric
    31  	// This test will fail with the default configuration if executed in the package dir
    32  	// We are in common/configtx/test
    33  	os.Chdir(filepath.Join("..", "..", ".."))
    34  
    35  	logging.SetLevel(logging.DEBUG, "")
    36  }
    37  
    38  func TestMakeGenesisBlock(t *testing.T) {
    39  	_, err := MakeGenesisBlock("foo")
    40  	if err != nil {
    41  		t.Fatalf("Error making genesis block: %s", err)
    42  	}
    43  }
    44  
    45  func TestMakeGenesisBlockFromMSPs(t *testing.T) {
    46  
    47  	mspDir, err := config.GetDevMspDir()
    48  	if err != nil {
    49  		t.Fatalf("Error getting DevMspDir: %s", err)
    50  	}
    51  
    52  	ordererOrgID := "TestOrdererOrg"
    53  	appOrgID := "TestAppOrg"
    54  	appMSPConf, err := msp.GetLocalMspConfig(mspDir, nil, appOrgID)
    55  	if err != nil {
    56  		t.Fatalf("Error making genesis block from MSPs: %s", err)
    57  	}
    58  	ordererMSPConf, err := msp.GetLocalMspConfig(mspDir, nil, ordererOrgID)
    59  	if err != nil {
    60  		t.Fatalf("Error making genesis block from MSPs: %s", err)
    61  	}
    62  	_, err = MakeGenesisBlockFromMSPs("foo", appMSPConf, ordererMSPConf, appOrgID, ordererOrgID)
    63  	if err != nil {
    64  		t.Fatalf("Error making genesis block from MSPs: %s", err)
    65  	}
    66  }
    67  
    68  func TestOrdererTemplate(t *testing.T) {
    69  	_ = OrdererTemplate()
    70  }
    71  
    72  func TestOrdererOrgTemplate(t *testing.T) {
    73  	_ = OrdererOrgTemplate()
    74  }
    75  
    76  func TestApplicationOrgTemplate(t *testing.T) {
    77  	_ = ApplicationOrgTemplate()
    78  }
    79  
    80  func TestCompositeTemplate(t *testing.T) {
    81  	_ = CompositeTemplate()
    82  }