lotus/api/test/test.go

39 lines
755 B
Go
Raw Normal View History

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
type testSuite struct {
2019-07-09 16:27:07 +00:00
makeNodes APIBuilder
}
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) {
ts := testSuite{
2019-07-09 16:27:07 +00:00
makeNodes: b,
}
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]
v, err := fc.Version(ctx)
if err != nil {
t.Fatal(err)
}
if v.Version != build.Version {
t.Error("Version didn't work properly")
}
}