From 0b9791849027aefbf6d58af77cc321b9b0176563 Mon Sep 17 00:00:00 2001 From: Benjamin Bollen <ben@erisindustries.com> Date: Wed, 22 Jun 2016 18:18:18 +0100 Subject: [PATCH] fix more tests in /test --- test/mock/mock_web_api_test.go | 21 ++++++++++---------- test/mock/pipe.go | 31 ++++++++++++++++++++---------- test/server/ws_burst_test.go | 6 +++--- test/testdata/testdata/testdata.go | 2 ++ 4 files changed, 37 insertions(+), 23 deletions(-) diff --git a/test/mock/mock_web_api_test.go b/test/mock/mock_web_api_test.go index fc4d9c69..378097c8 100644 --- a/test/mock/mock_web_api_test.go +++ b/test/mock/mock_web_api_test.go @@ -9,12 +9,13 @@ import ( "runtime" "testing" - "github.com/eris-ltd/eris-db/account" - core "github.com/eris-ltd/eris-db/core" + account "github.com/eris-ltd/eris-db/account" core_types "github.com/eris-ltd/eris-db/core/types" - "github.com/eris-ltd/eris-db/rpc" - "github.com/eris-ltd/eris-db/server" - td "github.com/eris-ltd/eris-db/test/testdata/testdata" + event "github.com/eris-ltd/eris-db/event" + rpc "github.com/eris-ltd/eris-db/rpc" + rpc_v0 "github.com/eris-ltd/eris-db/rpc/v0" + server "github.com/eris-ltd/eris-db/server" + td "github.com/eris-ltd/eris-db/test/testdata/testdata" "github.com/eris-ltd/eris-db/txs" "github.com/gin-gonic/gin" @@ -45,20 +46,20 @@ func (this *MockSuite) SetupSuite() { // Load the supporting objects. testData := td.LoadTestData() pipe := NewMockPipe(testData) - codec := &core_types.TCodec{} - evtSubs := core.NewEventSubscriptions(pipe.Events()) + codec := &rpc_v0.TCodec{} + evtSubs := event.NewEventSubscriptions(pipe.Events()) // The server - restServer := core.NewRestServer(codec, pipe, evtSubs) + restServer := rpc_v0.NewRestServer(codec, pipe, evtSubs) sConf := server.DefaultServerConfig() sConf.Bind.Port = 31402 // Create a server process. - proc := server.NewServeProcess(sConf, restServer) + proc, _ := server.NewServeProcess(sConf, restServer) err := proc.Start() if err != nil { panic(err) } this.serveProcess = proc - this.codec = core_types.NewTCodec() + this.codec = rpc_v0.NewTCodec() this.testData = testData this.sUrl = "http://localhost:31402" } diff --git a/test/mock/pipe.go b/test/mock/pipe.go index 21e946fc..cc6460da 100644 --- a/test/mock/pipe.go +++ b/test/mock/pipe.go @@ -1,14 +1,16 @@ package mock import ( - "github.com/eris-ltd/eris-db/account" - core_types "github.com/eris-ltd/eris-db/core/types" - definitions "github.com/eris-ltd/eris-db/definitions" - event "github.com/eris-ltd/eris-db/event" - td "github.com/eris-ltd/eris-db/test/testdata/testdata" - types "github.com/eris-ltd/eris-db/txs" + account "github.com/eris-ltd/eris-db/account" + core_types "github.com/eris-ltd/eris-db/core/types" + definitions "github.com/eris-ltd/eris-db/definitions" + event "github.com/eris-ltd/eris-db/event" + manager_types "github.com/eris-ltd/eris-db/manager/types" + td "github.com/eris-ltd/eris-db/test/testdata/testdata" + types "github.com/eris-ltd/eris-db/txs" mintTypes "github.com/tendermint/tendermint/types" + evts "github.com/tendermint/go-events" ) // Base struct. @@ -65,18 +67,27 @@ func (this *MockPipe) Events() event.EventEmitter { return this.events } -func (this *MockPipe) NameReg() core_types.NameReg { +func (this *MockPipe) NameReg() definitions.NameReg { return this.namereg } -func (this *MockPipe) Net() core_types.Net { +func (this *MockPipe) Net() definitions.Net { return this.net } -func (this *MockPipe) Transactor() core_types.Transactor { +func (this *MockPipe) Transactor() definitions.Transactor { return this.transactor } +func (this *MockPipe) GetApplication() manager_types.Application { + // TODO: [ben] mock application + return nil +} + +func (this *MockPipe) SetConsensusEngine(_ definitions.ConsensusEngine) error { + // TODO: [ben] mock consensus engine + return nil +} // Components // Accounts @@ -159,7 +170,7 @@ type eventer struct { testData *td.TestData } -func (this *eventer) Subscribe(subId, event string, callback func(events.EventData)) (bool, error) { +func (this *eventer) Subscribe(subId, event string, callback func(evts.EventData)) (bool, error) { return true, nil } diff --git a/test/server/ws_burst_test.go b/test/server/ws_burst_test.go index d7d656c9..4316af17 100644 --- a/test/server/ws_burst_test.go +++ b/test/server/ws_burst_test.go @@ -65,9 +65,9 @@ func TestWsFlooding(t *testing.T) { assert.NoError(t, errRun, "ScumSocketed!") assert.NoError(t, errStop, "ScumSocketed!") o, c, a := sc.Report() - assert.Equal(t, o, CONNS, "Server registered '%d' opened conns out of '%d'", o, CONNS) - assert.Equal(t, c, CONNS, "Server registered '%d' closed conns out of '%d'", c, CONNS) - assert.Equal(t, a, 0, "Server registered '%d' conns still active after shutting down.", a) + assert.Equal(t, uint16(o), CONNS, "Server registered '%d' opened conns out of '%d'", o, CONNS) + assert.Equal(t, uint16(c), CONNS, "Server registered '%d' closed conns out of '%d'", c, CONNS) + assert.Equal(t, uint16(a), uint16(0), "Server registered '%d' conns still active after shutting down.", a) } func runWs() error { diff --git a/test/testdata/testdata/testdata.go b/test/testdata/testdata/testdata.go index 39d24603..811ee655 100644 --- a/test/testdata/testdata/testdata.go +++ b/test/testdata/testdata/testdata.go @@ -1,6 +1,8 @@ package testdata import ( + wire "github.com/tendermint/go-wire" + account "github.com/eris-ltd/eris-db/account" core_types "github.com/eris-ltd/eris-db/core/types" event "github.com/eris-ltd/eris-db/event" -- GitLab