Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: app: make SimGenesisAccount.Validate error if .BaseAccount is nil #2591

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/genesis_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,9 @@ func (sga SimGenesisAccount) Validate() error {
}
}

if sga.BaseAccount == nil {
return errors.New("BaseAccount must not be nil")
}

return sga.BaseAccount.Validate()
}
35 changes: 35 additions & 0 deletions app/genesis_account_fuzz_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package gaia

import (
"runtime/debug"
"testing"

"github.com/google/gofuzz"
)

func TestFuzzGenesisAccountValidate(t *testing.T) {
if testing.Short() {
t.Skip("running in -short mode")
}

t.Parallel()

acct := new(SimGenesisAccount)
i := 0
defer func() {
r := recover()
if r == nil {
return
}

// Otherwise report on the configuration and iteration.
t.Fatalf("Failed SimGenesisAccount on iteration #%d: %#v\n\n%s\n\n%s", i, acct, r, debug.Stack())
}()

f := fuzz.New()
for i = 0; i < 1e5; i++ {
acct = new(SimGenesisAccount)
f.Fuzz(acct)
acct.Validate()
}
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.3
github.com/golangci/golangci-lint v1.52.2
github.com/google/gofuzz v1.2.0
github.com/gorilla/mux v1.8.0
github.com/gravity-devs/liquidity v1.5.3
github.com/grpc-ecosystem/grpc-gateway v1.16.0
Expand Down