@@ -12,6 +12,7 @@ import (
12
12
"fmt"
13
13
"math/rand"
14
14
"net"
15
+ "strings"
15
16
"sync"
16
17
"sync/atomic"
17
18
"testing"
@@ -21,7 +22,7 @@ import (
21
22
"github.com/hyperledger/fabric/bccsp/factory"
22
23
"github.com/hyperledger/fabric/common/configtx/test"
23
24
errors2 "github.com/hyperledger/fabric/common/errors"
24
- "github.com/hyperledger/fabric/common/flogging/floggingtest "
25
+ "github.com/hyperledger/fabric/common/flogging"
25
26
"github.com/hyperledger/fabric/common/metrics/disabled"
26
27
"github.com/hyperledger/fabric/common/util"
27
28
corecomm "github.com/hyperledger/fabric/core/comm"
@@ -48,6 +49,7 @@ import (
48
49
"github.com/hyperledger/fabric/protos/ledger/rwset"
49
50
transientstore2 "github.com/hyperledger/fabric/protos/transientstore"
50
51
"github.com/hyperledger/fabric/protoutil"
52
+ "github.com/onsi/gomega/gbytes"
51
53
"github.com/stretchr/testify/assert"
52
54
"github.com/stretchr/testify/mock"
53
55
)
@@ -751,7 +753,15 @@ func TestHaltChainProcessing(t *testing.T) {
751
753
}
752
754
}
753
755
754
- l , recorder := floggingtest .NewTestLogger (t )
756
+ buf := gbytes .NewBuffer ()
757
+ logging , err := flogging .New (flogging.Config {
758
+ LogSpec : "debug" ,
759
+ Writer : buf ,
760
+ })
761
+ assert .NoError (t , err , "failed to create logging" )
762
+
763
+ defer func (l gossiputil.Logger ) { logger = l }(logger )
764
+ l := logging .Logger ("state_test" )
755
765
logger = l
756
766
757
767
mc := & mockCommitter {Mock : & mock.Mock {}}
@@ -771,9 +781,10 @@ func TestHaltChainProcessing(t *testing.T) {
771
781
peerNode := newPeerNodeWithGossipWithValidator (0 , mc , noopPeerIdentityAcceptor , g , v )
772
782
defer peerNode .shutdown ()
773
783
gossipMsgs <- newBlockMsg (1 )
774
- assertLogged (t , recorder , "Got error while committing" )
775
- assertLogged (t , recorder , "Aborting chain processing" )
776
- assertLogged (t , recorder , "foobar" )
784
+
785
+ assertLogged (t , buf , "Got error while committing" )
786
+ assertLogged (t , buf , "Aborting chain processing" )
787
+ assertLogged (t , buf , "foobar" )
777
788
}
778
789
779
790
func TestFailures (t * testing.T ) {
@@ -1680,7 +1691,7 @@ func waitUntilTrueOrTimeout(t *testing.T, predicate func() bool, timeout time.Du
1680
1691
t .Log ("Stop waiting until timeout or true" )
1681
1692
}
1682
1693
1683
- func assertLogged (t * testing.T , r * floggingtest. Recorder , msg string ) {
1684
- observed := func () bool { return len ( r . MessagesContaining ( msg )) > 0 }
1694
+ func assertLogged (t * testing.T , buf * gbytes. Buffer , msg string ) {
1695
+ observed := func () bool { return strings . Contains ( string ( buf . Contents ()), msg ) }
1685
1696
waitUntilTrueOrTimeout (t , observed , 30 * time .Second )
1686
1697
}
0 commit comments