From 6918fd88d40734b8c15fb5c519e9a40aec53eb74 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 3 Dec 2024 20:26:57 -0600 Subject: [PATCH] types: enable proptest::Arbitrary impls via the 'proptest' feature --- crates/sui-sdk-types/Cargo.toml | 12 ++- crates/sui-sdk-types/Makefile | 12 ++- crates/sui-sdk-types/src/hash.rs | 2 +- crates/sui-sdk-types/src/types/address.rs | 2 +- crates/sui-sdk-types/src/types/checkpoint.rs | 26 +++--- .../src/types/crypto/bls12381.rs | 4 +- .../sui-sdk-types/src/types/crypto/ed25519.rs | 4 +- crates/sui-sdk-types/src/types/crypto/mod.rs | 2 +- .../src/types/crypto/multisig.rs | 16 ++-- .../sui-sdk-types/src/types/crypto/passkey.rs | 2 +- .../src/types/crypto/secp256k1.rs | 4 +- .../src/types/crypto/secp256r1.rs | 4 +- .../src/types/crypto/signature.rs | 6 +- .../src/types/crypto/validator.rs | 10 +-- .../sui-sdk-types/src/types/crypto/zklogin.rs | 20 ++--- crates/sui-sdk-types/src/types/digest.rs | 4 +- crates/sui-sdk-types/src/types/effects/mod.rs | 2 +- crates/sui-sdk-types/src/types/effects/v1.rs | 24 +++--- crates/sui-sdk-types/src/types/effects/v2.rs | 22 ++--- crates/sui-sdk-types/src/types/events.rs | 6 +- .../src/types/execution_status.rs | 14 +-- crates/sui-sdk-types/src/types/gas.rs | 2 +- crates/sui-sdk-types/src/types/object.rs | 20 ++--- crates/sui-sdk-types/src/types/object_id.rs | 2 +- .../src/types/transaction/mod.rs | 86 +++++++++---------- .../sui-sdk-types/src/types/type_tag/mod.rs | 10 +-- 26 files changed, 162 insertions(+), 156 deletions(-) diff --git a/crates/sui-sdk-types/Cargo.toml b/crates/sui-sdk-types/Cargo.toml index 8b97caac0..3169bc40b 100644 --- a/crates/sui-sdk-types/Cargo.toml +++ b/crates/sui-sdk-types/Cargo.toml @@ -27,6 +27,7 @@ serde = ["dep:serde", "dep:serde_derive", "dep:serde_with", "dep:bcs", "dep:serd schemars = ["serde", "dep:schemars", "dep:serde_json"] rand = ["dep:rand_core"] hash = ["dep:blake2"] +proptest = ["dep:proptest", "dep:test-strategy", "serde"] [dependencies] base64ct = { version = "1.6.0", features = ["alloc"] } @@ -52,6 +53,10 @@ rand_core = { version = "0.6.4", optional = true } # Hash support blake2 = { version = "0.10.6", optional = true } +# proptest support +proptest = { version = "1.5.0", default-features = false, features = ["std"], optional = true } +test-strategy = { version = "0.4", optional = true } + [dev-dependencies] bcs = "0.1.6" serde_json = "1.0.128" @@ -59,13 +64,6 @@ num-bigint = "0.4.6" jsonschema = { version = "0.20", default-features = false } paste = "1.0.15" -# proptest support in tests -# -# Pin to this specific commit in order to work around an issue where proptest doesn't build properly in wasm environments -# see https://github.com/proptest-rs/proptest/pull/270 for more info -proptest = { git = "https://github.com/bmwill/proptest.git", rev = "bc36db126183bce18c8bc595f0c0cfeac48b870c", default-features = false, features = ["std"] } -test-strategy = "0.4" - [target.wasm32-unknown-unknown.dev-dependencies] wasm-bindgen-test = "0.3" getrandom = { version = "0.2", features = ["js"] } diff --git a/crates/sui-sdk-types/Makefile b/crates/sui-sdk-types/Makefile index acc0c2322..ff15371b7 100644 --- a/crates/sui-sdk-types/Makefile +++ b/crates/sui-sdk-types/Makefile @@ -12,12 +12,20 @@ clippy: .PHONY: test test: - cargo nextest run --all-features + # Note on proptest: + # + # Pin to this specific commit in order to work around an issue where proptest doesn't build properly in wasm environments + # see https://github.com/proptest-rs/proptest/pull/270 for more info + cargo nextest run --all-features --config 'patch.crates-io.proptest.git="https://github.com/bmwill/proptest.git"' --config 'patch.crates-io.proptest.rev="0a140789d25f4999632b8b88aedb1e2ba056151d"' cargo test --doc .PHONY: wasm wasm: - CC=clang wasm-pack test --node --all-features + # Note on proptest: + # + # Pin to this specific commit in order to work around an issue where proptest doesn't build properly in wasm environments + # see https://github.com/proptest-rs/proptest/pull/270 for more info + CC=clang wasm-pack test --node --all-features --config 'patch.crates-io.proptest.git="https://github.com/bmwill/proptest.git"' --config 'patch.crates-io.proptest.rev="0a140789d25f4999632b8b88aedb1e2ba056151d"' %: $(MAKE) -C ../.. $@ diff --git a/crates/sui-sdk-types/src/hash.rs b/crates/sui-sdk-types/src/hash.rs index c2716aafd..77ab94c86 100644 --- a/crates/sui-sdk-types/src/hash.rs +++ b/crates/sui-sdk-types/src/hash.rs @@ -283,7 +283,7 @@ mod signing_message { /// to ensure no hashing collision for any ObjectId vs Address which is derived /// as the hash of `flag || pubkey`. #[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] #[repr(u8)] enum HashingIntent { #[cfg(feature = "serde")] diff --git a/crates/sui-sdk-types/src/types/address.rs b/crates/sui-sdk-types/src/types/address.rs index 8d7018267..9bb137e8c 100644 --- a/crates/sui-sdk-types/src/types/address.rs +++ b/crates/sui-sdk-types/src/types/address.rs @@ -3,7 +3,7 @@ feature = "serde", derive(serde_derive::Serialize, serde_derive::Deserialize) )] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct Address( #[cfg_attr( feature = "serde", diff --git a/crates/sui-sdk-types/src/types/checkpoint.rs b/crates/sui-sdk-types/src/types/checkpoint.rs index 484c5fba7..b1279be07 100644 --- a/crates/sui-sdk-types/src/types/checkpoint.rs +++ b/crates/sui-sdk-types/src/types/checkpoint.rs @@ -24,7 +24,7 @@ pub type ProtocolVersion = u64; derive(schemars::JsonSchema), schemars(tag = "type", rename_all = "snake_case") )] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum CheckpointCommitment { EcmhLiveObjectSet { digest: Digest }, // Other commitment types (e.g. merkle roots) go here. @@ -36,7 +36,7 @@ pub enum CheckpointCommitment { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct EndOfEpochData { /// next_epoch_committee is `Some` if and only if the current checkpoint is /// the last checkpoint of an epoch. @@ -59,7 +59,7 @@ pub struct EndOfEpochData { #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct CheckpointSummary { #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))] pub epoch: EpochId, @@ -109,7 +109,7 @@ pub struct CheckpointSummary { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct SignedCheckpointSummary { pub checkpoint: CheckpointSummary, pub signature: ValidatorAggregatedSignature, @@ -117,9 +117,9 @@ pub struct SignedCheckpointSummary { #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct CheckpointContents( - #[cfg_attr(test, any(proptest::collection::size_range(0..=2).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))] Vec, ); @@ -143,11 +143,11 @@ impl CheckpointContents { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct CheckpointTransactionInfo { pub transaction: TransactionDigest, pub effects: TransactionEffectsDigest, - #[cfg_attr(test, any(proptest::collection::size_range(0..=2).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))] pub signatures: Vec, } @@ -157,11 +157,11 @@ pub struct CheckpointTransactionInfo { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct CheckpointData { pub checkpoint_summary: SignedCheckpointSummary, pub checkpoint_contents: CheckpointContents, - #[cfg_attr(test, any(proptest::collection::size_range(0..=1).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=1).lift()))] pub transactions: Vec, } @@ -171,7 +171,7 @@ pub struct CheckpointData { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct CheckpointTransaction { /// The input Transaction #[cfg_attr( @@ -185,10 +185,10 @@ pub struct CheckpointTransaction { /// The events, if any, emitted by this transaciton during execution pub events: Option, /// The state of all inputs to this transaction as they were prior to execution. - #[cfg_attr(test, any(proptest::collection::size_range(0..=2).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))] pub input_objects: Vec, /// The state of all output objects created or mutated by this transaction. - #[cfg_attr(test, any(proptest::collection::size_range(0..=2).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))] pub output_objects: Vec, } diff --git a/crates/sui-sdk-types/src/types/crypto/bls12381.rs b/crates/sui-sdk-types/src/types/crypto/bls12381.rs index 5da099849..4f2dcff94 100644 --- a/crates/sui-sdk-types/src/types/crypto/bls12381.rs +++ b/crates/sui-sdk-types/src/types/crypto/bls12381.rs @@ -6,7 +6,7 @@ derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct Bls12381PublicKey( #[cfg_attr( feature = "serde", @@ -107,7 +107,7 @@ impl std::fmt::Debug for Bls12381PublicKey { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct Bls12381Signature( #[cfg_attr( feature = "serde", diff --git a/crates/sui-sdk-types/src/types/crypto/ed25519.rs b/crates/sui-sdk-types/src/types/crypto/ed25519.rs index 9d42f868a..8a6c9e669 100644 --- a/crates/sui-sdk-types/src/types/crypto/ed25519.rs +++ b/crates/sui-sdk-types/src/types/crypto/ed25519.rs @@ -6,7 +6,7 @@ derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct Ed25519PublicKey( #[cfg_attr( feature = "serde", @@ -105,7 +105,7 @@ impl std::fmt::Debug for Ed25519PublicKey { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct Ed25519Signature( #[cfg_attr( feature = "serde", diff --git a/crates/sui-sdk-types/src/types/crypto/mod.rs b/crates/sui-sdk-types/src/types/crypto/mod.rs index d75f40f6f..64eebbf5e 100644 --- a/crates/sui-sdk-types/src/types/crypto/mod.rs +++ b/crates/sui-sdk-types/src/types/crypto/mod.rs @@ -85,7 +85,7 @@ macro_rules! impl_base64_helper { #[allow(unused)] #[derive(Debug, PartialEq)] - #[cfg_attr(test, derive(test_strategy::Arbitrary))] + #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] struct $fromstr([u8; $base::LENGTH]); impl std::str::FromStr for $fromstr { diff --git a/crates/sui-sdk-types/src/types/crypto/multisig.rs b/crates/sui-sdk-types/src/types/crypto/multisig.rs index 11297103d..21059b0d0 100644 --- a/crates/sui-sdk-types/src/types/crypto/multisig.rs +++ b/crates/sui-sdk-types/src/types/crypto/multisig.rs @@ -17,7 +17,7 @@ const MAX_COMMITTEE_SIZE: usize = 10; // const MAX_BITMAP_VALUE: BitmapUnit = 0b1111111111; #[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum MultisigMemberPublicKey { Ed25519(Ed25519PublicKey), Secp256k1(Secp256k1PublicKey), @@ -31,7 +31,7 @@ pub enum MultisigMemberPublicKey { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct MultisigMember { public_key: MultisigMemberPublicKey, weight: WeightUnit, @@ -57,10 +57,10 @@ impl MultisigMember { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct MultisigCommittee { /// A list of committee members and their corresponding weight. - #[cfg_attr(test, any(proptest::collection::size_range(0..=10).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=10).lift()))] members: Vec, /// If the total weight of the public keys corresponding to verified signatures is larger than threshold, the Multisig is verified. threshold: ThresholdUnit, @@ -115,12 +115,12 @@ impl MultisigCommittee { /// The struct that contains signatures and public keys necessary for authenticating a Multisig. #[derive(Debug, Clone)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct MultisigAggregatedSignature { /// The plain signature encoded with signature scheme. /// /// The signatures must be in the same order as they are listed in the committee. - #[cfg_attr(test, any(proptest::collection::size_range(0..=10).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=10).lift()))] signatures: Vec, /// A bitmap that indicates the position of which public key the signature should be authenticated with. bitmap: BitmapUnit, @@ -133,7 +133,7 @@ pub struct MultisigAggregatedSignature { with = "Option", ) )] - #[cfg_attr(test, strategy(proptest::strategy::Just(None)))] + #[cfg_attr(feature = "proptest", strategy(proptest::strategy::Just(None)))] legacy_bitmap: Option, /// The public key encoded with each public key with its signature scheme used along with the corresponding weight. committee: MultisigCommittee, @@ -199,7 +199,7 @@ fn roaring_bitmap_to_u16(roaring: &roaring::RoaringBitmap) -> Result; diff --git a/crates/sui-sdk-types/src/types/crypto/secp256k1.rs b/crates/sui-sdk-types/src/types/crypto/secp256k1.rs index 928ffff70..94f556192 100644 --- a/crates/sui-sdk-types/src/types/crypto/secp256k1.rs +++ b/crates/sui-sdk-types/src/types/crypto/secp256k1.rs @@ -6,7 +6,7 @@ derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct Secp256k1PublicKey( #[cfg_attr( feature = "serde", @@ -107,7 +107,7 @@ impl std::fmt::Debug for Secp256k1PublicKey { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct Secp256k1Signature( #[cfg_attr( feature = "serde", diff --git a/crates/sui-sdk-types/src/types/crypto/secp256r1.rs b/crates/sui-sdk-types/src/types/crypto/secp256r1.rs index 90d4baaa5..0e01918fc 100644 --- a/crates/sui-sdk-types/src/types/crypto/secp256r1.rs +++ b/crates/sui-sdk-types/src/types/crypto/secp256r1.rs @@ -24,7 +24,7 @@ impl Secp256r1PrivateKey { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct Secp256r1PublicKey( #[cfg_attr( feature = "serde", @@ -125,7 +125,7 @@ impl std::fmt::Debug for Secp256r1PublicKey { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct Secp256r1Signature( #[cfg_attr( feature = "serde", diff --git a/crates/sui-sdk-types/src/types/crypto/signature.rs b/crates/sui-sdk-types/src/types/crypto/signature.rs index b273e8648..f107178da 100644 --- a/crates/sui-sdk-types/src/types/crypto/signature.rs +++ b/crates/sui-sdk-types/src/types/crypto/signature.rs @@ -14,7 +14,7 @@ use super::ZkLoginAuthenticator; derive(schemars::JsonSchema), schemars(tag = "scheme", rename_all = "lowercase") )] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum SimpleSignature { Ed25519 { signature: Ed25519Signature, @@ -297,7 +297,7 @@ impl<'de> serde::Deserialize<'de> for SimpleSignature { } #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] #[repr(u8)] pub enum SignatureScheme { Ed25519 = 0x00, @@ -380,7 +380,7 @@ impl std::fmt::Display for InvalidSignatureScheme { } #[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum UserSignature { Simple(SimpleSignature), Multisig(MultisigAggregatedSignature), diff --git a/crates/sui-sdk-types/src/types/crypto/validator.rs b/crates/sui-sdk-types/src/types/crypto/validator.rs index bf678e207..f5283804b 100644 --- a/crates/sui-sdk-types/src/types/crypto/validator.rs +++ b/crates/sui-sdk-types/src/types/crypto/validator.rs @@ -9,7 +9,7 @@ use crate::types::checkpoint::StakeUnit; derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct ValidatorCommittee { #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))] #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))] @@ -23,7 +23,7 @@ pub struct ValidatorCommittee { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct ValidatorCommitteeMember { #[cfg_attr(feature = "serde", serde(with = "ValidatorPublicKeySerialization"))] #[cfg_attr(feature = "schemars", schemars(with = "Bls12381PublicKey"))] @@ -39,7 +39,7 @@ pub struct ValidatorCommitteeMember { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct ValidatorAggregatedSignature { #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))] #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))] @@ -48,7 +48,7 @@ pub struct ValidatorAggregatedSignature { #[cfg_attr(feature = "serde", serde(with = "RoaringBitMapSerialization"))] #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::Base64"))] #[cfg_attr( - test, + feature = "proptest", strategy(proptest::strategy::Just(roaring::RoaringBitmap::default())) )] pub bitmap: roaring::RoaringBitmap, @@ -100,7 +100,7 @@ impl<'de> serde_with::DeserializeAs<'de, Bls12381PublicKey> for BinaryValidatorP derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct ValidatorSignature { #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))] #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))] diff --git a/crates/sui-sdk-types/src/types/crypto/zklogin.rs b/crates/sui-sdk-types/src/types/crypto/zklogin.rs index 4b3247e22..5f443a115 100644 --- a/crates/sui-sdk-types/src/types/crypto/zklogin.rs +++ b/crates/sui-sdk-types/src/types/crypto/zklogin.rs @@ -5,7 +5,7 @@ use crate::types::u256::U256; /// An zk login authenticator with all the necessary fields. #[derive(Debug, Clone, PartialEq, Eq)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct ZkLoginAuthenticator { pub inputs: ZkLoginInputs, #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))] @@ -20,7 +20,7 @@ pub struct ZkLoginAuthenticator { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct ZkLoginInputs { pub proof_points: ZkLoginProof, pub iss_base64_details: Claim, @@ -35,7 +35,7 @@ pub struct ZkLoginInputs { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct Claim { pub value: String, pub index_mod_4: u8, @@ -48,7 +48,7 @@ pub struct Claim { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct ZkLoginProof { pub a: CircomG1, pub b: CircomG2, @@ -59,7 +59,7 @@ pub struct ZkLoginProof { /// representation of the projective coordinates in Fq. #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct CircomG1(pub [Bn254FieldElement; 3]); /// A G2 point in BN254 serialized as a vector of three vectors each being a vector of two strings @@ -67,14 +67,14 @@ pub struct CircomG1(pub [Bn254FieldElement; 3]); /// in Fq2. #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct CircomG2(pub [[Bn254FieldElement; 2]; 3]); /// A wrapper struct to retrofit in [enum PublicKey] for zkLogin. /// Useful to construct [struct MultiSigPublicKey]. #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] //TODO ensure iss is less than 255 bytes long pub struct ZkLoginPublicIdentifier { iss: String, @@ -108,7 +108,7 @@ impl ZkLoginPublicIdentifier { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct Jwk { /// Key type parameter, pub kty: String, @@ -127,7 +127,7 @@ pub struct Jwk { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct JwkId { /// iss string that identifies the OIDC provider. pub iss: String, @@ -137,7 +137,7 @@ pub struct JwkId { #[derive(Clone, Debug, Default, PartialEq, Eq)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct Bn254FieldElement( #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U256"))] [u8; 32], ); diff --git a/crates/sui-sdk-types/src/types/digest.rs b/crates/sui-sdk-types/src/types/digest.rs index ea10227fb..1398f9844 100644 --- a/crates/sui-sdk-types/src/types/digest.rs +++ b/crates/sui-sdk-types/src/types/digest.rs @@ -5,7 +5,7 @@ derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct Digest( #[cfg_attr(feature = "serde", serde(with = "DigestSerialization"))] #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::Base58"))] @@ -194,7 +194,7 @@ macro_rules! impl_digest { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] - #[cfg_attr(test, derive(test_strategy::Arbitrary))] + #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct $t(Digest); impl $t { diff --git a/crates/sui-sdk-types/src/types/effects/mod.rs b/crates/sui-sdk-types/src/types/effects/mod.rs index 0609e0f1c..7c1f10ee4 100644 --- a/crates/sui-sdk-types/src/types/effects/mod.rs +++ b/crates/sui-sdk-types/src/types/effects/mod.rs @@ -22,7 +22,7 @@ use crate::types::execution_status::ExecutionStatus; derive(schemars::JsonSchema), schemars(tag = "version") )] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum TransactionEffects { #[cfg_attr(feature = "schemars", schemars(rename = "1"))] V1(Box), diff --git a/crates/sui-sdk-types/src/types/effects/v1.rs b/crates/sui-sdk-types/src/types/effects/v1.rs index 5ae9c62c8..54aef5843 100644 --- a/crates/sui-sdk-types/src/types/effects/v1.rs +++ b/crates/sui-sdk-types/src/types/effects/v1.rs @@ -11,7 +11,7 @@ use crate::types::TransactionEventsDigest; /// The response from processing a transaction or a certified transaction #[derive(Eq, PartialEq, Clone, Debug)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct TransactionEffectsV1 { /// The status of the execution #[cfg_attr(feature = "schemars", schemars(flatten))] @@ -22,33 +22,33 @@ pub struct TransactionEffectsV1 { pub gas_used: GasCostSummary, /// The version that every modified (mutated or deleted) object had before it was modified by /// this transaction. - #[cfg_attr(test, any(proptest::collection::size_range(0..=5).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=5).lift()))] pub modified_at_versions: Vec, /// The object references of the shared objects used in this transaction. Empty if no shared objects were used. - #[cfg_attr(test, any(proptest::collection::size_range(0..=5).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=5).lift()))] pub shared_objects: Vec, /// The transaction digest pub transaction_digest: TransactionDigest, /// ObjectReference and owner of new objects created. - #[cfg_attr(test, any(proptest::collection::size_range(0..=5).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=5).lift()))] pub created: Vec, /// ObjectReference and owner of mutated objects, including gas object. - #[cfg_attr(test, any(proptest::collection::size_range(0..=5).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=5).lift()))] pub mutated: Vec, /// ObjectReference and owner of objects that are unwrapped in this transaction. /// Unwrapped objects are objects that were wrapped into other objects in the past, /// and just got extracted out. - #[cfg_attr(test, any(proptest::collection::size_range(0..=5).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=5).lift()))] pub unwrapped: Vec, /// Object Refs of objects now deleted (the new refs). - #[cfg_attr(test, any(proptest::collection::size_range(0..=5).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=5).lift()))] pub deleted: Vec, /// Object refs of objects previously wrapped in other objects but now deleted. - #[cfg_attr(test, any(proptest::collection::size_range(0..=5).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=5).lift()))] pub unwrapped_then_deleted: Vec, /// Object refs of objects now wrapped in other objects. - #[cfg_attr(test, any(proptest::collection::size_range(0..=5).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=5).lift()))] pub wrapped: Vec, /// The updated gas object reference. Have a dedicated field for convenient access. /// It's also included in mutated. @@ -57,7 +57,7 @@ pub struct TransactionEffectsV1 { /// can be None if the transaction does not emit any event. pub events_digest: Option, /// The set of transaction digests this transaction depends on. - #[cfg_attr(test, any(proptest::collection::size_range(0..=5).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=5).lift()))] pub dependencies: Vec, } @@ -67,7 +67,7 @@ pub struct TransactionEffectsV1 { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct ModifiedAtVersion { pub object_id: ObjectId, #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))] @@ -81,7 +81,7 @@ pub struct ModifiedAtVersion { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct ObjectReferenceWithOwner { pub reference: ObjectReference, pub owner: Owner, diff --git a/crates/sui-sdk-types/src/types/effects/v2.rs b/crates/sui-sdk-types/src/types/effects/v2.rs index dedd5be1f..c254dae59 100644 --- a/crates/sui-sdk-types/src/types/effects/v2.rs +++ b/crates/sui-sdk-types/src/types/effects/v2.rs @@ -12,7 +12,7 @@ use crate::types::TransactionEventsDigest; /// The response from processing a transaction or a certified transaction #[derive(Eq, PartialEq, Clone, Debug)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct TransactionEffectsV2 { /// The status of the execution #[cfg_attr(feature = "schemars", schemars(flatten))] @@ -31,20 +31,20 @@ pub struct TransactionEffectsV2 { /// can be None if the transaction does not emit any event. pub events_digest: Option, /// The set of transaction digests this transaction depends on. - #[cfg_attr(test, any(proptest::collection::size_range(0..=5).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=5).lift()))] pub dependencies: Vec, /// The version number of all the written Move objects by this transaction. #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))] pub lamport_version: Version, /// Objects whose state are changed in the object store. - #[cfg_attr(test, any(proptest::collection::size_range(0..=2).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))] pub changed_objects: Vec, /// Shared objects that are not mutated in this transaction. Unlike owned objects, /// read-only shared objects' version are not committed in the transaction, /// and in order for a node to catch up and execute it without consensus sequencing, /// the version needs to be committed in the effects. - #[cfg_attr(test, any(proptest::collection::size_range(0..=2).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))] pub unchanged_shared_objects: Vec, /// Auxiliary data that are not protocol-critical, generated as part of the effects but are stored separately. /// Storing it separately allows us to avoid bloating the effects with data that are not critical. @@ -55,7 +55,7 @@ pub struct TransactionEffectsV2 { //XXX Do we maybe want to just fold "EffectsObjectChange" into this struct? #[derive(Eq, PartialEq, Clone, Debug)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct ChangedObject { pub object_id: ObjectId, #[cfg_attr(feature = "schemars", schemars(flatten))] @@ -68,7 +68,7 @@ pub struct ChangedObject { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct UnchangedSharedObject { pub object_id: ObjectId, pub kind: UnchangedSharedKind, @@ -80,7 +80,7 @@ pub struct UnchangedSharedObject { derive(schemars::JsonSchema), schemars(tag = "kind", rename_all = "snake_case") )] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum UnchangedSharedKind { /// Read-only shared objects from the input. We don't really need ObjectDigest /// for protocol correctness, but it will make it easier to verify untrusted read. @@ -114,7 +114,7 @@ pub enum UnchangedSharedKind { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct EffectsObjectChange { // input_state and output_state are the core fields that's required by // the protocol as it tells how an object changes on-chain. @@ -138,7 +138,7 @@ pub struct EffectsObjectChange { derive(schemars::JsonSchema), schemars(tag = "state", rename_all = "snake_case") )] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum ObjectIn { NotExist, /// The old version, digest and owner. @@ -156,7 +156,7 @@ pub enum ObjectIn { derive(schemars::JsonSchema), schemars(tag = "state", rename_all = "snake_case") )] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum ObjectOut { /// Same definition as in ObjectIn. NotExist, @@ -178,7 +178,7 @@ pub enum ObjectOut { serde(rename_all = "lowercase") )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum IdOperation { None, Created, diff --git a/crates/sui-sdk-types/src/types/events.rs b/crates/sui-sdk-types/src/types/events.rs index 7b4b42ddb..027faefb5 100644 --- a/crates/sui-sdk-types/src/types/events.rs +++ b/crates/sui-sdk-types/src/types/events.rs @@ -10,7 +10,7 @@ use super::TypeTag; derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct TransactionEvents(pub Vec); /// Specific type of event @@ -20,7 +20,7 @@ pub struct TransactionEvents(pub Vec); derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct Event { pub package_id: ObjectId, pub module: Identifier, @@ -41,7 +41,7 @@ pub struct Event { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct BalanceChange { /// Owner of the balance change pub address: Address, diff --git a/crates/sui-sdk-types/src/types/execution_status.rs b/crates/sui-sdk-types/src/types/execution_status.rs index ebf56866e..1fe7e2077 100644 --- a/crates/sui-sdk-types/src/types/execution_status.rs +++ b/crates/sui-sdk-types/src/types/execution_status.rs @@ -4,7 +4,7 @@ use super::Identifier; use super::ObjectId; #[derive(Eq, PartialEq, Clone, Debug)] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum ExecutionStatus { Success, /// Gas used in the failed case, and the error. @@ -12,7 +12,7 @@ pub enum ExecutionStatus { /// The error error: ExecutionError, /// Which command the error occurred - #[cfg_attr(test, map(|x: Option| x.map(Into::into)))] + #[cfg_attr(feature = "proptest", map(|x: Option| x.map(Into::into)))] command: Option, }, } @@ -27,7 +27,7 @@ pub type TypeParameterIndex = u16; derive(schemars::JsonSchema), schemars(tag = "error", rename_all = "snake_case") )] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum ExecutionError { // // General transaction errors @@ -188,7 +188,7 @@ pub enum ExecutionError { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct MoveLocation { pub package: ObjectId, pub module: Identifier, @@ -205,7 +205,7 @@ pub struct MoveLocation { derive(schemars::JsonSchema), schemars(tag = "kind", rename_all = "snake_case") )] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum CommandArgumentError { /// The type of the value does not match the expected type TypeMismatch, @@ -246,7 +246,7 @@ pub enum CommandArgumentError { derive(schemars::JsonSchema), schemars(tag = "kind", rename_all = "snake_case") )] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum PackageUpgradeError { /// Unable to fetch package UnableToFetchPackage { package_id: ObjectId }, @@ -276,7 +276,7 @@ pub enum PackageUpgradeError { derive(schemars::JsonSchema), schemars(rename_all = "snake_case") )] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum TypeArgumentError { /// A type was not found in the module specified TypeNotFound, diff --git a/crates/sui-sdk-types/src/types/gas.rs b/crates/sui-sdk-types/src/types/gas.rs index 45417f1cb..36a41579d 100644 --- a/crates/sui-sdk-types/src/types/gas.rs +++ b/crates/sui-sdk-types/src/types/gas.rs @@ -28,7 +28,7 @@ derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct GasCostSummary { /// Cost of computation/execution #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))] diff --git a/crates/sui-sdk-types/src/types/object.rs b/crates/sui-sdk-types/src/types/object.rs index c902358ab..a323c6208 100644 --- a/crates/sui-sdk-types/src/types/object.rs +++ b/crates/sui-sdk-types/src/types/object.rs @@ -15,7 +15,7 @@ pub type Version = u64; derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct ObjectReference { object_id: ObjectId, #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))] @@ -63,7 +63,7 @@ impl ObjectReference { serde(rename_all = "lowercase") )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum Owner { /// # Address Owned /// Object is exclusively owned by a single address, and is mutable. @@ -90,7 +90,7 @@ pub enum Owner { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[allow(clippy::large_enum_variant)] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] //TODO think about hiding this type and not exposing it pub enum ObjectData { /// An object whose governing logic lives in a published Move module @@ -107,7 +107,7 @@ pub enum ObjectData { feature = "serde", derive(serde_derive::Serialize, serde_derive::Deserialize) )] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct MovePackage { pub id: ObjectId, /// Most move packages are uniquely identified by their ID (i.e. there is only one version per @@ -157,7 +157,7 @@ pub struct MovePackage { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct TypeOrigin { pub module_name: Identifier, pub struct_name: Identifier, @@ -171,7 +171,7 @@ pub struct TypeOrigin { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct UpgradeInfo { /// Id of the upgraded packages pub upgraded_id: ObjectId, @@ -187,7 +187,7 @@ pub struct UpgradeInfo { feature = "serde", derive(serde_derive::Serialize, serde_derive::Deserialize) )] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct MoveStruct { /// The type of this object. Immutable #[cfg_attr( @@ -207,7 +207,7 @@ pub struct MoveStruct { feature = "serde", serde(with = "::serde_with::As::<::serde_with::Bytes>") )] - #[cfg_attr(test, any(proptest::collection::size_range(32..=1024).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(32..=1024).lift()))] pub(crate) contents: Vec, } @@ -257,7 +257,7 @@ pub enum ObjectType { } #[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct Object { /// The meat of the object pub(crate) data: ObjectData, @@ -335,7 +335,7 @@ fn id_opt(contents: &[u8]) -> Option { } #[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct GenesisObject { data: ObjectData, owner: Owner, diff --git a/crates/sui-sdk-types/src/types/object_id.rs b/crates/sui-sdk-types/src/types/object_id.rs index dedc5874f..89c8288c0 100644 --- a/crates/sui-sdk-types/src/types/object_id.rs +++ b/crates/sui-sdk-types/src/types/object_id.rs @@ -6,7 +6,7 @@ use super::Address; derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct ObjectId(Address); impl ObjectId { diff --git a/crates/sui-sdk-types/src/types/transaction/mod.rs b/crates/sui-sdk-types/src/types/transaction/mod.rs index 880893e88..0d8542991 100644 --- a/crates/sui-sdk-types/src/types/transaction/mod.rs +++ b/crates/sui-sdk-types/src/types/transaction/mod.rs @@ -24,7 +24,7 @@ pub(crate) use serialization::SignedTransactionWithIntentMessage; pub mod unresolved; #[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct Transaction { pub kind: TransactionKind, pub sender: Address, @@ -38,14 +38,14 @@ pub struct Transaction { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct SignedTransaction { pub transaction: Transaction, pub signatures: Vec, } #[derive(Clone, Copy, Default, Debug, PartialEq, Eq, Hash)] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum TransactionExpiration { /// The transaction has no expiration #[default] @@ -61,7 +61,7 @@ pub enum TransactionExpiration { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct GasPayment { pub objects: Vec, pub owner: Address, @@ -79,7 +79,7 @@ pub struct GasPayment { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct RandomnessStateUpdate { /// Epoch of the randomness state update transaction #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))] @@ -105,7 +105,7 @@ pub struct RandomnessStateUpdate { } #[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum TransactionKind { /// A transaction that allows the interleaving of native commands and Move calls ProgrammableTransaction(ProgrammableTransaction), @@ -144,7 +144,7 @@ pub enum TransactionKind { derive(schemars::JsonSchema), schemars(tag = "kind", rename_all = "snake_case") )] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum EndOfEpochTransactionKind { ChangeEpoch(ChangeEpoch), AuthenticatorStateCreate, @@ -166,7 +166,7 @@ pub enum EndOfEpochTransactionKind { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct AuthenticatorStateExpire { /// expire JWKs that have a lower epoch than this #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))] @@ -184,7 +184,7 @@ pub struct AuthenticatorStateExpire { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct AuthenticatorStateUpdate { /// Epoch of the authenticator state update transaction #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))] @@ -210,7 +210,7 @@ pub struct AuthenticatorStateUpdate { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct ActiveJwk { pub jwk_id: JwkId, pub jwk: Jwk, @@ -228,7 +228,7 @@ pub struct ActiveJwk { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct ConsensusCommitPrologue { /// Epoch of the commit prologue transaction #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))] @@ -250,7 +250,7 @@ pub struct ConsensusCommitPrologue { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct ConsensusCommitPrologueV2 { /// Epoch of the commit prologue transaction #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))] @@ -274,11 +274,11 @@ pub struct ConsensusCommitPrologueV2 { derive(schemars::JsonSchema), schemars(tag = "kind", rename_all = "snake_case") )] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum ConsensusDeterminedVersionAssignments { /// Cancelled transaction version assignment. CancelledTransactions { - #[cfg_attr(test, any(proptest::collection::size_range(0..=2).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))] cancelled_transactions: Vec, }, } @@ -289,10 +289,10 @@ pub enum ConsensusDeterminedVersionAssignments { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct CancelledTransaction { pub digest: TransactionDigest, - #[cfg_attr(test, any(proptest::collection::size_range(0..=2).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))] pub version_assignments: Vec, } @@ -302,7 +302,7 @@ pub struct CancelledTransaction { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct VersionAssignment { pub object_id: ObjectId, #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))] @@ -316,7 +316,7 @@ pub struct VersionAssignment { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct ConsensusCommitPrologueV3 { /// Epoch of the commit prologue transaction #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))] @@ -350,7 +350,7 @@ pub struct ConsensusCommitPrologueV3 { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct ChangeEpoch { /// The next (to become) epoch ID. #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))] @@ -385,7 +385,7 @@ pub struct ChangeEpoch { /// the validator must write out the modules below. Modules are provided with the version they /// will be upgraded to, their modules in serialized form (which include their package ID), and /// a list of their transitive dependencies. - #[cfg_attr(test, any(proptest::collection::size_range(0..=2).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))] pub system_packages: Vec, } @@ -395,7 +395,7 @@ pub struct ChangeEpoch { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct SystemPackage { #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))] #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))] @@ -407,7 +407,7 @@ pub struct SystemPackage { ) )] #[cfg_attr(feature = "schemars", schemars(with = "Vec"))] - #[cfg_attr(test, any(proptest::collection::size_range(0..=2).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))] pub modules: Vec>, pub dependencies: Vec, } @@ -418,9 +418,9 @@ pub struct SystemPackage { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct GenesisTransaction { - #[cfg_attr(test, any(proptest::collection::size_range(0..=2).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))] pub objects: Vec, } @@ -432,14 +432,14 @@ pub struct GenesisTransaction { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct ProgrammableTransaction { /// Input objects or primitive values - #[cfg_attr(test, any(proptest::collection::size_range(0..=10).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=10).lift()))] pub inputs: Vec, /// The commands to be executed sequentially. A failure in any command will /// result in the failure of the entire transaction. - #[cfg_attr(test, any(proptest::collection::size_range(0..=10).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=10).lift()))] pub commands: Vec, } @@ -449,7 +449,7 @@ pub struct ProgrammableTransaction { derive(schemars::JsonSchema), schemars(tag = "type", rename_all = "snake_case") )] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum Input { // contains no structs or objects Pure { @@ -477,7 +477,7 @@ pub enum Input { derive(schemars::JsonSchema), schemars(tag = "command", rename_all = "snake_case") )] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum Command { /// A call to either an entry or a public Move function MoveCall(MoveCall), @@ -515,9 +515,9 @@ pub enum Command { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct TransferObjects { - #[cfg_attr(test, any(proptest::collection::size_range(0..=2).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))] pub objects: Vec, pub address: Argument, } @@ -528,10 +528,10 @@ pub struct TransferObjects { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct SplitCoins { pub coin: Argument, - #[cfg_attr(test, any(proptest::collection::size_range(0..=2).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))] pub amounts: Vec, } @@ -541,10 +541,10 @@ pub struct SplitCoins { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct MergeCoins { pub coin: Argument, - #[cfg_attr(test, any(proptest::collection::size_range(0..=2).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))] pub coins_to_merge: Vec, } @@ -554,7 +554,7 @@ pub struct MergeCoins { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct Publish { #[cfg_attr( feature = "serde", @@ -573,11 +573,11 @@ pub struct Publish { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct MakeMoveVector { #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: Option, - #[cfg_attr(test, any(proptest::collection::size_range(0..=2).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))] pub elements: Vec, } @@ -587,7 +587,7 @@ pub struct MakeMoveVector { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct Upgrade { #[cfg_attr( feature = "serde", @@ -604,7 +604,7 @@ pub struct Upgrade { /// An argument to a programmable transaction command #[derive(Clone, Copy, Debug, PartialEq, Eq)] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum Argument { /// The gas coin. The gas coin can only be used by-ref, except for with /// `TransferObjects`, which can use it by-value. @@ -638,7 +638,7 @@ impl Argument { derive(serde_derive::Serialize, serde_derive::Deserialize) )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct MoveCall { /// The package containing the module and function. pub package: ObjectId, @@ -647,9 +647,9 @@ pub struct MoveCall { /// The function to be called. pub function: Identifier, /// The type arguments to the function. - #[cfg_attr(test, any(proptest::collection::size_range(0..=2).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))] pub type_arguments: Vec, /// The arguments to the function. - #[cfg_attr(test, any(proptest::collection::size_range(0..=2).lift()))] + #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))] pub arguments: Vec, } diff --git a/crates/sui-sdk-types/src/types/type_tag/mod.rs b/crates/sui-sdk-types/src/types/type_tag/mod.rs index d0a04e69c..3c5d56128 100644 --- a/crates/sui-sdk-types/src/types/type_tag/mod.rs +++ b/crates/sui-sdk-types/src/types/type_tag/mod.rs @@ -7,7 +7,7 @@ mod serialization; use super::Address; #[derive(Eq, PartialEq, PartialOrd, Ord, Debug, Clone, Hash)] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub enum TypeTag { U8, U16, @@ -18,7 +18,7 @@ pub enum TypeTag { Bool, Address, Signer, - #[cfg_attr(test, weight(0))] + #[cfg_attr(feature = "proptest", weight(0))] Vector(Box), Struct(Box), } @@ -65,7 +65,7 @@ impl std::fmt::Display for TypeParseError { impl std::error::Error for TypeParseError {} #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct Identifier( #[cfg_attr( test, @@ -118,12 +118,12 @@ impl PartialEq for Identifier { } #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(test, derive(test_strategy::Arbitrary))] +#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] pub struct StructTag { pub address: Address, pub module: Identifier, pub name: Identifier, - #[cfg_attr(test, strategy(proptest::strategy::Just(Vec::new())))] + #[cfg_attr(feature = "proptest", strategy(proptest::strategy::Just(Vec::new())))] pub type_params: Vec, }