Skip to content

Commit

Permalink
Make build-fuzz work again, test it on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
kostko committed Feb 19, 2020
1 parent 8a75be1 commit 81cf908
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 6 deletions.
8 changes: 8 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ steps:
plugins:
<<: *docker_plugin

- label: Test fuzz builds
branches: master kostko/fix/build-fuzz
command:
- . .buildkite/scripts/skip_if_only_docs_changes.sh
- make -C go build-fuzz
plugins:
<<: *docker_plugin

# Wait for all jobs defined before this point
# to finish running in parallel before continuing.
- wait
Expand Down
1 change: 1 addition & 0 deletions .changelog/2695.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make build-fuzz work again, test it on CI
6 changes: 4 additions & 2 deletions go/consensus/tendermint/abci/mux_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ package abci

import (
"context"

upgrade "github.com/oasislabs/oasis-core/go/upgrade/api"
)

// MockABCIMux exports some of the muxer's internal methods for testing use.
Expand All @@ -22,8 +24,8 @@ func (mux *MockABCIMux) MockClose() {
}

// NewMockMux creates a new ABCI mux suitable for testing.
func NewMockMux(ctx context.Context, cfg *ApplicationConfig) (*MockABCIMux, error) {
mux, err := newABCIMux(ctx, cfg)
func NewMockMux(ctx context.Context, upgrader upgrade.Backend, cfg *ApplicationConfig) (*MockABCIMux, error) {
mux, err := newABCIMux(ctx, upgrader, cfg)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion go/consensus/tendermint/apps/staking/proposing_rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ func (app *stakingApplication) rewardBlockProposing(ctx *abci.Context, stakeStat
if err != nil {
return fmt.Errorf("app state getting current epoch: %w", err)
}
if epoch == epochtime.EpochInvalid {
invalidEpoch := epochtime.EpochInvalid // Workaround for incorrect go-fuzz instrumentation.
if epoch == invalidEpoch {
ctx.Logger().Info("rewardBlockProposing: this block does not belong to an epoch. no block proposing reward")
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion go/consensus/tendermint/fuzz/fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/oasislabs/oasis-core/go/consensus/tendermint/apps/epochtime_mock"
registryApp "github.com/oasislabs/oasis-core/go/consensus/tendermint/apps/registry"
stakingApp "github.com/oasislabs/oasis-core/go/consensus/tendermint/apps/staking"
"github.com/oasislabs/oasis-core/go/upgrade"
)

var (
Expand Down Expand Up @@ -53,7 +54,7 @@ func Fuzz(data []byte) int {
}

// The muxer will start with the previous state, if it exists (the state database isn't cleared).
muxer, _ := abci.NewMockMux(ctx, appConfig)
muxer, _ := abci.NewMockMux(ctx, upgrade.NewDummyUpgradeManager(), appConfig)
defer muxer.MockClose()

for _, app := range FuzzableApps {
Expand Down
3 changes: 2 additions & 1 deletion go/storage/fuzz/fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"context"
"io/ioutil"

"github.com/oasislabs/oasis-core/go/common"
"github.com/oasislabs/oasis-core/go/common/crypto/signature"
"github.com/oasislabs/oasis-core/go/common/crypto/signature/signers/file"
commonFuzz "github.com/oasislabs/oasis-core/go/common/fuzz"
Expand Down Expand Up @@ -40,7 +41,7 @@ func init() {
}

// Create the storage backend service.
storageBackend, err = storage.New(context.Background(), localDB, identity, nil, nil)
storageBackend, err = storage.New(context.Background(), localDB, common.Namespace{}, identity, nil, nil)
if err != nil {
panic(err)
}
Expand Down
3 changes: 2 additions & 1 deletion go/storage/fuzz/gencorpus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"io/ioutil"

"github.com/oasislabs/oasis-core/go/common"
commonFuzz "github.com/oasislabs/oasis-core/go/common/fuzz"
"github.com/oasislabs/oasis-core/go/common/identity"
"github.com/oasislabs/oasis-core/go/storage"
Expand All @@ -19,7 +20,7 @@ const (
)

func main() {
storage, err := storage.New(context.Background(), "/tmp/oasis-node-fuzz-storage", &identity.Identity{}, nil, nil)
storage, err := storage.New(context.Background(), "/tmp/oasis-node-fuzz-storage", common.Namespace{}, &identity.Identity{}, nil, nil)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 81cf908

Please sign in to comment.