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-02 12:40:25 +00:00
|
|
|
type APIBuilder func() api.API
|
2019-06-29 09:19:06 +00:00
|
|
|
type testSuite struct {
|
2019-07-02 12:40:25 +00:00
|
|
|
makeNode 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-02 12:40:25 +00:00
|
|
|
makeNode: b,
|
2019-06-29 09:19:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
t.Run("version", ts.testVersion)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ts *testSuite) testVersion(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
|
|
|
fc := ts.makeNode()
|
|
|
|
|
|
|
|
v, err := fc.Version(ctx)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if v.Version != build.Version {
|
|
|
|
t.Error("Version didn't work properly")
|
|
|
|
}
|
|
|
|
}
|