Skip to content

Commit 2e02055

Browse files
Rama542adecaro
authored andcommitted
fix: use path.Join instead of filepath.Join for embed.FS reads in regression tests
embed.FS.ReadFile requires forward-slash separators on all platforms. filepath.Join produces backslashes on Windows, causing file-not-found errors. Switch all embed.FS path construction to path.Join (which always uses forward slashes) and drop the now-unused path/filepath import. Signed-off-by: Rama542 <Rama542@users.noreply.github.com>
1 parent 38e74be commit 2e02055

1 file changed

Lines changed: 25 additions & 25 deletions

File tree

token/core/zkatdlog/nogh/v1/validator/regression/regression_test.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"encoding/base64"
1212
"encoding/json"
1313
"fmt"
14-
"path/filepath"
14+
"path"
1515
"testing"
1616

1717
"github.com/hyperledger-labs/fabric-token-sdk/token"
@@ -45,25 +45,25 @@ func TestRegression(t *testing.T) {
4545
t.Parallel()
4646
for _, root := range []string{"testdata", "testdata2", "testdata3"} {
4747
for _, action := range []string{"transfers", "issues", "redeems", "swaps"} {
48-
testRegressionParallel(t, filepath.Join(root, "32-BLS12_381_BBS_GURVY"), action+"_i1_o1")
49-
testRegressionParallel(t, filepath.Join(root, "32-BLS12_381_BBS_GURVY"), action+"_i1_o2")
50-
testRegressionParallel(t, filepath.Join(root, "32-BLS12_381_BBS_GURVY"), action+"_i2_o1")
51-
testRegressionParallel(t, filepath.Join(root, "32-BLS12_381_BBS_GURVY"), action+"_i2_o2")
52-
53-
testRegressionParallel(t, filepath.Join(root, "64-BLS12_381_BBS_GURVY"), action+"_i1_o1")
54-
testRegressionParallel(t, filepath.Join(root, "64-BLS12_381_BBS_GURVY"), action+"_i1_o2")
55-
testRegressionParallel(t, filepath.Join(root, "64-BLS12_381_BBS_GURVY"), action+"_i2_o1")
56-
testRegressionParallel(t, filepath.Join(root, "64-BLS12_381_BBS_GURVY"), action+"_i2_o2")
57-
58-
testRegressionParallel(t, filepath.Join(root, "32-BN254"), action+"_i1_o1")
59-
testRegressionParallel(t, filepath.Join(root, "32-BN254"), action+"_i1_o2")
60-
testRegressionParallel(t, filepath.Join(root, "32-BN254"), action+"_i2_o1")
61-
testRegressionParallel(t, filepath.Join(root, "32-BN254"), action+"_i2_o2")
62-
63-
testRegressionParallel(t, filepath.Join(root, "64-BN254"), action+"_i1_o1")
64-
testRegressionParallel(t, filepath.Join(root, "64-BN254"), action+"_i1_o2")
65-
testRegressionParallel(t, filepath.Join(root, "64-BN254"), action+"_i2_o1")
66-
testRegressionParallel(t, filepath.Join(root, "64-BN254"), action+"_i2_o2")
48+
testRegressionParallel(t, path.Join(root, "32-BLS12_381_BBS_GURVY"), action+"_i1_o1")
49+
testRegressionParallel(t, path.Join(root, "32-BLS12_381_BBS_GURVY"), action+"_i1_o2")
50+
testRegressionParallel(t, path.Join(root, "32-BLS12_381_BBS_GURVY"), action+"_i2_o1")
51+
testRegressionParallel(t, path.Join(root, "32-BLS12_381_BBS_GURVY"), action+"_i2_o2")
52+
53+
testRegressionParallel(t, path.Join(root, "64-BLS12_381_BBS_GURVY"), action+"_i1_o1")
54+
testRegressionParallel(t, path.Join(root, "64-BLS12_381_BBS_GURVY"), action+"_i1_o2")
55+
testRegressionParallel(t, path.Join(root, "64-BLS12_381_BBS_GURVY"), action+"_i2_o1")
56+
testRegressionParallel(t, path.Join(root, "64-BLS12_381_BBS_GURVY"), action+"_i2_o2")
57+
58+
testRegressionParallel(t, path.Join(root, "32-BN254"), action+"_i1_o1")
59+
testRegressionParallel(t, path.Join(root, "32-BN254"), action+"_i1_o2")
60+
testRegressionParallel(t, path.Join(root, "32-BN254"), action+"_i2_o1")
61+
testRegressionParallel(t, path.Join(root, "32-BN254"), action+"_i2_o2")
62+
63+
testRegressionParallel(t, path.Join(root, "64-BN254"), action+"_i1_o1")
64+
testRegressionParallel(t, path.Join(root, "64-BN254"), action+"_i1_o2")
65+
testRegressionParallel(t, path.Join(root, "64-BN254"), action+"_i2_o1")
66+
testRegressionParallel(t, path.Join(root, "64-BN254"), action+"_i2_o2")
6767
}
6868
}
6969
}
@@ -79,7 +79,7 @@ func testRegressionParallel(t *testing.T, rootDir, subFolder string) {
7979
func testRegression(t *testing.T, rootDir, subFolder string) {
8080
t.Helper()
8181
t.Logf("regression test for [%s:%s]", rootDir, subFolder)
82-
paramsData, err := testDataFS.ReadFile(filepath.Join(rootDir, "params.txt"))
82+
paramsData, err := testDataFS.ReadFile(path.Join(rootDir, "params.txt"))
8383
require.NoError(t, err)
8484

8585
ppRaw, err := base64.StdEncoding.DecodeString(string(paramsData))
@@ -93,7 +93,7 @@ func testRegression(t *testing.T, rootDir, subFolder string) {
9393
TXID string `json:"txid"`
9494
}
9595
for i := range 64 {
96-
filePath := filepath.Join(
96+
filePath := path.Join(
9797
rootDir,
9898
subFolder,
9999
fmt.Sprintf("output.%d.json", i),
@@ -144,7 +144,7 @@ func TestRegressionWithMinProtocolVersionV2(t *testing.T) {
144144
// Test with one representative sample from each testdata directory
145145
for _, root := range []string{"testdata", "testdata2", "testdata3"} {
146146
for _, variant := range []string{"32-BLS12_381_BBS_GURVY", "64-BLS12_381_BBS_GURVY", "32-BN254", "64-BN254"} {
147-
testRegressionWithMinVersionParallel(t, filepath.Join(root, variant), "transfers_i1_o1")
147+
testRegressionWithMinVersionParallel(t, path.Join(root, variant), "transfers_i1_o1")
148148
}
149149
}
150150
}
@@ -161,7 +161,7 @@ func testRegressionWithMinVersion(t *testing.T, rootDir, subFolder string) {
161161
t.Helper()
162162
t.Logf("regression test with MinProtocolVersion=V2 for [%s:%s]", rootDir, subFolder)
163163

164-
paramsData, err := testDataFS.ReadFile(filepath.Join(rootDir, "params.txt"))
164+
paramsData, err := testDataFS.ReadFile(path.Join(rootDir, "params.txt"))
165165
require.NoError(t, err)
166166

167167
ppRaw, err := base64.StdEncoding.DecodeString(string(paramsData))
@@ -177,7 +177,7 @@ func testRegressionWithMinVersion(t *testing.T, rootDir, subFolder string) {
177177
}
178178

179179
// Test just the first vector - all vectors in testdata are V1
180-
filePath := filepath.Join(rootDir, subFolder, "output.0.json")
180+
filePath := path.Join(rootDir, subFolder, "output.0.json")
181181
jsonData, err := testDataFS.ReadFile(filePath)
182182
require.NoError(t, err)
183183

0 commit comments

Comments
 (0)