diff --git a/examples/barebones-with-extra/src/lib.rs b/examples/barebones-with-extra/src/lib.rs index 35b0bfe..8d075e1 100644 --- a/examples/barebones-with-extra/src/lib.rs +++ b/examples/barebones-with-extra/src/lib.rs @@ -17,8 +17,8 @@ impl Program for BarebonesWithExtra { /// This is the only function required by the program runtime. `signature_request` is the preimage of the curve element to be /// signed, eg. RLP-serialized Ethereum transaction request, raw x86_64 executable, etc. fn evaluate(signature_request: InitialState) -> Result<(), Error> { - let InitialState { preimage, extra} = signature_request; - + let InitialState { preimage, extra } = signature_request; + // our constraint just checks that the length of the signature request is greater than 10 if preimage.len() < 10 { return Err(Error::Evaluation( @@ -27,7 +27,9 @@ impl Program for BarebonesWithExtra { } // Just check and make sure the extra field is not empty. - extra.ok_or(Error::Evaluation("This program requires that `extra` be `Some`.".to_string()))?; + extra.ok_or(Error::Evaluation( + "This program requires that `extra` be `Some`.".to_string(), + ))?; Ok(()) } @@ -45,7 +47,7 @@ mod tests { fn test_preimage_length_is_valid() { let signature_request = InitialState { preimage: "some_data_longer_than_10_bytes".to_string().into_bytes(), - extra: Some(vec![0x00]) + extra: Some(vec![0x00]), }; assert!(BarebonesWithExtra::evaluate(signature_request).is_ok()); @@ -56,7 +58,7 @@ mod tests { let signature_request = InitialState { // should error since preimage is less than 10 bytes preimage: "under10".to_string().into_bytes(), - extra: Some(vec![0x00]) + extra: Some(vec![0x00]), }; assert!(BarebonesWithExtra::evaluate(signature_request).is_err()); @@ -67,10 +69,9 @@ mod tests { let signature_request = InitialState { preimage: "some_data_longer_than_10_bytes".to_string().into_bytes(), // should error since extra field is None - extra: None + extra: None, }; assert!(BarebonesWithExtra::evaluate(signature_request).is_err()); } - } diff --git a/examples/barebones/src/lib.rs b/examples/barebones/src/lib.rs index aa6c918..9687012 100644 --- a/examples/barebones/src/lib.rs +++ b/examples/barebones/src/lib.rs @@ -41,7 +41,7 @@ mod tests { fn test_should_sign() { let signature_request = InitialState { preimage: "some_data_longer_than_10_bytes".to_string().into_bytes(), - extra: None + extra: None, }; assert!(BarebonesProgram::evaluate(signature_request).is_ok()); @@ -52,7 +52,7 @@ mod tests { // data being checked is under 10 bytes in length let signature_request = InitialState { preimage: "under10".to_string().into_bytes(), - extra: None + extra: None, }; assert!(BarebonesProgram::evaluate(signature_request).is_err()); diff --git a/examples/risczero-zkvm-verification/src/lib.rs b/examples/risczero-zkvm-verification/src/lib.rs index fa8f7c6..1f28947 100644 --- a/examples/risczero-zkvm-verification/src/lib.rs +++ b/examples/risczero-zkvm-verification/src/lib.rs @@ -18,13 +18,22 @@ pub struct ZkVmVerificationProgram; impl Program for ZkVmVerificationProgram { fn evaluate(signature_request: InitialState) -> Result<(), Error> { - let image_id: [u32; 8] = bincode::deserialize(&signature_request.preimage) - .map_err(|_| Error::InvalidTransactionRequest("Could not parse image_id".to_string()))?; + let image_id: [u32; 8] = + bincode::deserialize(&signature_request.preimage).map_err(|_| { + Error::InvalidTransactionRequest("Could not parse image_id".to_string()) + })?; let receipt: Receipt = match signature_request.extra { - Some(serialized_receipt) => bincode::deserialize(&serialized_receipt) - .map_err(|_| Error::InvalidTransactionRequest("Could not parse receipt".to_string()))?, - None => return Err(Error::InvalidTransactionRequest("No receipt provided".to_string())), + Some(serialized_receipt) => { + bincode::deserialize(&serialized_receipt).map_err(|_| { + Error::InvalidTransactionRequest("Could not parse receipt".to_string()) + })? + } + None => { + return Err(Error::InvalidTransactionRequest( + "No receipt provided".to_string(), + )) + } }; receipt @@ -77,7 +86,7 @@ mod tests { fn test_should_pass_valid_receipt_and_image_pair() { let signature_request = InitialState { preimage: bincode::serialize(&read_test_image_id()).unwrap(), - extra: Some(bincode::serialize(&read_test_receipt()).unwrap()) + extra: Some(bincode::serialize(&read_test_receipt()).unwrap()), }; assert!(ZkVmVerificationProgram::evaluate(signature_request).is_ok()); @@ -87,7 +96,7 @@ mod tests { fn test_should_error_with_incorrect_image_id_for_receipt_image_pair() { let signature_request = InitialState { preimage: bincode::serialize(&read_erronous_test_image_id()).unwrap(), - extra: Some(bincode::serialize(&read_test_receipt()).unwrap()) + extra: Some(bincode::serialize(&read_test_receipt()).unwrap()), }; assert!(ZkVmVerificationProgram::evaluate(signature_request).is_err()); diff --git a/examples/siwe/src/lib.rs b/examples/siwe/src/lib.rs index c72b58e..a4353b6 100644 --- a/examples/siwe/src/lib.rs +++ b/examples/siwe/src/lib.rs @@ -60,7 +60,7 @@ Nonce: oNCEHm5jzQU2WvuBB Issued At: 2022-01-28T23:28:16.013Z" .to_string() .into_bytes(), - extra: None + extra: None, }; assert!(Siwe::evaluate(signature_request).is_ok()); @@ -81,7 +81,7 @@ Nonce: oNCEHm5jzQU2WvuBB Issued At: 2022-01-28T23:28:16.013Z" .to_string() .into_bytes(), - extra: None + extra: None, }; assert!(Siwe::evaluate(signature_request).is_err()); @@ -102,7 +102,7 @@ Nonce: oNCEHm5jzQU2WvuBB Issued At: 2022-01-28T23:28:16.013Z" .to_string() .into_bytes(), - extra: None + extra: None, }; assert!(Siwe::evaluate(signature_request).is_err()); diff --git a/runtime/tests/runtime.rs b/runtime/tests/runtime.rs index 9d9859d..0bc3ca8 100644 --- a/runtime/tests/runtime.rs +++ b/runtime/tests/runtime.rs @@ -12,7 +12,7 @@ fn test_barebones_component() { let longer_than_10 = "asdfasdfasdfasdf".to_string(); let initial_state = InitialState { preimage: longer_than_10.into_bytes(), - extra: None + extra: None, }; let res = runtime.evaluate(BAREBONES_COMPONENT_WASM, &initial_state); @@ -27,7 +27,7 @@ fn test_barebones_component_fails_with_data_length_less_than_10() { let shorter_than_10 = "asdf".to_string(); let initial_state = InitialState { preimage: shorter_than_10.into_bytes(), - extra: None + extra: None, }; let res = runtime.evaluate(BAREBONES_COMPONENT_WASM, &initial_state);