Skip to content
Snippets Groups Projects
Commit 2405c7c0 authored by Wei Tang's avatar Wei Tang
Browse files

ssztests: embed all yamltests directly in rust tests (under spectests feature)

parent 658748b9
Branches
No related merge requests found
#!/usr/bin/env bash
set -euo pipefail
scripts/run_minimal.sh
scripts/run_mainnet.sh
#!/usr/bin/env bash
set -euo pipefail
cargo run --release -- --config full -r attestation res/spectests/tests/operations/attestation/attestation_mainnet.yaml
cargo run --release -- --config full -r attester_slashing res/spectests/tests/operations/attester_slashing/attester_slashing_mainnet.yaml
cargo run --release -- --config full -r block_header res/spectests/tests/operations/block_header/block_header_mainnet.yaml
cargo run --release -- --config full -r deposit res/spectests/tests/operations/deposit/deposit_mainnet.yaml
cargo run --release -- --config full -r proposer_slashing res/spectests/tests/operations/proposer_slashing/proposer_slashing_mainnet.yaml
cargo run --release -- --config full -r transfer res/spectests/tests/operations/transfer/transfer_mainnet.yaml
cargo run --release -- --config full -r voluntary_exit res/spectests/tests/operations/voluntary_exit/voluntary_exit_mainnet.yaml
cargo run --release -- --config full -r crosslinks res/spectests/tests/epoch_processing/crosslinks/crosslinks_mainnet.yaml
cargo run --release -- --config full -r registry_updates res/spectests/tests/epoch_processing/registry_updates/registry_updates_mainnet.yaml
cargo run --release -- --config full -r blocks res/spectests/tests/sanity/blocks/sanity_blocks_mainnet.yaml
cargo run --release -- --config full -r slots res/spectests/tests/sanity/slots/sanity_slots_mainnet.yaml
#!/usr/bin/env bash
set -euo pipefail
cargo run --release -- -r attestation res/spectests/tests/operations/attestation/attestation_minimal.yaml
cargo run --release -- -r attester_slashing res/spectests/tests/operations/attester_slashing/attester_slashing_minimal.yaml
cargo run --release -- -r block_header res/spectests/tests/operations/block_header/block_header_minimal.yaml
cargo run --release -- -r deposit res/spectests/tests/operations/deposit/deposit_minimal.yaml
cargo run --release -- -r proposer_slashing res/spectests/tests/operations/proposer_slashing/proposer_slashing_minimal.yaml
cargo run --release -- -r transfer res/spectests/tests/operations/transfer/transfer_minimal.yaml
cargo run --release -- -r voluntary_exit res/spectests/tests/operations/voluntary_exit/voluntary_exit_minimal.yaml
cargo run --release -- -r crosslinks res/spectests/tests/epoch_processing/crosslinks/crosslinks_minimal.yaml
cargo run --release -- -r registry_updates res/spectests/tests/epoch_processing/registry_updates/registry_updates_minimal.yaml
cargo run --release -- -r blocks res/spectests/tests/sanity/blocks/sanity_blocks_minimal.yaml
cargo run --release -- -r slots res/spectests/tests/sanity/slots/sanity_slots_minimal.yaml
......@@ -14,3 +14,6 @@ beacon = { path = "../../beacon" }
crypto = { package = "shasper-crypto", path = "../../crypto" }
hex = "0.3"
sha2 = "0.8"
[features]
spectests = []
......@@ -136,3 +136,39 @@ fn main() {
_ => panic!("Unknown config"),
}
}
#[cfg(all(test, feature = "spectests"))]
mod spectests {
use super::*;
macro_rules! run {
( $name:ident, $config:ty, $path:expr ) => {
#[test]
fn $name() {
let reader = BufReader::new(include_bytes!($path).as_ref());
let coll = serde_yaml::from_reader::<_, Collection<$config>>(reader)
.expect("parse test cases failed");
for test in coll.test_cases {
test.test()
}
}
}
}
run!(ssz_mainnet_random, MainnetConfig,
"../../spectests/tests/ssz_static/core/ssz_mainnet_random.yaml");
run!(ssz_minimal_lengthy, MinimalConfig,
"../../spectests/tests/ssz_static/core/ssz_minimal_lengthy.yaml");
run!(ssz_minimal_max, MinimalConfig,
"../../spectests/tests/ssz_static/core/ssz_minimal_max.yaml");
run!(ssz_minimal_nil, MinimalConfig,
"../../spectests/tests/ssz_static/core/ssz_minimal_nil.yaml");
run!(ssz_minimal_one, MinimalConfig,
"../../spectests/tests/ssz_static/core/ssz_minimal_one.yaml");
run!(ssz_minimal_random_chaos, MinimalConfig,
"../../spectests/tests/ssz_static/core/ssz_minimal_random_chaos.yaml");
run!(ssz_minimal_random, MinimalConfig,
"../../spectests/tests/ssz_static/core/ssz_minimal_random.yaml");
run!(ssz_minimal_zero, MinimalConfig,
"../../spectests/tests/ssz_static/core/ssz_minimal_zero.yaml");
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment