diff --git a/core/cmd/shell_local.go b/core/cmd/shell_local.go index dc0d44f3189..a1f7fdb857c 100644 --- a/core/cmd/shell_local.go +++ b/core/cmd/shell_local.go @@ -22,6 +22,7 @@ import ( gethCommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/fatih/color" + "github.com/lib/pq" "github.com/kylelemons/godebug/diff" "github.com/pkg/errors" @@ -834,7 +835,9 @@ func (m *failedToRandomizeTestDBSequencesError) Error() string { // randomizeTestDBSequences randomizes sequenced table columns sequence // This is necessary as to avoid false positives in some test cases. func randomizeTestDBSequences(db *sqlx.DB) error { - seqRows, err := db.Query(`SELECT sequence_schema, sequence_name FROM information_schema.sequences WHERE sequence_schema = $1`, "public") + // not ideal to hard code this, but also not safe to do it programmatically :( + schemas := pq.Array([]string{"public", "evm"}) + seqRows, err := db.Query(`SELECT sequence_schema, sequence_name, minimum_value FROM information_schema.sequences WHERE sequence_schema IN ($1)`, schemas) if err != nil { return fmt.Errorf("%s: error fetching sequences: %s", failedToRandomizeTestDBSequencesError{}, err) } @@ -842,7 +845,8 @@ func randomizeTestDBSequences(db *sqlx.DB) error { defer seqRows.Close() for seqRows.Next() { var sequenceSchema, sequenceName string - if err = seqRows.Scan(&sequenceSchema, &sequenceName); err != nil { + var minimumSequenceValue int64 + if err = seqRows.Scan(&sequenceSchema, &sequenceName, &minimumSequenceValue); err != nil { return fmt.Errorf("%s: failed scanning sequence rows: %s", failedToRandomizeTestDBSequencesError{}, err) } @@ -855,6 +859,7 @@ func randomizeTestDBSequences(db *sqlx.DB) error { if err != nil { return fmt.Errorf("%s: failed to generate random number", failedToRandomizeTestDBSequencesError{}) } + randNum.Add(randNum, big.NewInt(minimumSequenceValue)) if _, err = db.Exec(fmt.Sprintf("ALTER SEQUENCE %s.%s RESTART WITH %d", sequenceSchema, sequenceName, randNum)); err != nil { return fmt.Errorf("%s: failed to alter and restart %s sequence: %w", failedToRandomizeTestDBSequencesError{}, sequenceName, err)