@@ -17,11 +17,9 @@ limitations under the License.
17
17
package main
18
18
19
19
import (
20
- "bytes"
21
20
"crypto/rand"
22
21
"crypto/x509"
23
22
"crypto/x509/pkix"
24
- "encoding/gob"
25
23
"encoding/json"
26
24
"encoding/pem"
27
25
"fmt"
@@ -77,13 +75,6 @@ func deleteExe() {
77
75
panicOnError (os .Remove (mainexe ))
78
76
}
79
77
80
- func install () {
81
- installcmd := exec .Command ("go" , "install" , maindir )
82
- installcmd .Stdout = os .Stdout
83
- installcmd .Stderr = os .Stderr
84
- panicOnError (installcmd .Run ())
85
- }
86
-
87
78
func TestMain (m * testing.M ) {
88
79
build ()
89
80
code := m .Run ()
@@ -107,7 +98,9 @@ func TestTwoReplicasBroadcastAndDeliverUsingTheSame(t *testing.T) {
107
98
if berr := Broadcast (peers [0 ], startingPort , []byte {0 , 1 , 2 , 3 , 4 }); berr != nil {
108
99
t .Errorf ("Failed to broadcast message: %s" , berr )
109
100
}
110
- if ! AssertWithTimeout (func () bool { return r .Received () == 2 }, 30 ) {
101
+ if ! AssertWithTimeout (func () bool {
102
+ return r .Received () == 2
103
+ }, 30 ) {
111
104
t .Errorf ("Failed to receive some messages. (Received %d)" , r .Received ())
112
105
}
113
106
}
@@ -128,7 +121,9 @@ func TestTenReplicasBroadcastAndDeliverUsingDifferent(t *testing.T) {
128
121
if berr := Broadcast (peers [1 ], startingPort , []byte {0 , 1 , 2 , 3 , 4 }); berr != nil {
129
122
t .Errorf ("Failed to broadcast message: %s" , berr )
130
123
}
131
- if ! AssertWithTimeout (func () bool { return r .Received () == 2 }, 30 ) {
124
+ if ! AssertWithTimeout (func () bool {
125
+ return r .Received () == 2
126
+ }, 30 ) {
132
127
t .Errorf ("Failed to receive some messages. (Received %d)" , r .Received ())
133
128
}
134
129
}
@@ -155,7 +150,9 @@ func TestFourReplicasBombedWithBroadcasts(t *testing.T) {
155
150
}
156
151
time .Sleep (time .Second )
157
152
}
158
- if ! AssertWithTimeout (func () bool { return r .Received () == broadcastCount + 1 }, 30 ) {
153
+ if ! AssertWithTimeout (func () bool {
154
+ return r .Received () == broadcastCount + 1
155
+ }, 30 ) {
159
156
t .Errorf ("Failed to receive some messages. (Received %d)" , r .Received ())
160
157
}
161
158
}
@@ -180,7 +177,9 @@ func TestTenReplicasBombedWithBroadcasts(t *testing.T) {
180
177
}
181
178
time .Sleep (time .Second )
182
179
}
183
- if ! AssertWithTimeout (func () bool { return r .Received () == broadcastCount + 1 }, 60 ) {
180
+ if ! AssertWithTimeout (func () bool {
181
+ return r .Received () == broadcastCount + 1
182
+ }, 60 ) {
184
183
t .Errorf ("Failed to receive some messages. (Received %d)" , r .Received ())
185
184
}
186
185
}
@@ -213,7 +212,9 @@ func TestTenReplicasBombedWithBroadcastsIfLedgersConsistent(t *testing.T) {
213
212
214
213
for i := 0 ; i < len (receivers ); i ++ {
215
214
r := receivers [i ]
216
- if ! AssertWithTimeout (func () bool { return r .Received () == broadcastCount + 1 }, 60 ) {
215
+ if ! AssertWithTimeout (func () bool {
216
+ return r .Received () == broadcastCount + 1
217
+ }, 60 ) {
217
218
t .Errorf ("Failed to receive some messages. (Received %d)" , r .Received ())
218
219
}
219
220
}
@@ -441,27 +442,6 @@ func generateCertificate(id uint64, keyFile string) string {
441
442
return certPath
442
443
}
443
444
444
- func readGenesisBlockChainID (path string ) string {
445
- dat , err := ioutil .ReadFile (path )
446
- panicOnError (err )
447
-
448
- buf := bytes .NewBuffer (dat )
449
- block := & cb.Block {}
450
- dec := gob .NewDecoder (buf )
451
- err = dec .Decode (block )
452
- panicOnError (err )
453
-
454
- env := & cb.Envelope {}
455
- err = proto .Unmarshal (block .Data .Data [0 ], env )
456
- panicOnError (err )
457
-
458
- payload := & cb.Payload {}
459
- err = proto .Unmarshal (env .Payload , payload )
460
- panicOnError (err )
461
-
462
- return payload .Header .ChainHeader .ChainID
463
- }
464
-
465
445
func panicOnError (err error ) {
466
446
if err != nil {
467
447
panic (err )
0 commit comments