github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/integration/nwo/standard_networks.go (about)

     1  /*
     2  Copyright hechain. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package nwo
     8  
     9  // BasicSolo is a configuration with two organizations and one peer per org.
    10  func BasicSolo() *Config {
    11  	return &Config{
    12  		Organizations: []*Organization{{
    13  			Name:          "OrdererOrg",
    14  			MSPID:         "OrdererMSP",
    15  			Domain:        "example.com",
    16  			EnableNodeOUs: false,
    17  			Users:         0,
    18  			CA:            &CA{Hostname: "ca"},
    19  		}, {
    20  			Name:          "Org1",
    21  			MSPID:         "Org1MSP",
    22  			Domain:        "org1.example.com",
    23  			EnableNodeOUs: true,
    24  			Users:         2,
    25  			CA:            &CA{Hostname: "ca"},
    26  		}, {
    27  			Name:          "Org2",
    28  			MSPID:         "Org2MSP",
    29  			Domain:        "org2.example.com",
    30  			EnableNodeOUs: true,
    31  			Users:         2,
    32  			CA:            &CA{Hostname: "ca"},
    33  		}},
    34  		Consortiums: []*Consortium{{
    35  			Name: "SampleConsortium",
    36  			Organizations: []string{
    37  				"Org1",
    38  				"Org2",
    39  			},
    40  		}},
    41  		Consensus: &Consensus{
    42  			Type:            "solo",
    43  			BootstrapMethod: "file",
    44  		},
    45  		SystemChannel: &SystemChannel{
    46  			Name:    "systemchannel",
    47  			Profile: "TwoOrgsOrdererGenesis",
    48  		},
    49  		Orderers: []*Orderer{
    50  			{Name: "orderer", Organization: "OrdererOrg"},
    51  		},
    52  		Channels: []*Channel{
    53  			{Name: "testchannel", Profile: "TwoOrgsChannel"},
    54  		},
    55  		Peers: []*Peer{{
    56  			Name:         "peer0",
    57  			Organization: "Org1",
    58  			Channels: []*PeerChannel{
    59  				{Name: "testchannel", Anchor: true},
    60  			},
    61  		}, {
    62  			Name:         "peer0",
    63  			Organization: "Org2",
    64  			Channels: []*PeerChannel{
    65  				{Name: "testchannel", Anchor: true},
    66  			},
    67  		}},
    68  		Profiles: []*Profile{{
    69  			Name:     "TwoOrgsOrdererGenesis",
    70  			Orderers: []string{"orderer"},
    71  		}, {
    72  			Name:          "TwoOrgsChannel",
    73  			Consortium:    "SampleConsortium",
    74  			Organizations: []string{"Org1", "Org2"},
    75  		}},
    76  	}
    77  }
    78  
    79  // ThreeOrgSolo returns a simple configuration with three organizations instead
    80  // of two.
    81  func ThreeOrgSolo() *Config {
    82  	config := BasicSolo()
    83  	config.Organizations = append(
    84  		config.Organizations,
    85  		&Organization{
    86  			Name:   "Org3",
    87  			MSPID:  "Org3MSP",
    88  			Domain: "org3.example.com",
    89  			Users:  2,
    90  			CA:     &CA{Hostname: "ca"},
    91  		},
    92  	)
    93  	config.Consortiums[0].Organizations = append(
    94  		config.Consortiums[0].Organizations,
    95  		"Org3",
    96  	)
    97  	config.SystemChannel.Profile = "ThreeOrgsOrdererGenesis"
    98  	config.Channels[0].Profile = "ThreeOrgsChannel"
    99  	config.Peers = append(
   100  		config.Peers,
   101  		&Peer{
   102  			Name:         "peer0",
   103  			Organization: "Org3",
   104  			Channels: []*PeerChannel{
   105  				{Name: "testchannel", Anchor: true},
   106  			},
   107  		},
   108  	)
   109  	config.Profiles = []*Profile{{
   110  		Name:     "ThreeOrgsOrdererGenesis",
   111  		Orderers: []string{"orderer"},
   112  	}, {
   113  		Name:          "ThreeOrgsChannel",
   114  		Consortium:    "SampleConsortium",
   115  		Organizations: []string{"Org1", "Org2", "Org3"},
   116  	}}
   117  
   118  	return config
   119  }
   120  
   121  // FullSolo is a configuration with two organizations and two peers per org.
   122  func FullSolo() *Config {
   123  	config := BasicSolo()
   124  
   125  	config.Peers = append(
   126  		config.Peers,
   127  		&Peer{
   128  			Name:         "peer1",
   129  			Organization: "Org1",
   130  			Channels: []*PeerChannel{
   131  				{Name: "testchannel", Anchor: false},
   132  			},
   133  		},
   134  		&Peer{
   135  			Name:         "peer1",
   136  			Organization: "Org2",
   137  			Channels: []*PeerChannel{
   138  				{Name: "testchannel", Anchor: false},
   139  			},
   140  		},
   141  	)
   142  
   143  	return config
   144  }
   145  
   146  func BasicSoloWithIdemix() *Config {
   147  	config := BasicSolo()
   148  
   149  	// Add idemix organization
   150  	config.Organizations = append(config.Organizations, &Organization{
   151  		Name:          "Org3",
   152  		MSPID:         "Org3MSP",
   153  		MSPType:       "idemix",
   154  		Domain:        "org3.example.com",
   155  		EnableNodeOUs: false,
   156  		Users:         0,
   157  		CA:            &CA{Hostname: "ca"},
   158  	})
   159  	// Add idemix organization to consortium
   160  	config.Consortiums[0].Organizations = append(config.Consortiums[0].Organizations, "Org3")
   161  	config.Profiles[1].Organizations = append(config.Profiles[1].Organizations, "Org3")
   162  
   163  	return config
   164  }
   165  
   166  func MultiChannelBasicSolo() *Config {
   167  	config := BasicSolo()
   168  
   169  	config.Channels = []*Channel{
   170  		{Name: "testchannel", Profile: "TwoOrgsChannel"},
   171  		{Name: "testchannel2", Profile: "TwoOrgsChannel"},
   172  	}
   173  
   174  	for _, peer := range config.Peers {
   175  		peer.Channels = []*PeerChannel{
   176  			{Name: "testchannel", Anchor: true},
   177  			{Name: "testchannel2", Anchor: true},
   178  		}
   179  	}
   180  
   181  	return config
   182  }
   183  
   184  func BasicKafka() *Config {
   185  	config := BasicSolo()
   186  
   187  	config.Consensus.Type = "kafka"
   188  	config.Consensus.ZooKeepers = 1
   189  	config.Consensus.Brokers = 1
   190  
   191  	return config
   192  }
   193  
   194  func BasicEtcdRaft() *Config {
   195  	config := BasicSolo()
   196  
   197  	config.Consensus.Type = "etcdraft"
   198  	config.Profiles = []*Profile{{
   199  		Name:     "SampleDevModeEtcdRaft",
   200  		Orderers: []string{"orderer"},
   201  	}, {
   202  		Name:          "TwoOrgsChannel",
   203  		Consortium:    "SampleConsortium",
   204  		Organizations: []string{"Org1", "Org2"},
   205  	}}
   206  	config.SystemChannel.Profile = "SampleDevModeEtcdRaft"
   207  
   208  	return config
   209  }
   210  
   211  func MinimalRaft() *Config {
   212  	config := BasicEtcdRaft()
   213  
   214  	config.Peers[1].Channels = nil
   215  	config.Channels = []*Channel{
   216  		{Name: "testchannel", Profile: "OneOrgChannel"},
   217  	}
   218  	config.Profiles = []*Profile{{
   219  		Name:     "SampleDevModeEtcdRaft",
   220  		Orderers: []string{"orderer"},
   221  	}, {
   222  		Name:          "OneOrgChannel",
   223  		Consortium:    "SampleConsortium",
   224  		Organizations: []string{"Org1"},
   225  	}}
   226  
   227  	return config
   228  }
   229  
   230  func ThreeOrgRaft() *Config {
   231  	config := BasicEtcdRaft()
   232  
   233  	config.Organizations = append(
   234  		config.Organizations,
   235  		&Organization{
   236  			Name:   "Org3",
   237  			MSPID:  "Org3MSP",
   238  			Domain: "org3.example.com",
   239  			Users:  2,
   240  			CA:     &CA{Hostname: "ca"},
   241  		},
   242  	)
   243  	config.Consortiums[0].Organizations = append(
   244  		config.Consortiums[0].Organizations,
   245  		"Org3",
   246  	)
   247  	config.SystemChannel.Profile = "ThreeOrgsOrdererGenesis"
   248  	config.Channels[0].Profile = "ThreeOrgsChannel"
   249  	config.Peers = append(
   250  		config.Peers,
   251  		&Peer{
   252  			Name:         "peer0",
   253  			Organization: "Org3",
   254  			Channels: []*PeerChannel{
   255  				{Name: "testchannel", Anchor: true},
   256  			},
   257  		},
   258  	)
   259  	config.Profiles = []*Profile{{
   260  		Name:     "ThreeOrgsOrdererGenesis",
   261  		Orderers: []string{"orderer"},
   262  	}, {
   263  		Name:          "ThreeOrgsChannel",
   264  		Consortium:    "SampleConsortium",
   265  		Organizations: []string{"Org1", "Org2", "Org3"},
   266  	}}
   267  
   268  	return config
   269  }
   270  
   271  func MultiChannelEtcdRaft() *Config {
   272  	config := MultiChannelBasicSolo()
   273  
   274  	config.Consensus.Type = "etcdraft"
   275  	config.Profiles = []*Profile{{
   276  		Name:     "SampleDevModeEtcdRaft",
   277  		Orderers: []string{"orderer"},
   278  	}, {
   279  		Name:          "TwoOrgsChannel",
   280  		Consortium:    "SampleConsortium",
   281  		Organizations: []string{"Org1", "Org2"},
   282  	}}
   283  	config.SystemChannel.Profile = "SampleDevModeEtcdRaft"
   284  
   285  	return config
   286  }
   287  
   288  func MultiNodeEtcdRaft() *Config {
   289  	config := BasicEtcdRaft()
   290  	config.Orderers = []*Orderer{
   291  		{Name: "orderer1", Organization: "OrdererOrg"},
   292  		{Name: "orderer2", Organization: "OrdererOrg"},
   293  		{Name: "orderer3", Organization: "OrdererOrg"},
   294  	}
   295  	config.Profiles = []*Profile{{
   296  		Name:     "SampleDevModeEtcdRaft",
   297  		Orderers: []string{"orderer1", "orderer2", "orderer3"},
   298  	}, {
   299  		Name:          "TwoOrgsChannel",
   300  		Consortium:    "SampleConsortium",
   301  		Organizations: []string{"Org1", "Org2"},
   302  	}}
   303  	return config
   304  }