Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ members = [
]

[workspace.package]
version = "0.1.36"
version = "0.1.37"
edition = "2021"
license = "Apache-2.0"
authors = ["Junha Park <0xjunha@gmail.com>"]
Expand Down
26 changes: 1 addition & 25 deletions block/src/types/extrinsics/tickets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,14 @@ impl Display for TicketsXt {
}
}

#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, JamEncode, JamDecode)]
pub struct TicketsXtEntry {
/// `e`: The ticket entry index, either 0 or 1.
pub entry_index: u8,
/// `p`: The ticket identifier (note: different from `Ticket` which contains hash of the proof as a ticket id)
pub ticket_proof: BandersnatchRingVrfSig,
}

impl JamEncode for TicketsXtEntry {
fn size_hint(&self) -> usize {
self.entry_index.size_hint() + self.ticket_proof.size_hint()
}

fn encode_to<T: JamOutput>(&self, dest: &mut T) -> Result<(), JamCodecError> {
self.entry_index.encode_to_fixed(dest, 1)?;
self.ticket_proof.encode_to(dest)?;
Ok(())
}
}

impl JamDecode for TicketsXtEntry {
fn decode<I: JamInput>(input: &mut I) -> Result<Self, JamCodecError>
where
Self: Sized,
{
Ok(Self {
entry_index: u8::decode_fixed(input, 1)?,
ticket_proof: BandersnatchRingVrfSig::decode(input)?,
})
}
}

impl Display for TicketsXtEntry {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.ticket_proof.output_hash() {
Expand Down
20 changes: 17 additions & 3 deletions integration/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
use std::{env, fs, fs::ReadDir, path::PathBuf};

const RETIRED_TRACES: &[&str] = &[
// TODO: Remove after tickets extrinsic encoding get fixed in test vectors
"1766243315_2277",
"1766244122_5414",
"1766244251_1816",
"1767872928_1994",
];

fn is_retired(trace_name: &str) -> bool {
RETIRED_TRACES.contains(&trace_name)
}

/// Build script to generate test cases from JSON test vectors
fn main() {
// PVM test cases
Expand Down Expand Up @@ -105,11 +117,13 @@ fn generate_fuzzer_block_import_tests() {

let mut test_case_contents = String::from("use fr_fuzz::fuzzer::run_fuzz_trace_dir;");

let mut write_fuzzer_case = |test_name: &str, trace_path: &PathBuf| {
let mut write_fuzzer_case = |test_name: &str, trace_path: &PathBuf, ignored: bool| {
let trace_path_str = trace_path.to_str().unwrap();
let ignored_attr = if ignored { "#[ignore]" } else { "" };
test_case_contents.push_str(&format!(
"\
#[tokio::test]\
{ignored_attr}\
async fn {test_name}() -> Result<(), Box<dyn std::error::Error>> {{
run_fuzz_trace_dir(\"{trace_path_str}\").await?;
Ok(())
Expand All @@ -130,7 +144,7 @@ fn generate_fuzzer_block_import_tests() {
None => continue,
};
let test_name = format!("block_import_conformance_0_7_2_{}", trace_name);
write_fuzzer_case(&test_name, &trace_path);
write_fuzzer_case(&test_name, &trace_path, is_retired(trace_name));
}

let fuzzy_block_groups = ["fuzzy", "fuzzy_light"];
Expand All @@ -142,7 +156,7 @@ fn generate_fuzzer_block_import_tests() {

if trace_path.is_dir() {
let test_name = format!("block_import_{group}_all");
write_fuzzer_case(&test_name, &trace_path);
write_fuzzer_case(&test_name, &trace_path, false);
}
}

Expand Down