-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Boilerplate for handlers. Create (wip)
BlobToKzgCommitmentTestCase
- Loading branch information
Showing
1 changed file
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,63 @@ | ||
use crate::{test_case::TestCase, test_utils::Error}; | ||
use crate::{ | ||
test_case::TestCase, | ||
test_utils::{load_yaml, Error}, | ||
}; | ||
use ethereum_consensus::deneb::{ | ||
mainnet as spec, | ||
polynomial_commitments::{blob_to_kzg_commitment, KzgCommitment, KzgSettings}, | ||
}; | ||
use serde::Deserialize; | ||
use serde_with::{serde_as, DefaultOnError}; | ||
|
||
pub fn dispatch(_test: &TestCase) -> Result<(), Error> { | ||
todo!() | ||
pub fn dispatch(test: &TestCase) -> Result<(), Error> { | ||
let meta = &test.meta; | ||
let path = &test.data_path; | ||
match meta.handler.0.as_str() { | ||
"blob_to_kzg_commitment" => { | ||
let test_case = BlobToKzgCommitmentTestCase::from(path); | ||
test_case.run(); | ||
Ok(()) | ||
} | ||
"compute_kzg_proof" => { | ||
todo!() | ||
} | ||
"verify_kzg_proof" => { | ||
todo!() | ||
} | ||
"compute_blob_kzg_proof" => { | ||
todo!() | ||
} | ||
"verify_blob_kzg_proof" => { | ||
todo!() | ||
} | ||
"verify_blob_kzg_proof_batch" => { | ||
todo!() | ||
} | ||
} | ||
} | ||
|
||
#[serde_as] | ||
#[derive(Debug, Deserialize)] | ||
struct BlobToKzgCommitmentInput { | ||
#[serde_as(deserialize_as = "DefaultOnError")] | ||
blob: spec::Blob, | ||
#[serde_as(deserialize_as = "DefaultOnError")] | ||
kzg_settings: KzgSettings, | ||
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
pub struct BlobToKzgCommitmentTestCase { | ||
input: BlobToKzgCommitmentInput, | ||
output: KzgCommitment, | ||
} | ||
|
||
impl BlobToKzgCommitmentTestCase { | ||
pub fn from(test_case_path: &str) -> Self { | ||
let path = test_case_path.to_string() + "/data.yaml"; | ||
load_yaml(&path) | ||
} | ||
|
||
pub fn run(&self) -> bool { | ||
blob_to_kzg_commitment(&self.input.blob, &self.input.kzg_settings).is_ok() | ||
} | ||
} |
834e5eb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Questions for PR:
.run()
on a test case instead of some sort of.execute()
? You said to not implement the execute trait, but am unsure whether you want to completely omit all functionality it provides.Default
andDeserialize
traits aren't defined forKzgSettings
. This is needed forload_yaml()
. Should i implement these traits? Or am i missing something?