Skip to content

Commit

Permalink
Merge pull request #4538 from filecoin-project/steb/test-cleanup-proofs
Browse files Browse the repository at this point in the history
Cleanup test initialization and always validate VRFs in tests
  • Loading branch information
magik6k authored Oct 23, 2020
2 parents 2cf770c + 4a550d1 commit 2c3d804
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 37 deletions.
3 changes: 0 additions & 3 deletions api/test/ccupgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package test
import (
"context"
"fmt"
"os"
"sync/atomic"
"testing"
"time"
Expand All @@ -17,8 +16,6 @@ import (
)

func TestCCUpgrade(t *testing.T, b APIBuilder, blocktime time.Duration) {
_ = os.Setenv("BELLMAN_NO_GPU", "1")

for _, height := range []abi.ChainEpoch{
1, // before
162, // while sealing
Expand Down
17 changes: 0 additions & 17 deletions api/test/deals.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ import (

"github.com/ipfs/go-cid"
files "github.com/ipfs/go-ipfs-files"
logging "github.com/ipfs/go-log/v2"
"github.com/ipld/go-car"

"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
"github.com/filecoin-project/lotus/miner"
dag "github.com/ipfs/go-merkledag"
dstest "github.com/ipfs/go-merkledag/test"
unixfile "github.com/ipfs/go-unixfs/file"
Expand All @@ -34,18 +31,7 @@ import (
ipld "github.com/ipfs/go-ipld-format"
)

var MineNext = miner.MineReq{
InjectNulls: 0,
Done: func(bool, abi.ChainEpoch, error) {},
}

func init() {
logging.SetAllLoggers(logging.LevelInfo)
build.InsecurePoStValidation = true
}

func TestDealFlow(t *testing.T, b APIBuilder, blocktime time.Duration, carExport, fastRet bool) {
_ = os.Setenv("BELLMAN_NO_GPU", "1")

ctx := context.Background()
n, sn := b(t, OneFull, OneMiner)
Expand Down Expand Up @@ -82,7 +68,6 @@ func TestDealFlow(t *testing.T, b APIBuilder, blocktime time.Duration, carExport
}

func TestDoubleDealFlow(t *testing.T, b APIBuilder, blocktime time.Duration) {
_ = os.Setenv("BELLMAN_NO_GPU", "1")

ctx := context.Background()
n, sn := b(t, OneFull, OneMiner)
Expand Down Expand Up @@ -146,7 +131,6 @@ func makeDeal(t *testing.T, ctx context.Context, rseed int, client *impl.FullNod
}

func TestFastRetrievalDealFlow(t *testing.T, b APIBuilder, blocktime time.Duration) {
_ = os.Setenv("BELLMAN_NO_GPU", "1")

ctx := context.Background()
n, sn := b(t, OneFull, OneMiner)
Expand Down Expand Up @@ -201,7 +185,6 @@ func TestFastRetrievalDealFlow(t *testing.T, b APIBuilder, blocktime time.Durati
}

func TestSenondDealRetrieval(t *testing.T, b APIBuilder, blocktime time.Duration) {
_ = os.Setenv("BELLMAN_NO_GPU", "1")

ctx := context.Background()
n, sn := b(t, OneFull, OneMiner)
Expand Down
3 changes: 0 additions & 3 deletions api/test/mining.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"fmt"
"math/rand"
"os"
"sync/atomic"
"testing"
"time"
Expand Down Expand Up @@ -88,8 +87,6 @@ func (ts *testSuite) testMiningReal(t *testing.T) {
}

func TestDealMining(t *testing.T, b APIBuilder, blocktime time.Duration, carExport bool) {
_ = os.Setenv("BELLMAN_NO_GPU", "1")

// test making a deal with a fresh miner, and see if it starts to mine

ctx := context.Background()
Expand Down
3 changes: 0 additions & 3 deletions api/test/paych.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package test
import (
"context"
"fmt"
"os"
"sync/atomic"
"testing"
"time"
Expand All @@ -28,8 +27,6 @@ import (
)

func TestPaymentChannels(t *testing.T, b APIBuilder, blocktime time.Duration) {
_ = os.Setenv("BELLMAN_NO_GPU", "1")

ctx := context.Background()
n, sn := b(t, TwoFull, OneMiner)

Expand Down
17 changes: 17 additions & 0 deletions api/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package test

import (
"context"
"fmt"
"os"
"testing"
"time"

"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/types"

logging "github.com/ipfs/go-log/v2"
"github.com/multiformats/go-multiaddr"

"github.com/stretchr/testify/assert"
Expand All @@ -22,6 +25,15 @@ import (
"github.com/filecoin-project/lotus/node"
)

func init() {
logging.SetAllLoggers(logging.LevelInfo)
err := os.Setenv("BELLMAN_NO_GPU", "1")
if err != nil {
panic(fmt.Sprintf("failed to set BELLMAN_NO_GPU env variable: %s", err))
}
build.InsecurePoStValidation = true
}

type TestNode struct {
api.FullNode
// ListenAddr is the address on which an API server is listening, if an
Expand Down Expand Up @@ -110,6 +122,11 @@ var FullNodeWithUpgradeAt = func(upgradeHeight abi.ChainEpoch) FullNodeOpts {
}
}

var MineNext = miner.MineReq{
InjectNulls: 0,
Done: func(bool, abi.ChainEpoch, error) {},
}

func (ts *testSuite) testVersion(t *testing.T) {
build.RunningNodeType = build.NodeFull

Expand Down
8 changes: 0 additions & 8 deletions api/test/window_post.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"sync/atomic"

"os"
"strings"
"testing"
"time"
Expand All @@ -24,13 +23,6 @@ import (
"github.com/filecoin-project/lotus/node/impl"
)

func init() {
err := os.Setenv("BELLMAN_NO_GPU", "1")
if err != nil {
panic(fmt.Sprintf("failed to set BELLMAN_NO_GPU env variable: %s", err))
}
}

func TestPledgeSector(t *testing.T, b APIBuilder, blocktime time.Duration, nSectors int) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down
3 changes: 0 additions & 3 deletions chain/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -1731,9 +1731,6 @@ func (syncer *Syncer) collectChain(ctx context.Context, ts *types.TipSet) error
}

func VerifyElectionPoStVRF(ctx context.Context, worker address.Address, rand []byte, evrf []byte) error {
if build.InsecurePoStValidation {
return nil
}
return gen.VerifyVRF(ctx, worker, rand, evrf)
}

Expand Down

0 comments on commit 2c3d804

Please sign in to comment.