2019-11-12 19:23:59 +00:00
|
|
|
package vm_test
|
|
|
|
|
|
|
|
import (
|
2020-03-03 01:33:18 +00:00
|
|
|
"fmt"
|
|
|
|
"reflect"
|
|
|
|
"runtime"
|
2019-11-12 19:23:59 +00:00
|
|
|
"testing"
|
|
|
|
|
2020-03-03 01:33:18 +00:00
|
|
|
suites "github.com/filecoin-project/chain-validation/suites"
|
2020-03-12 17:22:45 +00:00
|
|
|
"github.com/filecoin-project/chain-validation/suites/tipset"
|
2019-11-12 19:23:59 +00:00
|
|
|
|
2020-03-03 01:33:18 +00:00
|
|
|
factory "github.com/filecoin-project/lotus/chain/validation"
|
2019-11-12 19:23:59 +00:00
|
|
|
)
|
|
|
|
|
2020-03-03 01:33:18 +00:00
|
|
|
// TestSkipper contains a list of test cases skipped by the implementation.
|
|
|
|
type TestSkipper struct {
|
|
|
|
testSkips []suites.TestCase
|
|
|
|
}
|
2019-11-12 19:23:59 +00:00
|
|
|
|
2020-03-03 01:33:18 +00:00
|
|
|
// 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
|
|
|
|
2020-03-03 01:33:18 +00:00
|
|
|
// TestSuiteSkips contains tests we wish to skip.
|
|
|
|
var TestSuiteSkipper TestSkipper
|
2020-02-27 22:17:08 +00:00
|
|
|
|
2020-03-03 01:33:18 +00:00
|
|
|
func init() {
|
|
|
|
// initialize the test skipper with tests being skipped
|
|
|
|
TestSuiteSkipper = TestSkipper{testSkips: []suites.TestCase{
|
2020-03-05 21:25:57 +00:00
|
|
|
/* tests to skip go here */
|
2020-03-12 17:22:45 +00:00
|
|
|
tipset.TestInternalMessageApplicationFailure,
|
|
|
|
tipset.TestInvalidSenderAddress,
|
2020-03-03 01:33:18 +00:00
|
|
|
}}
|
2019-11-12 19:23:59 +00:00
|
|
|
}
|
2019-12-09 17:55:24 +00:00
|
|
|
|
2020-03-03 01:33:18 +00:00
|
|
|
func TestChainValidationMessageSuite(t *testing.T) {
|
|
|
|
f := factory.NewFactories()
|
|
|
|
for _, testCase := range suites.MessageTestCases() {
|
|
|
|
if TestSuiteSkipper.Skip(testCase) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
testCase(t, f)
|
|
|
|
}
|
|
|
|
}
|
2020-02-27 22:17:08 +00:00
|
|
|
|
2020-03-03 01:33:18 +00:00
|
|
|
func TestChainValidationTipSetSuite(t *testing.T) {
|
|
|
|
f := factory.NewFactories()
|
|
|
|
for _, testCase := range suites.TipSetTestCases() {
|
|
|
|
if TestSuiteSkipper.Skip(testCase) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
testCase(t, f)
|
|
|
|
}
|
2019-12-16 11:47:11 +00:00
|
|
|
}
|