lotus/api/test/test.go

39 lines
724 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-02 12:40:25 +00:00
type APIBuilder func() api.API
type testSuite struct {
2019-07-02 12:40:25 +00:00
makeNode 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-02 12:40:25 +00:00
makeNode: b,
}
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")
}
}