Skip to content

Commit 8aab6a8

Browse files
committed
commnets + lint fix
Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
1 parent bc613fa commit 8aab6a8

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

token/core/zkatdlog/nogh/v1/benchmark/setup_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
17
package benchmark
28

39
import (

token/core/zkatdlog/nogh/v1/validator/testdata/env_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
17
package testdata
28

39
import (
@@ -23,7 +29,7 @@ func TestSaveTransferToFile(t *testing.T) {
2329
assert.NoError(t, err)
2430

2531
var payload struct {
26-
TxID string `json:"txid"`
32+
TxID string `json:"txid"`
2733
ReqRaw string `json:"req_raw"`
2834
}
2935
err = json.Unmarshal(b, &payload)

token/core/zkatdlog/nogh/v1/validator/testdata/generator/main.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
17
package main
28

39
import (
@@ -8,14 +14,14 @@ import (
814

915
"github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/v1/benchmark"
1016
"github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/v1/validator/testdata"
11-
benchmark2 "github.com/hyperledger-labs/fabric-token-sdk/token/services/benchmark"
17+
sbenchmark "github.com/hyperledger-labs/fabric-token-sdk/token/services/benchmark"
1218
)
1319

1420
//go:generate go run . -bits=32,64 -curves=BN254,BLS12_381_BBS_GURVY
1521
func main() {
1622
flag.Parse()
1723
// generate setup
18-
bits, curves, _, err := benchmark2.GenerateCasesWithDefaults()
24+
bits, curves, _, err := sbenchmark.GenerateCasesWithDefaults()
1925
if err != nil {
2026
panic(err)
2127
}
@@ -36,7 +42,7 @@ func main() {
3642
}
3743

3844
for i := range 64 {
39-
env, err := testdata.NewEnv(&benchmark2.Case{
45+
env, err := testdata.NewEnv(&sbenchmark.Case{
4046
Bits: configuration.Bits,
4147
CurveID: configuration.CurveID,
4248
NumInputs: 2,

token/core/zkatdlog/nogh/v1/validator/validator_test.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,19 @@ func TestParallelBenchmarkValidatorTransfer(t *testing.T) {
113113
)
114114
}
115115

116+
// TestRegression runs previously recorded regression test vectors contained in the
117+
// `testdata/<variant>` directories. Each directory contains a `params.txt` and a
118+
// sequence of JSON files under `transfers/output.<n>.json` representing serialized
119+
// token requests and their associated txids. The test unmarshals each recorded
120+
// request and verifies it against the validator to ensure the library remains
121+
// backwards compatible.
122+
//
123+
// Notes:
124+
// - The testdata used here is generated by `testdata/generator`. If you need to
125+
// re-generate vectors for a new setup, run that generator and commit the
126+
// produced artifacts to the corresponding `testdata/...` directory.
127+
// - The test expects 64 transfer vectors (output.0..output.63). Update the loop
128+
// range in `testRegression` if you add or remove vectors.
116129
func TestRegression(t *testing.T) {
117130
testRegression(t, "testdata/32-BLS12_381_BBS_GURVY")
118131
testRegression(t, "testdata/64-BLS12_381_BBS_GURVY")
@@ -141,7 +154,7 @@ func testRegression(t *testing.T, rootDir string) {
141154
err = json.Unmarshal(jsonData, &tokenData)
142155
require.NoError(t, err)
143156
_, _, err = tokenValidator.UnmarshallAndVerifyWithMetadata(
144-
context.Background(),
157+
t.Context(),
145158
&fakeLedger{},
146159
token.RequestAnchor(tokenData.TXID),
147160
tokenData.ReqRaw,
@@ -188,6 +201,6 @@ func tokenServicesFactory(bytes []byte) (tcc.PublicParameters, tcc.Validator, er
188201

189202
type fakeLedger struct{}
190203

191-
func (*fakeLedger) GetState(id tk.ID) ([]byte, error) {
204+
func (*fakeLedger) GetState(_ tk.ID) ([]byte, error) {
192205
panic("ciao")
193206
}

0 commit comments

Comments
 (0)