@@ -45,10 +45,12 @@ import (
4545 "github.com/hyperledger/firefly-common/pkg/fftls"
4646 "github.com/hyperledger/firefly-common/pkg/i18n"
4747 "github.com/hyperledger/firefly-common/pkg/metric"
48+ "github.com/sirupsen/logrus"
4849 "golang.org/x/time/rate"
4950
5051 "github.com/jarcoal/httpmock"
5152 "github.com/stretchr/testify/assert"
53+ "github.com/stretchr/testify/require"
5254)
5355
5456const configDir = "../../test/data/config"
@@ -608,6 +610,8 @@ func TestBadKeyPair(t *testing.T) {
608610}
609611
610612func TestMTLSClientWithServer (t * testing.T ) {
613+ logrus .SetLevel (logrus .TraceLevel )
614+
611615 // Create an X509 certificate pair
612616 privatekey , _ := rsa .GenerateKey (rand .Reader , 2048 )
613617 publickey := & privatekey .PublicKey
@@ -661,13 +665,11 @@ func TestMTLSClientWithServer(t *testing.T) {
661665
662666 ctx , cancelCtx := context .WithCancel (context .Background ())
663667 go func () {
664- select {
665- case <- ctx .Done ():
666- shutdownContext , cancel := context .WithTimeout (context .Background (), 2 * time .Second )
667- defer cancel ()
668- if err := server .Shutdown (shutdownContext ); err != nil {
669- return
670- }
668+ <- ctx .Done ()
669+ shutdownContext , cancel := context .WithTimeout (context .Background (), 2 * time .Second )
670+ defer cancel ()
671+ if err := server .Shutdown (shutdownContext ); err != nil {
672+ return
671673 }
672674 }()
673675
@@ -809,3 +811,11 @@ func TestHooks(t *testing.T) {
809811 assert .Equal (t , onSuccessCount , 1 )
810812
811813}
814+
815+ func TestTrace (t * testing.T ) {
816+ require .Equal (t , "plain" , traceBody ("plain" ))
817+ require .Equal (t , "plain" , traceBody ([]byte ("plain" )))
818+ require .Equal (t , "" , traceBody (nil ))
819+ require .JSONEq (t , `{"some":"data"}` , traceBody (map [string ]string {"some" : "data" }))
820+ require .Equal (t , `(binary reader)` , traceBody (strings .NewReader ("data to stream" )))
821+ }
0 commit comments