From 577b0e8f6c480b697c1fb4b9a8c35191cde33208 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 27 Sep 2026 18:54:50 +0700 Subject: [PATCH 1/2] test: follow the test conventions in tests added in 4.1 and 4.2 - rs-platform-encryption: the round-trip tests drew keys and IVs from thread_rng; seed them with StdRng::seed_from_u64 so a failure reproduces. - try_from_schema v3, validate_update keep-history repair, the withdrawal asset-unlock info v1 and the token evaluate v1 tests pinned protocol version 14 although they test the latest generation; run them at PlatformVersion::latest() (pinning happens when a newer generation arrives). The one test named for the v14 fee cap stays pinned. - v14.rs: drop ranked_feature_slots_exist_but_are_dormant, which only restated PLATFORM_V14 slot values, and put the meta-schema doc comment back on the test it describes. Co-Authored-By: Claude Opus 5.5 --- .../distribution_function/evaluate.rs | 7 +- .../try_from_schema/v3/keep_history_tests.rs | 10 +- .../class_methods/try_from_schema/v3/mod.rs | 101 +++++++++--------- .../v1/mod.rs | 15 +-- .../src/account_label.rs | 10 +- packages/rs-platform-encryption/src/aes.rs | 6 +- .../src/compact_xpub.rs | 10 +- packages/rs-platform-encryption/src/ecdh.rs | 8 +- .../rs-platform-version/src/version/v14.rs | 50 +-------- 9 files changed, 85 insertions(+), 132 deletions(-) diff --git a/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/evaluate.rs b/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/evaluate.rs index d07240290bf..ea6c13e0210 100644 --- a/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/evaluate.rs +++ b/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/evaluate.rs @@ -738,14 +738,15 @@ mod tests { min_value: None, max_value: None, }; - let v14 = PlatformVersion::get(14).expect("v14 must exist"); + let latest = PlatformVersion::latest(); assert_eq!( - v14.dpp + latest + .dpp .token_versions .distribution_function_evaluate_version, 1 ); - assert_eq!(distribution.evaluate(0, 1, v14).unwrap(), 31_402); + assert_eq!(distribution.evaluate(0, 1, latest).unwrap(), 31_402); } #[test] diff --git a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/keep_history_tests.rs b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/keep_history_tests.rs index f0ceb8f5dcc..2fad7e6ab76 100644 --- a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/keep_history_tests.rs +++ b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/keep_history_tests.rs @@ -235,7 +235,7 @@ fn should_repair_legacy_keep_history_delete_flag_at_protocol_14() { let repaired = parse_at_version(repair_schema(true, false), 14, true).unwrap(); let result = old .as_ref() - .validate_update(repaired.as_ref(), 2, PlatformVersion::get(14).unwrap()) + .validate_update(repaired.as_ref(), 2, PlatformVersion::latest()) .expect("repair must reach a consensus result"); assert!(result.is_valid(), "repair rejected: {:?}", result.errors); } @@ -276,7 +276,7 @@ fn should_reject_other_delete_and_history_flag_changes_at_protocol_14() { let new = parse_at_version(repair_schema(new_flags.0, new_flags.1), 14, false).unwrap(); let result = old .as_ref() - .validate_update(new.as_ref(), 2, PlatformVersion::get(14).unwrap()) + .validate_update(new.as_ref(), 2, PlatformVersion::latest()) .unwrap(); assert!( !result.is_valid(), @@ -304,7 +304,7 @@ fn should_reject_incompatible_properties_during_keep_history_repair() { .unwrap(); let result = old .as_ref() - .validate_update(new.as_ref(), 2, PlatformVersion::get(14).unwrap()) + .validate_update(new.as_ref(), 2, PlatformVersion::latest()) .unwrap(); assert!( !result.is_valid(), @@ -320,7 +320,7 @@ fn should_reject_mutability_change_during_keep_history_repair() { let new = parse_at_version(schema, 14, true).unwrap(); let result = old .as_ref() - .validate_update(new.as_ref(), 2, PlatformVersion::get(14).unwrap()) + .validate_update(new.as_ref(), 2, PlatformVersion::latest()) .unwrap(); assert!( !result.is_valid(), @@ -353,7 +353,7 @@ fn should_still_validate_property_named_can_be_deleted_during_keep_history_repai let new = parse_at_version(new_schema, 14, true).unwrap(); let result = old .as_ref() - .validate_update(new.as_ref(), 2, PlatformVersion::get(14).unwrap()) + .validate_update(new.as_ref(), 2, PlatformVersion::latest()) .unwrap(); assert!( !result.is_valid(), diff --git a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/mod.rs b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/mod.rs index 6fff6574cbd..f3dbe199424 100644 --- a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/mod.rs @@ -1204,13 +1204,11 @@ mod tests { PlatformVersion::get(13).expect("protocol version 13 exists") } - /// Generation-specific tests must pin a protocol version that actually - /// selects their own generation: `pv14()` silently - /// retargets these tests onto a different parser generation and a - /// different document meta-schema whenever LATEST moves. PV14 is the - /// first protocol version whose `try_from_schema` selects generation 3. - fn pv14() -> &'static PlatformVersion { - PlatformVersion::get(14).expect("protocol version 14 exists") + /// Generation 3 is the latest parser generation, so its tests run at the latest protocol + /// version. When a later protocol version selects a new generation, pin these tests to the + /// last version that selects generation 3 (see the coding conventions). + fn latest() -> &'static PlatformVersion { + PlatformVersion::latest() } /// PV14 accepts the ranked keywords and carries them onto the parsed index @@ -1218,9 +1216,9 @@ mod tests { /// the way production reaches it, through the dispatcher. The dispatcher /// half is what pins that `try_from_schema: 3` actually routes here. #[test] - fn ranked_keywords_accepted_at_pv14() { + fn ranked_keywords_accepted_at_latest() { let schema = ranked_review_schema(vec![("rankedAverageable", true)]); - let v2 = parse_with(schema.clone(), pv14(), true) + let v2 = parse_with(schema.clone(), latest(), true) .expect("meta-schema v3 must accept the ranked index keywords"); let index = v2 @@ -1233,7 +1231,7 @@ mod tests { assert!(index.range_countable && index.range_summable); // Same schema, same platform version, through the real dispatcher. - let dispatched = parse_dispatched(schema, pv14(), true) + let dispatched = parse_dispatched(schema, latest(), true) .expect("the dispatcher must route PV14 to a generation that accepts the keywords"); let DocumentType::V2(dispatched) = dispatched else { panic!("generation 3 produces a V2-shaped document type"); @@ -1291,7 +1289,7 @@ mod tests { #[test] fn ranked_keywords_accepted_at_pv14_without_full_validation() { let schema = ranked_review_schema(vec![("rankedAverageable", true)]); - let v2 = parse_with(schema, pv14(), false) + let v2 = parse_with(schema, latest(), false) .expect("PV14 structural parse must accept the ranked keywords"); assert!( v2.indices @@ -1313,7 +1311,7 @@ mod tests { #[test] fn ranked_countable_satisfied_by_range_averageable_in_meta_schema() { let schema = ranked_review_schema(vec![("rankedCountable", true)]); - let v2 = parse_with(schema, pv14(), true) + let v2 = parse_with(schema, latest(), true) .expect("rangeAverageable satisfies rankedCountable's range prerequisite"); let index = v2 .indices @@ -1381,9 +1379,10 @@ mod tests { #[test] fn ranked_flags_written_out_as_false_do_not_require_a_range_axis() { for key in ["rankedCountable", "rankedSummable", "rankedAverageable"] { - let v2 = parse_with(bare_ranked_index_schema(key, false), pv14(), true).unwrap_or_else( - |e| panic!("`{key}: false` is an opt-out and must pass full validation: {e:?}"), - ); + let v2 = parse_with(bare_ranked_index_schema(key, false), latest(), true) + .unwrap_or_else(|e| { + panic!("`{key}: false` is an opt-out and must pass full validation: {e:?}") + }); let index = v2 .indices @@ -1407,7 +1406,7 @@ mod tests { #[test] fn ranked_flags_set_true_still_require_their_range_axis() { for key in ["rankedCountable", "rankedSummable", "rankedAverageable"] { - let result = parse_with(bare_ranked_index_schema(key, true), pv14(), true); + let result = parse_with(bare_ranked_index_schema(key, true), latest(), true); assert!( result.is_err(), "`{key}: true` with no range axis must be rejected under full validation" @@ -1437,7 +1436,7 @@ mod tests { "rankedCountable": true, }], }); - let result = parse_with(schema, pv14(), false); + let result = parse_with(schema, latest(), false); assert!( result.is_err(), "rankedCountable with no range-count layout must be rejected structurally" @@ -1579,7 +1578,7 @@ mod tests { } fn parse_bound(schema: Value) -> Result { - parse_with(schema, pv14(), true) + parse_with(schema, latest(), true) } /// Count-ranked and sum-ranked indexes share the 8-byte sort key, so both @@ -1968,9 +1967,9 @@ mod tests { /// paths — and the ranked flags land on the index alongside the /// range axes they require. #[test] - fn compound_ranked_index_accepted_at_pv14() { + fn compound_ranked_index_accepted_at_latest() { for full_validation in [true, false] { - let v2 = parse_with(compound_ranked_schema(vec![]), pv14(), full_validation) + let v2 = parse_with(compound_ranked_schema(vec![]), latest(), full_validation) .unwrap_or_else(|e| { panic!( "a compound ranked index must parse \ @@ -2003,7 +2002,7 @@ mod tests { vec![("countable", Value::Text("countable".to_string()))], )]); for full_validation in [true, false] { - let error = parse_with(schema.clone(), pv14(), full_validation).expect_err( + let error = parse_with(schema.clone(), latest(), full_validation).expect_err( "an aggregating index on the ranked compound's full prefix must be rejected", ); let message = format!("{error:?}"); @@ -2031,14 +2030,14 @@ mod tests { "restaurantId", vec![("countable", Value::Text("countable".to_string()))], )]); - parse_with(aggregating_elsewhere, pv14(), true) + parse_with(aggregating_elsewhere, latest(), true) .expect("an aggregating index off the prefix must not conflict"); // A plain index on the prefix property: terminates at [region] // but carries no aggregates, so its value trees stay normal and // no wrapper shell is ever needed. let plain_prefix = compound_ranked_schema(vec![("byRegion", "region", vec![])]); - parse_with(plain_prefix, pv14(), true) + parse_with(plain_prefix, latest(), true) .expect("a non-aggregating index on the prefix must not conflict"); } @@ -2168,7 +2167,7 @@ mod tests { /// structural path, landing in `ranked_countable_at` with the boolean /// terminal axis off. #[test] - fn prefix_ranked_at_accepted_at_pv14() { + fn prefix_ranked_at_accepted_at_latest() { for full_validation in [true, false] { let schema = prefix_at_schema( &["region", "restaurantId"], @@ -2177,7 +2176,7 @@ mod tests { 32, vec![], ); - let v2 = parse_with(schema, pv14(), full_validation).unwrap_or_else(|e| { + let v2 = parse_with(schema, latest(), full_validation).unwrap_or_else(|e| { panic!("the at form must parse (full_validation: {full_validation}): {e}") }); let index = v2.indices.get("byMain").expect("index parsed"); @@ -2189,7 +2188,7 @@ mod tests { /// The array form naming both levels passes the meta-schema and /// parses into both flags — the both-rankings-on-one-index shape. #[test] - fn prefix_ranked_at_array_form_accepted_at_pv14() { + fn prefix_ranked_at_array_form_accepted_at_latest() { for full_validation in [true, false] { let schema = prefix_at_schema( &["region", "restaurantId"], @@ -2204,7 +2203,7 @@ mod tests { 32, vec![], ); - let v2 = parse_with(schema, pv14(), full_validation).unwrap_or_else(|e| { + let v2 = parse_with(schema, latest(), full_validation).unwrap_or_else(|e| { panic!("the array form must parse (full_validation: {full_validation}): {e}") }); let index = v2.indices.get("byMain").expect("index parsed"); @@ -2245,7 +2244,7 @@ mod tests { vec![], ); assert!( - parse_with(schema, pv14(), true).is_err(), + parse_with(schema, latest(), true).is_err(), "meta-schema v3 must demand rangeCountable alongside the at form" ); } @@ -2272,7 +2271,7 @@ mod tests { ] { let schema = prefix_at_schema(&["region", "restaurantId"], value, true, 32, vec![]); assert!( - parse_with(schema, pv14(), true).is_err(), + parse_with(schema, latest(), true).is_err(), "the meta-schema must reject the {label} object form" ); } @@ -2305,7 +2304,7 @@ mod tests { 32, vec![(name, properties, flags.clone())], ); - let error = parse_with(schema, pv14(), full_validation) + let error = parse_with(schema, latest(), full_validation) .expect_err("an index conflicting with the at level must be rejected"); let message = format!("{error:?}"); assert!( @@ -2326,7 +2325,7 @@ mod tests { 32, vec![("byRegionGrade", &["region", "grade"], vec![])], ); - let v2 = parse_with(schema, pv14(), full_validation).unwrap_or_else(|e| { + let v2 = parse_with(schema, latest(), full_validation).unwrap_or_else(|e| { panic!( "a plain continuing sibling must be admitted \ (full_validation: {full_validation}): {e}" @@ -2352,7 +2351,7 @@ mod tests { 32, vec![("byGrade", &["grade"], vec![])], ); - parse_with(schema, pv14(), true) + parse_with(schema, latest(), true) .expect("an index over a different leading property must not conflict"); } @@ -2377,7 +2376,7 @@ mod tests { vec![("countable", Value::Text("countable".to_string()))], )], ); - let error = parse_with(schema, pv14(), full_validation) + let error = parse_with(schema, latest(), full_validation) .expect_err("an aggregating index above the at level must be rejected"); let message = format!("{error:?}"); assert!( @@ -2396,7 +2395,7 @@ mod tests { 32, vec![("byRegion", &["region"], vec![])], ); - parse_with(schema, pv14(), true) + parse_with(schema, latest(), true) .expect("a plain index on the prefix above the at level must not conflict"); } @@ -2412,7 +2411,7 @@ mod tests { 61, vec![], ); - parse_with(schema, pv14(), true).expect("61 characters fits the 247-byte ceiling"); + parse_with(schema, latest(), true).expect("61 characters fits the 247-byte ceiling"); // 62 * 4 = 248 > 247: rejected, naming the at property's bound. let schema = prefix_at_schema( @@ -2422,7 +2421,7 @@ mod tests { 62, vec![], ); - let error = parse_with(schema, pv14(), true) + let error = parse_with(schema, latest(), true) .expect_err("62 characters exceeds the 247-byte ceiling"); let msg = format!("{error:?}"); assert!( @@ -2537,7 +2536,7 @@ mod tests { #[test] fn averageable_sugar_satisfies_ranked_countable_under_full_validation() { let schema = schema_with_index_entry(sugar_multi_axis_index_entry()); - let v2 = parse_with(schema, pv14(), true) + let v2 = parse_with(schema, latest(), true) .expect("the sugar form satisfies every prerequisite in both layers"); let index = v2 .indices @@ -2555,8 +2554,8 @@ mod tests { ("rangeAverageable", Value::Bool(true)), ("rankedSummable", Value::Bool(true)), ])); - let v2 = - parse_with(schema, pv14(), true).expect("rangeAverageable stands in for rangeSummable"); + let v2 = parse_with(schema, latest(), true) + .expect("rangeAverageable stands in for rangeSummable"); let index = v2 .indices .get("storeRating") @@ -2576,7 +2575,7 @@ mod tests { ("rangeSummable", Value::Bool(true)), ("rankedAverageable", Value::Bool(true)), ])); - let v2 = parse_with(schema, pv14(), true) + let v2 = parse_with(schema, latest(), true) .expect("rangeCountable + rangeSummable stand in for rangeAverageable"); let index = v2 .indices @@ -2596,7 +2595,7 @@ mod tests { ("averageable", Value::Text("grade".to_string())), ("rankedCountable", Value::Bool(true)), ])); - let error = parse_with(schema, pv14(), true) + let error = parse_with(schema, latest(), true) .expect_err("a Count ranking needs a range axis, however it is spelled"); let msg = format!("{error:?}"); assert!( @@ -2613,7 +2612,7 @@ mod tests { ("averageable", Value::Text("grade".to_string())), ("rankedCountable", Value::Bool(false)), ])); - let v2 = parse_with(schema, pv14(), true) + let v2 = parse_with(schema, latest(), true) .expect("an explicit rankedCountable: false asks for no ranking axis"); let index = v2 .indices @@ -2630,7 +2629,7 @@ mod tests { fn range_countable_alone_implies_countable_under_full_validation() { let schema = schema_with_index_entry(index_entry(vec![("rangeCountable", Value::Bool(true))])); - let v2 = parse_with(schema, pv14(), true) + let v2 = parse_with(schema, latest(), true) .expect("rangeCountable alone is a complete declaration"); let index = v2 .indices @@ -2647,7 +2646,7 @@ mod tests { let schema = schema_with_index_entry(index_entry(vec![("rangeSummable", Value::Bool(true))])); let error = - parse_with(schema, pv14(), true).expect_err("rangeSummable needs something to sum"); + parse_with(schema, latest(), true).expect_err("rangeSummable needs something to sum"); let msg = format!("{error:?}"); assert!( msg.contains("summable"), @@ -2663,7 +2662,7 @@ mod tests { ("countable", Value::Text("notCountable".to_string())), ("rangeCountable", Value::Bool(true)), ])); - let error = parse_with(schema, pv14(), true) + let error = parse_with(schema, latest(), true) .expect_err("countable: notCountable contradicts rangeCountable: true"); let msg = format!("{error:?}"); assert!( @@ -2703,7 +2702,7 @@ mod tests { Value::Text("rangeCountable".to_string()), Value::Bool(false), )); - let error = parse_with(schema_with_index_entry(entry), pv14(), true) + let error = parse_with(schema_with_index_entry(entry), latest(), true) .expect_err("rangeAverageable: true contradicts an explicit rangeCountable: false"); let msg = format!("{error:?}"); assert!( @@ -2723,7 +2722,7 @@ mod tests { ], index_entry(vec![]), ); - parse_with(schema, pv14(), true).expect( + parse_with(schema, latest(), true).expect( "documentsAverageable implies documentsSummable, so rangeSummable is satisfied", ); @@ -2731,7 +2730,7 @@ mod tests { vec![("rangeSummable", Value::Bool(true))], index_entry(vec![]), ); - let error = parse_with(schema, pv14(), true) + let error = parse_with(schema, latest(), true) .expect_err("a doctype-level rangeSummable with nothing to sum is refused"); let msg = format!("{error:?}"); assert!( @@ -2746,7 +2745,7 @@ mod tests { #[test] fn sugar_form_parses_without_full_validation() { let schema = schema_with_index_entry(sugar_multi_axis_index_entry()); - let v2 = parse_with(schema, pv14(), false) + let v2 = parse_with(schema, latest(), false) .expect("the structural parser is sugar-aware and accepts the short form"); let index = v2 .indices @@ -2819,7 +2818,7 @@ mod tests { "rankedAverageable": true, "rankedCountable": true }); - DataContract::from_json(contract_json(short_form), true, pv14()) + DataContract::from_json(contract_json(short_form), true, latest()) .expect("the sugar short form registers, so the SDK must accept it too"); let no_range_axis = json!({ @@ -2828,7 +2827,7 @@ mod tests { "averageable": "grade", "rankedCountable": true }); - let error = DataContract::from_json(contract_json(no_range_axis), true, pv14()) + let error = DataContract::from_json(contract_json(no_range_axis), true, latest()) .expect_err("a ranking with no range axis is refused by both layers"); let msg = format!("{error:?}"); assert!( diff --git a/packages/rs-dpp/src/withdrawal/document_try_into_asset_unlock_base_transaction_info/v1/mod.rs b/packages/rs-dpp/src/withdrawal/document_try_into_asset_unlock_base_transaction_info/v1/mod.rs index 779e715434c..b727a9380a7 100644 --- a/packages/rs-dpp/src/withdrawal/document_try_into_asset_unlock_base_transaction_info/v1/mod.rs +++ b/packages/rs-dpp/src/withdrawal/document_try_into_asset_unlock_base_transaction_info/v1/mod.rs @@ -126,10 +126,7 @@ mod tests { fn stamped_withdrawal_reserves_output_and_core_fee_from_one_amount() { let amount = 2_000_000_000u64; let tx = withdrawal_document(Some(1), amount) - .try_into_asset_unlock_base_transaction_info( - 1, - PlatformVersion::get(14).expect("platform version 14"), - ) + .try_into_asset_unlock_base_transaction_info(1, PlatformVersion::latest()) .expect("asset unlock info"); assert_eq!( @@ -143,10 +140,7 @@ mod tests { fn unstamped_queued_withdrawal_is_bounded_by_its_reserved_amount() { let amount = 1_000_000u64; let tx = withdrawal_document(None, amount) - .try_into_asset_unlock_base_transaction_info( - 1, - PlatformVersion::get(14).expect("platform version 14"), - ) + .try_into_asset_unlock_base_transaction_info(1, PlatformVersion::latest()) .expect("asset unlock info"); assert_eq!( @@ -202,10 +196,7 @@ mod tests { // 500 duffs: below the 546-duff P2PKH dust threshold, legal under the pre-v12 floor. let amount = 500_000u64; let tx = withdrawal_document(None, amount) - .try_into_asset_unlock_base_transaction_info( - 1, - PlatformVersion::get(14).expect("platform version 14"), - ) + .try_into_asset_unlock_base_transaction_info(1, PlatformVersion::latest()) .expect("a legacy dust amount must convert rather than abort the block"); assert_eq!(tx.base_payload.fee, 0); diff --git a/packages/rs-platform-encryption/src/account_label.rs b/packages/rs-platform-encryption/src/account_label.rs index 9f281be8c60..3f5bd60067c 100644 --- a/packages/rs-platform-encryption/src/account_label.rs +++ b/packages/rs-platform-encryption/src/account_label.rs @@ -113,21 +113,23 @@ pub fn decrypt_account_label( mod tests { use super::*; use crate::ecdh::derive_shared_key_ecdh; - use secp256k1::rand::{thread_rng, RngCore}; + use secp256k1::rand::rngs::StdRng; + use secp256k1::rand::{RngCore, SeedableRng}; use secp256k1::Secp256k1; #[test] fn test_account_label_encryption() { + let mut rng = StdRng::seed_from_u64(4); let secp = Secp256k1::new(); - let (secret1, _public1) = secp.generate_keypair(&mut thread_rng()); - let (_secret2, public2) = secp.generate_keypair(&mut thread_rng()); + let (secret1, _public1) = secp.generate_keypair(&mut rng); + let (_secret2, public2) = secp.generate_keypair(&mut rng); // Derive shared key let shared_key = derive_shared_key_ecdh(&secret1, &public2); // Generate random IV let mut iv = [0u8; 16]; - thread_rng().fill_bytes(&mut iv); + rng.fill_bytes(&mut iv); let label = "My DashPay Account"; diff --git a/packages/rs-platform-encryption/src/aes.rs b/packages/rs-platform-encryption/src/aes.rs index c1609592fd7..3082a3218b4 100644 --- a/packages/rs-platform-encryption/src/aes.rs +++ b/packages/rs-platform-encryption/src/aes.rs @@ -63,13 +63,15 @@ pub fn decrypt_aes_256_cbc( #[cfg(test)] mod tests { use super::*; - use secp256k1::rand::{thread_rng, RngCore}; + use secp256k1::rand::rngs::StdRng; + use secp256k1::rand::{RngCore, SeedableRng}; #[test] fn test_aes_encryption_decryption() { + let mut rng = StdRng::seed_from_u64(2); let key = [0u8; 32]; let mut iv = [0u8; 16]; - thread_rng().fill_bytes(&mut iv); + rng.fill_bytes(&mut iv); let plaintext = b"Hello, DashPay!"; diff --git a/packages/rs-platform-encryption/src/compact_xpub.rs b/packages/rs-platform-encryption/src/compact_xpub.rs index 01816f34006..80101600948 100644 --- a/packages/rs-platform-encryption/src/compact_xpub.rs +++ b/packages/rs-platform-encryption/src/compact_xpub.rs @@ -139,21 +139,23 @@ pub fn parse_compact_xpub(bytes: &[u8]) -> Result { mod tests { use super::*; use crate::ecdh::derive_shared_key_ecdh; - use secp256k1::rand::{thread_rng, RngCore}; + use secp256k1::rand::rngs::StdRng; + use secp256k1::rand::{RngCore, SeedableRng}; use secp256k1::Secp256k1; #[test] fn test_extended_public_key_encryption() { + let mut rng = StdRng::seed_from_u64(3); let secp = Secp256k1::new(); - let (secret1, _public1) = secp.generate_keypair(&mut thread_rng()); - let (_secret2, public2) = secp.generate_keypair(&mut thread_rng()); + let (secret1, _public1) = secp.generate_keypair(&mut rng); + let (_secret2, public2) = secp.generate_keypair(&mut rng); // Derive shared key let shared_key = derive_shared_key_ecdh(&secret1, &public2); // Generate random IV let mut iv = [0u8; 16]; - thread_rng().fill_bytes(&mut iv); + rng.fill_bytes(&mut iv); // DIP-15 compact xpub plaintext (69 bytes). 69 → PKCS7 → 80, + 16-byte // IV = exactly 96 bytes, matching the contract's minItems/maxItems: 96. diff --git a/packages/rs-platform-encryption/src/ecdh.rs b/packages/rs-platform-encryption/src/ecdh.rs index 7e165365eec..0b2ae3bc707 100644 --- a/packages/rs-platform-encryption/src/ecdh.rs +++ b/packages/rs-platform-encryption/src/ecdh.rs @@ -28,16 +28,18 @@ pub fn derive_shared_key_ecdh(private_key: &SecretKey, public_key: &PublicKey) - #[cfg(test)] mod tests { use super::*; - use secp256k1::rand::thread_rng; + use secp256k1::rand::rngs::StdRng; + use secp256k1::rand::SeedableRng; use secp256k1::Secp256k1; #[test] fn test_ecdh_key_derivation() { + let mut rng = StdRng::seed_from_u64(1); let secp = Secp256k1::new(); // Generate two key pairs - let (secret1, public1) = secp.generate_keypair(&mut thread_rng()); - let (secret2, public2) = secp.generate_keypair(&mut thread_rng()); + let (secret1, public1) = secp.generate_keypair(&mut rng); + let (secret2, public2) = secp.generate_keypair(&mut rng); // Derive shared keys from both sides let shared1 = derive_shared_key_ecdh(&secret1, &public2); diff --git a/packages/rs-platform-version/src/version/v14.rs b/packages/rs-platform-version/src/version/v14.rs index 5c0236287d8..d1a0f0f7aa6 100644 --- a/packages/rs-platform-version/src/version/v14.rs +++ b/packages/rs-platform-version/src/version/v14.rs @@ -1524,8 +1524,6 @@ mod tests { ); } - /// The ranked index keywords are gated by the meta-schema version, so v14 - /// must select meta-schema v3 while v13 stays on v2. /// Contested indexes without a Lock choice (item 23): the three method /// versions that read the resolution are selected by v14 only, so a v13 /// replay keeps the shipped rules (a full poll for every contest, ties to @@ -1586,6 +1584,8 @@ mod tests { ); } + /// The ranked index keywords are gated by the meta-schema version, so v14 + /// must select meta-schema v3 while v13 stays on v2. #[test] fn ranked_index_keywords_are_gated_by_meta_schema_v3() { assert_eq!( @@ -1653,52 +1653,6 @@ mod tests { ); } - /// v14 introduces the slots but activates none of them yet. If a later - /// change flips one of these, it must do so deliberately — and update this - /// test — rather than by inheriting a default. - #[test] - fn ranked_feature_slots_exist_but_are_dormant() { - assert_eq!( - PLATFORM_V14.drive.methods.document.query.detect_ranked_mode, - 0 - ); - assert_eq!( - PLATFORM_V14.drive.methods.document.query.detect_having_mode, - 0 - ); - assert_eq!( - PLATFORM_V14 - .drive - .methods - .verify - .document_ranked - .verify_ranked_top_k_proof, - 0 - ); - assert_eq!( - PLATFORM_V14 - .drive - .methods - .verify - .document_ranked - .verify_having_range_proof, - 0 - ); - let grove = &PLATFORM_V14.drive.grove_methods.batch; - assert_eq!(grove.batch_insert_empty_provable_count_indexed_tree, 0); - assert_eq!(grove.batch_insert_empty_provable_sum_indexed_tree, 0); - assert_eq!( - grove.batch_insert_empty_provable_count_provable_sum_indexed_tree, - 0 - ); - } - - /// The contested vote poll index cross-check changes accept/reject - /// behavior for document create transitions, so it lives in v14's own - /// validation table: a v13 node keeps running structure validation v0, - /// which validates only the prefunded amount and ignores the index name. - /// A change that made v13 non-zero here would retroactively reject - /// transitions already in the chain. #[test] fn contested_index_cross_check_is_v14_only() { assert_eq!( From 8e26f1e3469d36309cdc25daf7dc469b5b3fe4c7 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 28 Sep 2026 00:00:06 +0700 Subject: [PATCH 2/2] test: restore a freeze test's rationale and drop stale PV14 wording Review follow-ups: removing the dormant-slots test also removed the replay rationale of contested_index_cross_check_is_v14_only; put it back. The generation 3 tests that now run at the latest protocol version no longer name protocol version 14 in their name, docs or failure messages. Co-Authored-By: Claude Opus 5.5 --- .../class_methods/try_from_schema/v3/mod.rs | 17 +++++++++-------- packages/rs-platform-version/src/version/v14.rs | 6 ++++++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/mod.rs b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/mod.rs index f3dbe199424..36f2ef75fd6 100644 --- a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/mod.rs @@ -1211,7 +1211,7 @@ mod tests { PlatformVersion::latest() } - /// PV14 accepts the ranked keywords and carries them onto the parsed index + /// The latest protocol version accepts the ranked keywords and carries them onto the parsed index /// — both when parsed through this generation directly and when reached /// the way production reaches it, through the dispatcher. The dispatcher /// half is what pins that `try_from_schema: 3` actually routes here. @@ -1232,7 +1232,7 @@ mod tests { // Same schema, same platform version, through the real dispatcher. let dispatched = parse_dispatched(schema, latest(), true) - .expect("the dispatcher must route PV14 to a generation that accepts the keywords"); + .expect("the dispatcher must route the latest protocol version to a generation that accepts the keywords"); let DocumentType::V2(dispatched) = dispatched else { panic!("generation 3 produces a V2-shaped document type"); }; @@ -1242,7 +1242,7 @@ mod tests { .get("byRestaurant") .expect("index parsed under its name") .ranked_averageable, - "dispatching at PV14 must reach generation 3, not an earlier generation" + "dispatching at the latest protocol version must reach generation 3, not an earlier generation" ); } @@ -1284,13 +1284,14 @@ mod tests { } } - /// Same schema, PV14, no full validation: accepted. Pins that the gate is - /// the parser *generation* and not the validation mode. + /// Same schema, latest protocol version, no full validation: accepted. Pins that the gate + /// is the parser *generation* and not the validation mode. #[test] - fn ranked_keywords_accepted_at_pv14_without_full_validation() { + fn ranked_keywords_accepted_at_latest_without_full_validation() { let schema = ranked_review_schema(vec![("rankedAverageable", true)]); - let v2 = parse_with(schema, latest(), false) - .expect("PV14 structural parse must accept the ranked keywords"); + let v2 = parse_with(schema, latest(), false).expect( + "the latest protocol version's structural parse must accept the ranked keywords", + ); assert!( v2.indices .get("byRestaurant") diff --git a/packages/rs-platform-version/src/version/v14.rs b/packages/rs-platform-version/src/version/v14.rs index d1a0f0f7aa6..6ce2ec7850d 100644 --- a/packages/rs-platform-version/src/version/v14.rs +++ b/packages/rs-platform-version/src/version/v14.rs @@ -1653,6 +1653,12 @@ mod tests { ); } + /// The contested vote poll index cross-check changes accept/reject + /// behavior for document create transitions, so it lives in v14's own + /// validation table: a v13 node keeps running structure validation v0, + /// which validates only the prefunded amount and ignores the index name. + /// A change that made v13 non-zero here would retroactively reject + /// transitions already in the chain. #[test] fn contested_index_cross_check_is_v14_only() { assert_eq!(