Skip to content

Commit 3f994db

Browse files
authored
chore: use standard lib testing environment detection (#1631)
1 parent 55b0e54 commit 3f994db

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

frontend/cs/commitment.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@ import (
44
"crypto/rand"
55
"fmt"
66
"math/big"
7-
"os"
8-
"strings"
7+
"testing"
98

109
"github.com/consensys/gnark/constraint/solver"
1110
"github.com/consensys/gnark/debug"
1211
"github.com/consensys/gnark/logger"
1312
)
1413

1514
func Bsb22CommitmentComputePlaceholder(mod *big.Int, _ []*big.Int, output []*big.Int) (err error) {
16-
if (len(os.Args) > 0 && (strings.HasSuffix(os.Args[0], ".test") || strings.HasSuffix(os.Args[0], ".test.exe"))) || debug.Debug {
15+
if testing.Testing() || debug.Debug {
1716
// usually we only run solver without prover during testing
1817
log := logger.Logger()
1918
log.Error().Msg("Augmented commitment hint not replaced. Proof will not be sound and verification will fail!")

logger/logger.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package logger
66
import (
77
"io"
88
"os"
9-
"strings"
9+
"testing"
1010

1111
"github.com/consensys/gnark/debug"
1212
"github.com/rs/zerolog"
@@ -18,7 +18,7 @@ func init() {
1818
output := zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: "15:04:05"}
1919
logger = zerolog.New(output).With().Timestamp().Logger()
2020

21-
if !debug.Debug && strings.HasSuffix(os.Args[0], ".test") {
21+
if !debug.Debug && testing.Testing() {
2222
logger = zerolog.Nop()
2323
}
2424

0 commit comments

Comments
 (0)