Documentation
¶
Overview ¶
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- Variables
- func CheckCorset(t *testing.T, stdlib bool, test string, fields ...field.Config)
- func CheckCorsetNoPadding(t *testing.T, stdlib bool, test string, fields ...field.Config)
- func CheckInvalid(t *testing.T, test, ext, prefix string, compiler ErrorCompiler)
- func CheckValid(t *testing.T, test, ext string, config Config)
- func CheckWithFields(t *testing.T, stdlib bool, test string, padding bool, fields ...field.Config)
- func CompileMachine(field field.Config, srcfiles ...source.File) []source.SyntaxError
- func CompileZkc(field field.Config, srcfile source.File) []source.SyntaxError
- func ExtractAttributes[T any](srcfile *source.File, attributes ...Attribute[T]) ([]T, []error)
- func ReadTracesFile(filename string) []lt.TraceFile
- type Attribute
- type Config
- func (p Config) Checkpoints(fn string, n uint64) Config
- func (p Config) Constraints(flag bool) Config
- func (p Config) FastModeSplitting(flag bool) Config
- func (p Config) GoGen(flag bool) Config
- func (p Config) MaxStaticDepths(depths ...uint) Config
- func (p Config) Padding(strategies map[string]ir.PaddingStrategy) Config
- func (p Config) Splitting(flag bool) Config
- func (p Config) Verbose(flag bool) Config
- type ErrorCompiler
- type LegacyTestConfig
- type TestCase
- type TestConfig
Constants ¶
const TestDir = "../../testdata"
TestDir determines the (relative) location of the test directory. That is where the corset test files (lisp) and the corresponding traces (accepts/rejects) are found.
Variables ¶
var ( // ALL_FIELDS defines the set of all known fields for testing ALL_FIELDS = []field.Config{field.BLS12_377, field.KOALABEAR_16, field.GF_8209} // DEFAULT_WORD sets the default word for fast mode execution. DEFAULT_WORD = vm.WORD_UINT128 // DEFAULT_FIELDS set default fields for testing DEFAULT_FIELDS = []field.Config{field.KOALABEAR_16} // DEFAULT_CONFIG sets a default testing configuration DEFAULT_CONFIG = Config{ // contains filtered or unexported fields } )
var FIELD_REGEX *regexp.Regexp
FIELD_REGEX is used to restrict which fields will be tested. This is primarily useful for the CI pipeline where we want to test individual fields in separate runners.
var LEGACY_TESTFILE_EXTENSIONS []LegacyTestConfig = []LegacyTestConfig{ {"accepts", true, true, true, "", allOptLevels}, {"accepts.bz2", true, true, true, "", allOptLevels}, {"auto.accepts", true, true, true, "", allOptLevels}, {"auto.accepts.bz2", true, true, true, "", allOptLevels}, {"expanded.accepts", true, false, false, "BLS12_377", allOptLevels}, {"expanded.O1.accepts", true, false, false, "BLS12_377", defaultOptLevel}, {"rejects", false, true, false, "", allOptLevels}, {"rejects.bz2", false, true, false, "", allOptLevels}, {"auto.rejects", false, true, false, "", allOptLevels}, {"bls12_377.rejects", false, true, false, "BLS12_377", allOptLevels}, {"koalabear_16.rejects", false, true, false, "KOALABEAR_16", defaultOptLevel}, {"gf_8209.rejects", false, true, false, "GF_8209", defaultOptLevel}, {"expanded.koalabear_16.rejects", false, false, false, "KOALABEAR_16", defaultOptLevel}, {"expanded.gf_8209.rejects", false, false, false, "GF_8209", defaultOptLevel}, {"expanded.rejects", false, false, false, "BLS12_377", allOptLevels}, {"expanded.O1.rejects", false, false, false, "BLS12_377", defaultOptLevel}, }
LEGACY_TESTFILE_EXTENSIONS identifies the possible file extensions used for different test inputs.
var SRC_EXTENSIONS = []string{"lisp"}
SRC_EXTENSIONS identifies the set of currently recognised extensions for constraint source files.
var TESTFILE_EXTENSIONS []TestConfig = []TestConfig{ {"accepts", true, nil}, {"accepts.bz2", true, nil}, {"gf_251.accepts", true, &field.GF_251}, {"gf_8209.accepts", true, &field.GF_8209}, {"koalabear_16.accepts", true, &field.KOALABEAR_16}, {"bls12_377.accepts", true, &field.BLS12_377}, {"rejects", false, nil}, {"rejects.bz2", false, nil}, {"gf_251.rejects", false, &field.GF_251}, {"gf_8209.rejects", false, &field.GF_8209}, {"koalabear_16.rejects", false, &field.KOALABEAR_16}, {"bls12_377.rejects", false, &field.BLS12_377}, }
TESTFILE_EXTENSIONS identifies the possible file extensions used for different test inputs.
Functions ¶
func CheckCorset ¶
CheckCorset checks that all traces which we expect to be accepted are accepted by a given set of constraints, and all traces that we expect to be rejected are rejected. All fields provided are tested against, both with and without padding (whereby every module's length is expanded up to the next power of two).
func CheckCorsetNoPadding ¶
CheckCorsetNoPadding checks that all traces which we expect to be accepted are accepted by a given set of constraints, and all traces that we expect to be rejected are rejected. All fields provided are tested against but without any padding. This is useful to reduce unnecessary testing for cases where we know padding is not relevant.
func CheckInvalid ¶
func CheckInvalid(t *testing.T, test, ext, prefix string, compiler ErrorCompiler)
Check that a given source file fails to compiler. nolint
func CheckValid ¶
CheckValid checks that a given source file compiles without any errors. nolint
func CheckWithFields ¶
CheckWithFields checks that all traces which we expect to be accepted are accepted by a given set of constraints, and all traces that we expect to be rejected are rejected. All fields provided are tested against.
func CompileMachine ¶
CompileMachine compiles one or more zkc source files into a base machine for executing tests with.
func CompileZkc ¶
CompileZkc compiles a single zkc source file, potentially producing errors. This includes both the validation phase and the code generation phase.
func ExtractAttributes ¶
ExtractAttributes extracts any matches attributes at the beginning of a source file.
func ReadTracesFile ¶
ReadTracesFile reads a file containing zero or more traces expressed as JSON, where each trace is on a separate line.
Types ¶
type Attribute ¶
Attribute provides a generic mechanism for extract attributes from the beginning of a file. Parse a given line (assuming it has matched) producing an item and, potentially, one or more syntax errors.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config for testing
func (Config) Checkpoints ¶ added in v1.2.21
Checkpoints enables checkpoint testing with checkpoints at every n ZkC instructions.
func (Config) Constraints ¶
Constraints determines whether or not to check constraints.
func (Config) FastModeSplitting ¶ added in v1.2.21
FastModeSplitting determines whether or not to apply register splitting in fast mode.
func (Config) GoGen ¶
GoGen determines whether or not to additionally run the generated-Go ("native") executor and check its outputs against the test. This is experimental and only applies to the Uint64 word; programs the generator cannot yet handle are skipped rather than failed (see runGogenExecutionTest).
func (Config) MaxStaticDepths ¶ added in v1.2.21
MaxStaticDepths sets the maximum depths (i.e. number of rows) of static range tables to test with.
func (Config) Padding ¶ added in v1.2.21
func (p Config) Padding(strategies map[string]ir.PaddingStrategy) Config
Padding determines how much front padding is added to the generated trace.
type ErrorCompiler ¶
type ErrorCompiler func(source.File) []source.SyntaxError
ErrorCompiler compiles a source file and produces zero or more errors.
type LegacyTestConfig ¶
type LegacyTestConfig struct {
// contains filtered or unexported fields
}
LegacyTestConfig provides a simple mechanism for searching for testfiles.
type TestCase ¶
type TestCase struct {
// contains filtered or unexported fields
}
TestCase represents a line in a file
func ReadTestsFile ¶
func ReadTestsFile(t *testing.T, cfg TestConfig, test string) []TestCase
ReadTestsFile reads a file containing zero or more tests expressed as JSON, where each test is on a separate line.
type TestConfig ¶
type TestConfig struct {
// contains filtered or unexported fields
}
TestConfig provides a simple mechanism for searching for testfiles.