drive/verify/shielded/verify_compacted_nullifier_changes/
mod.rs1mod v0;
2
3use crate::drive::shielded::nullifiers::types::CompactedNullifierChange;
4use crate::drive::Drive;
5use crate::error::drive::DriveError;
6use crate::error::Error;
7use crate::verify::RootHash;
8use dpp::version::PlatformVersion;
9
10impl Drive {
11 pub fn verify_compacted_nullifier_changes(
13 proof: &[u8],
14 start_block_height: u64,
15 limit: Option<u16>,
16 platform_version: &PlatformVersion,
17 ) -> Result<(RootHash, Vec<CompactedNullifierChange>), Error> {
18 match platform_version
19 .drive
20 .methods
21 .verify
22 .shielded
23 .verify_compacted_nullifier_changes
24 {
25 0 => Self::verify_compacted_nullifier_changes_v0(
26 proof,
27 start_block_height,
28 limit,
29 platform_version,
30 ),
31 version => Err(Error::Drive(DriveError::UnknownVersionMismatch {
32 method: "verify_compacted_nullifier_changes".to_string(),
33 known_versions: vec![0],
34 received: version,
35 })),
36 }
37 }
38}
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43 use dpp::version::PlatformVersion;
44
45 #[test]
46 fn test_verify_compacted_nullifier_changes_unknown_version_mismatch() {
47 let mut platform_version = PlatformVersion::latest().clone();
48 platform_version
49 .drive
50 .methods
51 .verify
52 .shielded
53 .verify_compacted_nullifier_changes = 255;
54
55 let result = Drive::verify_compacted_nullifier_changes(&[], 0, None, &platform_version);
56
57 assert!(
58 matches!(
59 &result,
60 Err(Error::Drive(DriveError::UnknownVersionMismatch { .. }))
61 ),
62 "expected UnknownVersionMismatch, got is_err={}",
63 result.is_err(),
64 );
65 }
66}