Skip to content

Commit d9f90e4

Browse files
committed
clone SchemaStack during testing
This alters the testing mechanism to clone the schema stack inbetween test runs. The purpose of this is to ensure that each test is run with a fresh stack to protect against any unexpected aliasing issues. However, at this time, it fails because various components need to be registered with relevant interfaces.
1 parent 4d1b474 commit d9f90e4

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

pkg/asm/program.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/consensys/go-corset/pkg/util/collection/array"
2626
"github.com/consensys/go-corset/pkg/util/collection/iter"
2727
"github.com/consensys/go-corset/pkg/util/field"
28+
"github.com/consensys/go-corset/pkg/util/word"
2829
)
2930

3031
// MixedProgram represents the composition of an assembly program along with
@@ -189,4 +190,6 @@ func (p *MixedProgram[F, T, M]) GobDecode(data []byte) error {
189190

190191
func init() {
191192
gob.Register(MacroComponent(&MacroFunction{}))
193+
gob.Register(schema.AnySchema[word.BigEndian](&MacroHirProgram{}))
194+
gob.Register(schema.AnySchema[word.BigEndian](&MicroHirProgram{}))
192195
}

pkg/test/util/check_valid.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ func checkTraces[F field.Element[F]](t *testing.T, test string, maxPadding uint,
228228
t.Run(test, func(t *testing.T) {
229229
// Enable parallel testing
230230
t.Parallel()
231+
// Clone localStack to ensure complete separation between tests.
232+
localStack := stack.Clone()
231233
//
232234
for _, ir := range []string{"MIR", "AIR"} {
233235
for i, tf := range traces {
@@ -239,13 +241,13 @@ func checkTraces[F field.Element[F]](t *testing.T, test string, maxPadding uint,
239241
//
240242
if tf.RawModules() != nil {
241243
// Construct trace identifier
242-
id := traceId{stack.RegisterMapping().Field().Name, ir, test,
244+
id := traceId{localStack.RegisterMapping().Field().Name, ir, test,
243245
cfg.expected, cfg.expand, cfg.validate, opt, parallel, i + 1, padding}
244246
//
245247
if cfg.expand || ir == "AIR" {
246248
// Always check if expansion required, otherwise
247249
// only check AIR constraints.
248-
checkTrace(t, tf, id, stack.ConcreteSchemaOf(ir), stack.RegisterMapping())
250+
checkTrace(t, tf, id, localStack.ConcreteSchemaOf(ir), localStack.RegisterMapping())
249251
}
250252
}
251253
}

0 commit comments

Comments
 (0)