2019-06-29 09:19:06 +00:00
|
|
|
package test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/go-lotus/api"
|
|
|
|
"github.com/filecoin-project/go-lotus/build"
|
|
|
|
)
|
|
|
|
|
2019-07-02 13:05:43 +00:00
|
|
|
// APIBuilder is a function which is invoked in test suite to provide
|
|
|
|
// test nodes and networks
|
2019-07-09 16:27:07 +00:00
|
|
|
type APIBuilder func(t *testing.T, n int) []api.API
|
2019-06-29 09:19:06 +00:00
|
|
|
type testSuite struct {
|
2019-07-09 16:27:07 +00:00
|
|
|
makeNodes APIBuilder
|
2019-06-29 09:19:06 +00:00
|
|
|
}
|
|
|
|
|
2019-07-02 13:05:43 +00:00
|
|
|
// TestApis is the entry point to API test suite
|
2019-07-02 12:40:25 +00:00
|
|
|
func TestApis(t *testing.T, b APIBuilder) {
|
2019-06-29 09:19:06 +00:00
|
|
|
ts := testSuite{
|
2019-07-09 16:27:07 +00:00
|
|
|
makeNodes: b,
|
2019-06-29 09:19:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
t.Run("version", ts.testVersion)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ts *testSuite) testVersion(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
2019-07-09 16:27:07 +00:00
|
|
|
fc := ts.makeNodes(t, 1)[0]
|
2019-06-29 09:19:06 +00:00
|
|
|
|
|
|
|
v, err := fc.Version(ctx)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if v.Version != build.Version {
|
|
|
|
t.Error("Version didn't work properly")
|
|
|
|
}
|
|
|
|
}
|