Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix minor unreachable code caused by t.Fatal #3574

Merged
merged 1 commit into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions core/common/ccpackage/ccpackage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,35 +288,30 @@ func TestMain(m *testing.M) {
// setup the MSP manager so that we can sign/verify
err := msptesttools.LoadMSPSetupForTesting()
if err != nil {
os.Exit(-1)
fmt.Printf("Could not initialize msp")
return
os.Exit(-1)
}

cryptoProvider, err := sw.NewDefaultSecurityLevelWithKeystore(sw.NewDummyKeyStore())
if err != nil {
fmt.Printf("Initialize cryptoProvider bccsp failed: %s", cryptoProvider)
os.Exit(-1)
return
}
localmsp = mspmgmt.GetLocalMSP(cryptoProvider)
if localmsp == nil {
os.Exit(-1)
fmt.Printf("Could not get msp")
return
os.Exit(-1)
}
signer, err = localmsp.GetDefaultSigningIdentity()
if err != nil {
os.Exit(-1)
fmt.Printf("Could not get signer")
return
os.Exit(-1)
}

signerSerialized, err = signer.Serialize()
if err != nil {
os.Exit(-1)
fmt.Printf("Could not serialize identity")
return
os.Exit(-1)
}

os.Exit(m.Run())
Expand Down
12 changes: 0 additions & 12 deletions gossip/privdata/coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,14 +607,10 @@ func TestCoordinatorStoreInvalidBlock(t *testing.T) {
iterator, err := store.GetTxPvtRWSetByTxid(txn, nil)
if err != nil {
t.Fatalf("Failed iterating, got err %s", err)
iterator.Close()
return
}
res, err := iterator.Next()
if err != nil {
t.Fatalf("Failed iterating, got err %s", err)
iterator.Close()
return
}
require.Nil(t, res)
iterator.Close()
Expand Down Expand Up @@ -928,14 +924,10 @@ func TestCoordinatorToFilterOutPvtRWSetsWithWrongHash(t *testing.T) {
iterator, err := store.GetTxPvtRWSetByTxid(txn, nil)
if err != nil {
t.Fatalf("Failed iterating, got err %s", err)
iterator.Close()
return
}
res, err := iterator.Next()
if err != nil {
t.Fatalf("Failed iterating, got err %s", err)
iterator.Close()
return
}
require.Nil(t, res)
iterator.Close()
Expand Down Expand Up @@ -1433,14 +1425,10 @@ func TestProceedWithoutPrivateData(t *testing.T) {
iterator, err := store.GetTxPvtRWSetByTxid(txn, nil)
if err != nil {
t.Fatalf("Failed iterating, got err %s", err)
iterator.Close()
return
}
res, err := iterator.Next()
if err != nil {
t.Fatalf("Failed iterating, got err %s", err)
iterator.Close()
return
}
require.Nil(t, res)
iterator.Close()
Expand Down
3 changes: 1 addition & 2 deletions gossip/state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1767,9 +1767,8 @@ func waitUntilTrueOrTimeout(t *testing.T, predicate func() bool, timeout time.Du
t.Log("Done.")
break
case <-time.After(timeout):
t.Fatal("Timeout has expired")
close(ch)
break
t.Fatal("Timeout has expired")
}
t.Log("Stop waiting until timeout or true")
}
12 changes: 4 additions & 8 deletions protoutil/proputils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,28 +480,24 @@ func TestMain(m *testing.M) {
// setup the MSP manager so that we can sign/verify
err := msptesttools.LoadMSPSetupForTesting()
if err != nil {
os.Exit(-1)
fmt.Printf("Could not initialize msp")
return
os.Exit(-1)
}
cryptoProvider, err := sw.NewDefaultSecurityLevelWithKeystore(sw.NewDummyKeyStore())
if err != nil {
os.Exit(-1)
fmt.Printf("Could not initialize cryptoProvider")
return
os.Exit(-1)
}
signer, err = mspmgmt.GetLocalMSP(cryptoProvider).GetDefaultSigningIdentity()
if err != nil {
os.Exit(-1)
fmt.Printf("Could not get signer")
return
os.Exit(-1)
}

signerSerialized, err = signer.Serialize()
if err != nil {
os.Exit(-1)
fmt.Printf("Could not serialize identity")
return
os.Exit(-1)
}

os.Exit(m.Run())
Expand Down