Skip to content

Commit 9981150

Browse files
committed
Remove unused function from SBFT test
Change-Id: I10c7f78a6ee072cffa0d6b65700d99c3a326a455 Signed-off-by: Gabor Hosszu <[email protected]>
1 parent 94e282f commit 9981150

File tree

1 file changed

+15
-35
lines changed

1 file changed

+15
-35
lines changed

orderer/sbft/main/network_test.go

+15-35
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ limitations under the License.
1717
package main
1818

1919
import (
20-
"bytes"
2120
"crypto/rand"
2221
"crypto/x509"
2322
"crypto/x509/pkix"
24-
"encoding/gob"
2523
"encoding/json"
2624
"encoding/pem"
2725
"fmt"
@@ -77,13 +75,6 @@ func deleteExe() {
7775
panicOnError(os.Remove(mainexe))
7876
}
7977

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-
8778
func TestMain(m *testing.M) {
8879
build()
8980
code := m.Run()
@@ -107,7 +98,9 @@ func TestTwoReplicasBroadcastAndDeliverUsingTheSame(t *testing.T) {
10798
if berr := Broadcast(peers[0], startingPort, []byte{0, 1, 2, 3, 4}); berr != nil {
10899
t.Errorf("Failed to broadcast message: %s", berr)
109100
}
110-
if !AssertWithTimeout(func() bool { return r.Received() == 2 }, 30) {
101+
if !AssertWithTimeout(func() bool {
102+
return r.Received() == 2
103+
}, 30) {
111104
t.Errorf("Failed to receive some messages. (Received %d)", r.Received())
112105
}
113106
}
@@ -128,7 +121,9 @@ func TestTenReplicasBroadcastAndDeliverUsingDifferent(t *testing.T) {
128121
if berr := Broadcast(peers[1], startingPort, []byte{0, 1, 2, 3, 4}); berr != nil {
129122
t.Errorf("Failed to broadcast message: %s", berr)
130123
}
131-
if !AssertWithTimeout(func() bool { return r.Received() == 2 }, 30) {
124+
if !AssertWithTimeout(func() bool {
125+
return r.Received() == 2
126+
}, 30) {
132127
t.Errorf("Failed to receive some messages. (Received %d)", r.Received())
133128
}
134129
}
@@ -155,7 +150,9 @@ func TestFourReplicasBombedWithBroadcasts(t *testing.T) {
155150
}
156151
time.Sleep(time.Second)
157152
}
158-
if !AssertWithTimeout(func() bool { return r.Received() == broadcastCount+1 }, 30) {
153+
if !AssertWithTimeout(func() bool {
154+
return r.Received() == broadcastCount+1
155+
}, 30) {
159156
t.Errorf("Failed to receive some messages. (Received %d)", r.Received())
160157
}
161158
}
@@ -180,7 +177,9 @@ func TestTenReplicasBombedWithBroadcasts(t *testing.T) {
180177
}
181178
time.Sleep(time.Second)
182179
}
183-
if !AssertWithTimeout(func() bool { return r.Received() == broadcastCount+1 }, 60) {
180+
if !AssertWithTimeout(func() bool {
181+
return r.Received() == broadcastCount+1
182+
}, 60) {
184183
t.Errorf("Failed to receive some messages. (Received %d)", r.Received())
185184
}
186185
}
@@ -213,7 +212,9 @@ func TestTenReplicasBombedWithBroadcastsIfLedgersConsistent(t *testing.T) {
213212

214213
for i := 0; i < len(receivers); i++ {
215214
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) {
217218
t.Errorf("Failed to receive some messages. (Received %d)", r.Received())
218219
}
219220
}
@@ -441,27 +442,6 @@ func generateCertificate(id uint64, keyFile string) string {
441442
return certPath
442443
}
443444

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-
465445
func panicOnError(err error) {
466446
if err != nil {
467447
panic(err)

0 commit comments

Comments
 (0)