Skip to content

Commit

Permalink
port python gen utility to rust
Browse files Browse the repository at this point in the history
  • Loading branch information
ralexstokes committed Jun 7, 2023
1 parent 2de276d commit ee61cd6
Show file tree
Hide file tree
Showing 7 changed files with 575 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[workspace]
resolver = "2"

members = [
"ssz-rs",
"ssz-rs-derive",
"ssz-rs-test-gen"
]
15 changes: 15 additions & 0 deletions ssz-rs-test-gen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "ssz-rs-test-gen"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"
readme = "./README.md"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = "1.0"
serde_yaml = "0.9"
num-bigint = "0.4.3"
hex = "0.4.3"
convert_case = "0.6.0"
11 changes: 11 additions & 0 deletions ssz-rs-test-gen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ssz-rs-test-gen

Utility for generating the integration tests for `ssz_rs`.

## How to use

```bash
just clean
just download-integration-tests
just generate-all
```
33 changes: 33 additions & 0 deletions ssz-rs-test-gen/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
default-fmt := "true"

generate-all:
#!/usr/bin/env sh
for TYP in basic_vector bitlist bitvector boolean containers uints; do
just generate $TYP false
done;
just fmt
generate TYPE FMT=default-fmt:
cargo run -p ssz-rs-test-gen {{TYPE}}
if {{FMT}} == true; then just fmt; fi

fmt:
cargo +nightly fmt --all

generate-clean:
rm -rf ../ssz-rs/tests/data

download-integration-tests: integration-tests-clean
#!/usr/bin/env sh
TESTS_TAG=$(cat spec-test-version)
REPO_NAME=consensus-spec-tests
CONFIG="general"
mkdir ${REPO_NAME}
wget https://github.com/ethereum/${REPO_NAME}/releases/download/${TESTS_TAG}/${CONFIG}.tar.gz
tar -xzf ${CONFIG}.tar.gz -C ${REPO_NAME}
rm -f *tar.gz
integration-tests-clean:
rm -rf consensus-spec-tests

clean: generate-clean integration-tests-clean
1 change: 1 addition & 0 deletions ssz-rs-test-gen/spec-test-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v1.3.0
Loading

0 comments on commit ee61cd6

Please sign in to comment.