@@ -17,6 +17,7 @@ limitations under the License.
17
17
package main
18
18
19
19
import (
20
+ "flag"
20
21
"io/ioutil"
21
22
"os"
22
23
"testing"
@@ -65,7 +66,7 @@ func TestInspectConfigTx(t *testing.T) {
65
66
configTxDest := tmpDir + string (os .PathSeparator ) + "configtx"
66
67
67
68
factory .InitFactories (nil )
68
- config := genesisconfig .Load (genesisconfig .SampleInsecureProfile )
69
+ config := genesisconfig .Load (genesisconfig .SampleSingleMSPChannelProfile )
69
70
70
71
assert .NoError (t , doOutputChannelCreateTx (config , "foo" , configTxDest ), "Good outputChannelCreateTx generation request" )
71
72
assert .NoError (t , doInspectChannelCreateTx (configTxDest ), "Good configtx inspection request" )
@@ -75,30 +76,50 @@ func TestGenerateAnchorPeersUpdate(t *testing.T) {
75
76
configTxDest := tmpDir + string (os .PathSeparator ) + "anchorPeerUpdate"
76
77
77
78
factory .InitFactories (nil )
78
- config := genesisconfig .Load (genesisconfig .SampleSingleMSPSoloProfile )
79
+ config := genesisconfig .Load (genesisconfig .SampleSingleMSPChannelProfile )
79
80
80
81
assert .NoError (t , doOutputAnchorPeersUpdate (config , "foo" , configTxDest , genesisconfig .SampleOrgName ), "Good anchorPeerUpdate request" )
81
82
}
82
83
83
- func TestFlags (t * testing.T ) {
84
- blockDest := tmpDir + string (os .PathSeparator ) + "block"
84
+ func TestConfigTxFlags (t * testing.T ) {
85
85
configTxDest := tmpDir + string (os .PathSeparator ) + "configtx"
86
+ configTxDestAnchorPeers := tmpDir + string (os .PathSeparator ) + "configtxAnchorPeers"
86
87
oldArgs := os .Args
87
- defer func () { os .Args = oldArgs }()
88
+ defer func () {
89
+ os .Args = oldArgs
90
+ flag .CommandLine = flag .NewFlagSet (os .Args [0 ], flag .ExitOnError )
91
+ }()
88
92
os .Args = []string {
89
93
"cmd" ,
90
- "-outputBlock=" + blockDest ,
91
94
"-outputCreateChannelTx=" + configTxDest ,
92
- "-profile=" + genesisconfig .SampleSingleMSPSoloProfile ,
93
- "-inspectBlock=" + blockDest ,
95
+ "-profile=" + genesisconfig .SampleSingleMSPChannelProfile ,
94
96
"-inspectChannelCreateTx=" + configTxDest ,
95
- "-outputAnchorPeersUpdate=" + configTxDest ,
97
+ "-outputAnchorPeersUpdate=" + configTxDestAnchorPeers ,
96
98
"-asOrg=" + genesisconfig .SampleOrgName ,
97
99
}
98
100
main ()
99
101
102
+ _ , err := os .Stat (configTxDest )
103
+ assert .NoError (t , err , "Configtx file is written successfully" )
104
+ _ , err = os .Stat (configTxDestAnchorPeers )
105
+ assert .NoError (t , err , "Configtx anchor peers file is written successfully" )
106
+ }
107
+
108
+ func TestBlockFlags (t * testing.T ) {
109
+ blockDest := tmpDir + string (os .PathSeparator ) + "block"
110
+ oldArgs := os .Args
111
+ defer func () {
112
+ os .Args = oldArgs
113
+ flag .CommandLine = flag .NewFlagSet (os .Args [0 ], flag .ExitOnError )
114
+ }()
115
+ os .Args = []string {
116
+ "cmd" ,
117
+ "-profile=" + genesisconfig .SampleSingleMSPSoloProfile ,
118
+ "-outputBlock=" + blockDest ,
119
+ "-inspectBlock=" + blockDest ,
120
+ }
121
+ main ()
122
+
100
123
_ , err := os .Stat (blockDest )
101
124
assert .NoError (t , err , "Block file is written successfully" )
102
- _ , err = os .Stat (configTxDest )
103
- assert .NoError (t , err , "Configtx file is written successfully" )
104
125
}
0 commit comments