Skip to content

Commit

Permalink
Merge pull request #50 from availproject/ghali/fix-all-features
Browse files Browse the repository at this point in the history
Ghali/fix all features
  • Loading branch information
Leouarz authored Sep 26, 2023
2 parents 4c3fdf4 + 5a059e9 commit d871bed
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 78 deletions.
1 change: 0 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ runtime = [
"binary-merkle-tree",
]

header-backward-compatibility-test = []
try-runtime = [
"runtime",
"sp-runtime/try-runtime",
Expand Down
17 changes: 0 additions & 17 deletions core/src/header/extension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,13 @@ use crate::DataLookup;
pub mod v1;
pub mod v2;

#[cfg(feature = "header-backward-compatibility-test")]
pub mod v_test;

/// Header extension data.
#[derive(PartialEq, Eq, Clone, RuntimeDebug, TypeInfo, Encode, Decode)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "runtime", derive(PassByCodec))]
pub enum HeaderExtension {
V1(v1::HeaderExtension),
V2(v2::HeaderExtension),
#[cfg(feature = "header-backward-compatibility-test")]
VTest(v_test::HeaderExtension),
}

/// It forwards the call to the inner version of the header. Any invalid version will return the
Expand All @@ -32,17 +27,13 @@ macro_rules! forward_to_version {
match $self {
HeaderExtension::V1(ext) => ext.$function(),
HeaderExtension::V2(ext) => ext.$function(),
#[cfg(feature = "header-backward-compatibility-test")]
HeaderExtension::VTest(ext) => ext.$function(),
}
}};

($self:ident, $function:ident, $arg:expr) => {{
match $self {
HeaderExtension::V1(ext) => ext.$function($arg),
HeaderExtension::V2(ext) => ext.$function($arg),
#[cfg(feature = "header-backward-compatibility-test")]
HeaderExtension::VTest(ext) => ext.$function($arg),
}
}};
}
Expand Down Expand Up @@ -84,11 +75,3 @@ impl From<v2::HeaderExtension> for HeaderExtension {
Self::V2(ext)
}
}

#[cfg(feature = "header-backward-compatibility-test")]
impl From<v_test::HeaderExtension> for HeaderExtension {
#[inline]
fn from(ext: v_test::HeaderExtension) -> Self {
Self::VTest(ext)
}
}
32 changes: 0 additions & 32 deletions core/src/header/extension/v_test.rs

This file was deleted.

27 changes: 0 additions & 27 deletions core/src/header/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,26 +418,8 @@ mod tests {
(encoded, error)
}

#[cfg(not(feature = "header-backward-compatibility-test"))]
fn header_test() -> THeader {
header_v1()
}

#[cfg(feature = "header-backward-compatibility-test")]
fn header_test() -> THeader {
let mut header = header_v1();
header.extension = extension::v_test::HeaderExtension {
new_field: b"New field for testing".to_vec(),
..Default::default()
}
.into();

header
}

#[test_case( header_v1().encode().as_ref() => Ok(header_v1()) ; "Decode V1 header")]
#[test_case( header_v2().encode().as_ref() => Ok(header_v2()) ; "Decode V2 header")]
#[test_case( header_test().encode().as_ref() => Ok(header_test()) ; "Decode test header")]
#[test_case( corrupted_header().0.as_ref() => Err(corrupted_header().1) ; "Decode corrupted header")]
fn header_decoding(mut encoded_header: &[u8]) -> Result<THeader, Error> {
Header::decode(&mut encoded_header)
Expand All @@ -448,7 +430,6 @@ mod tests {
}

#[test_case( header_serde_encode(header_v1()) => Ok(header_v1()) ; "Serde V1 header")]
#[test_case( header_serde_encode(header_test()) => Ok(header_test()) ; "Serde test header")]
fn header_serde(json_header: String) -> Result<THeader, String> {
serde_json::from_str(&json_header).map_err(|serde_err| format!("{}", serde_err))
}
Expand Down Expand Up @@ -514,8 +495,6 @@ mod tests {
extension::HeaderExtension::V2(ref mut ext) => {
ext.commitment.commitment = b"invalid commitment v2".to_vec();
},
#[cfg(feature = "header-backward-compatibility-test")]
_ => unreachable!(),
};

(header, hash)
Expand All @@ -531,8 +510,6 @@ mod tests {
extension::HeaderExtension::V2(ref mut ext) => {
ext.commitment.data_root = Some(H256::repeat_byte(2u8));
},
#[cfg(feature = "header-backward-compatibility-test")]
_ => unreachable!(),
};

(header, hash)
Expand All @@ -548,8 +525,6 @@ mod tests {
extension::HeaderExtension::V2(ref mut ext) => {
ext.commitment.cols += 2;
},
#[cfg(feature = "header-backward-compatibility-test")]
_ => unreachable!(),
};

(header, hash)
Expand All @@ -565,8 +540,6 @@ mod tests {
extension::HeaderExtension::V2(ref mut ext) => {
ext.commitment.rows += 2;
},
#[cfg(feature = "header-backward-compatibility-test")]
_ => unreachable!(),
};

(header, hash)
Expand Down
2 changes: 1 addition & 1 deletion kate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ license = "Apache-2.0"
poly-multiproof = { git = "https://github.com/availproject/poly-multiproof", default-features = false, tag = "v0.0.1", optional = true }

# Internal
avail-core = { path = "../core", default-features = false, feature = "runtime" }
avail-core = { path = "../core", default-features = false }
kate-recovery = { path = "recovery", default-features = false }

dusk-plonk = { git = "https://github.com/availproject/plonk.git", tag = "v0.12.0-polygon-2", optional = true }
Expand Down

0 comments on commit d871bed

Please sign in to comment.