Skip to content
Snippets Groups Projects
Unverified Commit 0b979184 authored by Benjamin Bollen's avatar Benjamin Bollen
Browse files

fix more tests in /test

parent 564e8423
No related branches found
No related tags found
No related merge requests found
...@@ -9,12 +9,13 @@ import ( ...@@ -9,12 +9,13 @@ import (
"runtime" "runtime"
"testing" "testing"
"github.com/eris-ltd/eris-db/account" account "github.com/eris-ltd/eris-db/account"
core "github.com/eris-ltd/eris-db/core"
core_types "github.com/eris-ltd/eris-db/core/types" core_types "github.com/eris-ltd/eris-db/core/types"
"github.com/eris-ltd/eris-db/rpc" event "github.com/eris-ltd/eris-db/event"
"github.com/eris-ltd/eris-db/server" rpc "github.com/eris-ltd/eris-db/rpc"
td "github.com/eris-ltd/eris-db/test/testdata/testdata" 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/eris-ltd/eris-db/txs"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
...@@ -45,20 +46,20 @@ func (this *MockSuite) SetupSuite() { ...@@ -45,20 +46,20 @@ func (this *MockSuite) SetupSuite() {
// Load the supporting objects. // Load the supporting objects.
testData := td.LoadTestData() testData := td.LoadTestData()
pipe := NewMockPipe(testData) pipe := NewMockPipe(testData)
codec := &core_types.TCodec{} codec := &rpc_v0.TCodec{}
evtSubs := core.NewEventSubscriptions(pipe.Events()) evtSubs := event.NewEventSubscriptions(pipe.Events())
// The server // The server
restServer := core.NewRestServer(codec, pipe, evtSubs) restServer := rpc_v0.NewRestServer(codec, pipe, evtSubs)
sConf := server.DefaultServerConfig() sConf := server.DefaultServerConfig()
sConf.Bind.Port = 31402 sConf.Bind.Port = 31402
// Create a server process. // Create a server process.
proc := server.NewServeProcess(sConf, restServer) proc, _ := server.NewServeProcess(sConf, restServer)
err := proc.Start() err := proc.Start()
if err != nil { if err != nil {
panic(err) panic(err)
} }
this.serveProcess = proc this.serveProcess = proc
this.codec = core_types.NewTCodec() this.codec = rpc_v0.NewTCodec()
this.testData = testData this.testData = testData
this.sUrl = "http://localhost:31402" this.sUrl = "http://localhost:31402"
} }
......
package mock package mock
import ( import (
"github.com/eris-ltd/eris-db/account" account "github.com/eris-ltd/eris-db/account"
core_types "github.com/eris-ltd/eris-db/core/types" core_types "github.com/eris-ltd/eris-db/core/types"
definitions "github.com/eris-ltd/eris-db/definitions" definitions "github.com/eris-ltd/eris-db/definitions"
event "github.com/eris-ltd/eris-db/event" event "github.com/eris-ltd/eris-db/event"
td "github.com/eris-ltd/eris-db/test/testdata/testdata" manager_types "github.com/eris-ltd/eris-db/manager/types"
types "github.com/eris-ltd/eris-db/txs" td "github.com/eris-ltd/eris-db/test/testdata/testdata"
types "github.com/eris-ltd/eris-db/txs"
mintTypes "github.com/tendermint/tendermint/types" mintTypes "github.com/tendermint/tendermint/types"
evts "github.com/tendermint/go-events"
) )
// Base struct. // Base struct.
...@@ -65,18 +67,27 @@ func (this *MockPipe) Events() event.EventEmitter { ...@@ -65,18 +67,27 @@ func (this *MockPipe) Events() event.EventEmitter {
return this.events return this.events
} }
func (this *MockPipe) NameReg() core_types.NameReg { func (this *MockPipe) NameReg() definitions.NameReg {
return this.namereg return this.namereg
} }
func (this *MockPipe) Net() core_types.Net { func (this *MockPipe) Net() definitions.Net {
return this.net return this.net
} }
func (this *MockPipe) Transactor() core_types.Transactor { func (this *MockPipe) Transactor() definitions.Transactor {
return this.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 // Components
// Accounts // Accounts
...@@ -159,7 +170,7 @@ type eventer struct { ...@@ -159,7 +170,7 @@ type eventer struct {
testData *td.TestData 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 return true, nil
} }
......
...@@ -65,9 +65,9 @@ func TestWsFlooding(t *testing.T) { ...@@ -65,9 +65,9 @@ func TestWsFlooding(t *testing.T) {
assert.NoError(t, errRun, "ScumSocketed!") assert.NoError(t, errRun, "ScumSocketed!")
assert.NoError(t, errStop, "ScumSocketed!") assert.NoError(t, errStop, "ScumSocketed!")
o, c, a := sc.Report() o, c, a := sc.Report()
assert.Equal(t, o, CONNS, "Server registered '%d' opened conns out of '%d'", o, CONNS) assert.Equal(t, uint16(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, uint16(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(a), uint16(0), "Server registered '%d' conns still active after shutting down.", a)
} }
func runWs() error { func runWs() error {
......
package testdata package testdata
import ( import (
wire "github.com/tendermint/go-wire"
account "github.com/eris-ltd/eris-db/account" account "github.com/eris-ltd/eris-db/account"
core_types "github.com/eris-ltd/eris-db/core/types" core_types "github.com/eris-ltd/eris-db/core/types"
event "github.com/eris-ltd/eris-db/event" event "github.com/eris-ltd/eris-db/event"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment