lotus/chain/vm/validation_test.go

73 lines
1.8 KiB
Go
Raw Normal View History

package vm_test
import (
"fmt"
2020-05-12 18:14:00 +00:00
"github.com/filecoin-project/chain-validation/suites/message"
"reflect"
"runtime"
"strings"
"testing"
suites "github.com/filecoin-project/chain-validation/suites"
factory "github.com/filecoin-project/lotus/chain/validation"
)
// TestSkipper contains a list of test cases skipped by the implementation.
type TestSkipper struct {
testSkips []suites.TestCase
}
// Skip return true if the sutire.TestCase should be skipped.
func (ts *TestSkipper) Skip(test suites.TestCase) bool {
for _, skip := range ts.testSkips {
if reflect.ValueOf(skip).Pointer() == reflect.ValueOf(test).Pointer() {
fmt.Printf("=== SKIP %v\n", runtime.FuncForPC(reflect.ValueOf(test).Pointer()).Name())
return true
}
}
return false
}
2020-02-27 22:17:08 +00:00
// TestSuiteSkips contains tests we wish to skip.
var TestSuiteSkipper TestSkipper
2020-02-27 22:17:08 +00:00
func init() {
// initialize the test skipper with tests being skipped
TestSuiteSkipper = TestSkipper{testSkips: []suites.TestCase{
2020-05-12 18:14:00 +00:00
message.MessageTest_NestedSends,
2020-04-17 20:44:13 +00:00
// tests to skip go here
}}
}
func TestChainValidationMessageSuite(t *testing.T) {
f := factory.NewFactories()
for _, testCase := range suites.MessageTestCases() {
if TestSuiteSkipper.Skip(testCase) {
continue
}
t.Run(caseName(testCase), func(t *testing.T) {
testCase(t, f)
})
}
}
2020-02-27 22:17:08 +00:00
func TestChainValidationTipSetSuite(t *testing.T) {
2020-05-11 21:13:02 +00:00
t.Skip("bls sigs changed")
f := factory.NewFactories()
for _, testCase := range suites.TipSetTestCases() {
if TestSuiteSkipper.Skip(testCase) {
continue
}
t.Run(caseName(testCase), func(t *testing.T) {
testCase(t, f)
})
}
2019-12-16 11:47:11 +00:00
}
func caseName(testCase suites.TestCase) string {
fqName := runtime.FuncForPC(reflect.ValueOf(testCase).Pointer()).Name()
toks := strings.Split(fqName, ".")
return toks[len(toks)-1]
}