github.com/s7techlab/cckit@v0.10.5/extensions/pinger/pinger_test.go (about) 1 package pinger 2 3 import ( 4 "testing" 5 6 . "github.com/onsi/ginkgo" 7 . "github.com/onsi/gomega" 8 9 "github.com/s7techlab/cckit/identity/testdata" 10 "github.com/s7techlab/cckit/router" 11 testcc "github.com/s7techlab/cckit/testing" 12 expectcc "github.com/s7techlab/cckit/testing/expect" 13 ) 14 15 func TestPinger(t *testing.T) { 16 RegisterFailHandler(Fail) 17 RunSpecs(t, "Pinger suite") 18 } 19 20 var ( 21 Someone = testdata.Certificates[1].MustIdentity(`SOME_MSP`) 22 ) 23 24 func New() *router.Chaincode { 25 r := router.New(`pingable`). 26 Init(router.EmptyContextHandler). 27 Invoke(FuncPing, Ping) 28 return router.NewChaincode(r) 29 } 30 31 var _ = Describe(`Pinger`, func() { 32 33 // Create chaincode mock 34 cc := testcc.NewMockStub(`cars`, New()) 35 36 Describe("Pinger", func() { 37 38 It("Allow anyone to invoke ping method", func() { 39 //invoke chaincode method from authority actor 40 pingInfo := expectcc.PayloadIs(cc.From(Someone).Invoke(FuncPing), &PingInfo{}).(*PingInfo) 41 Expect(pingInfo.InvokerId).To(Equal(Someone.GetID())) 42 Expect(pingInfo.InvokerCert).To(Equal(Someone.GetPEM())) 43 Expect(pingInfo.EndorsingServerTime).To(Not(BeNil())) 44 Expect(pingInfo.TxTime).To(Not(BeNil())) 45 }) 46 }) 47 })