Skip to content

Commit fb21690

Browse files
committed
transaction-fuzzer: add address-balance and gasless fuzz tests
1 parent 72993bd commit fb21690

12 files changed

Lines changed: 1516 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/sui-types/src/base_types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ pub trait ConciseableName<'a> {
146146

147147
#[serde_as]
148148
#[derive(Eq, PartialEq, Clone, Copy, PartialOrd, Ord, Hash, Serialize, Deserialize, JsonSchema)]
149+
#[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))]
149150
pub struct ObjectID(
150151
#[schemars(with = "Hex")]
151152
#[serde_as(as = "Readable<HexAccountAddress, _>")]

crates/sui-types/src/digests.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use tracing::info;
2121
#[derive(
2222
Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, JsonSchema,
2323
)]
24+
#[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))]
2425
pub struct Digest(
2526
#[schemars(with = "Base58")]
2627
#[serde_as(as = "Readable<Base58, Bytes>")]
@@ -159,6 +160,7 @@ impl fmt::UpperHex for Digest {
159160
Deserialize,
160161
JsonSchema,
161162
)]
163+
#[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))]
162164
pub struct ChainIdentifier(CheckpointDigest);
163165

164166
pub const MAINNET_CHAIN_IDENTIFIER_BASE58: &str = "4btiuiMPvEENsttpZC7CZ53DruC3MAgfznDbASZ7DR6S";
@@ -279,6 +281,7 @@ impl From<CheckpointDigest> for ChainIdentifier {
279281
#[derive(
280282
Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, JsonSchema,
281283
)]
284+
#[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))]
282285
pub struct CheckpointDigest(Digest);
283286

284287
impl CheckpointDigest {
@@ -873,6 +876,7 @@ impl std::str::FromStr for EffectsAuxDataDigest {
873876

874877
// Each object has a unique digest
875878
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, JsonSchema)]
879+
#[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))]
876880
pub struct ObjectDigest(Digest);
877881

878882
impl ObjectDigest {

crates/sui-types/src/transaction.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ impl CallArg {
139139
}
140140

141141
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Serialize, Deserialize)]
142+
#[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))]
142143
pub enum ObjectArg {
143144
// A Move object from fastpath.
144145
ImmOrOwnedObject(ObjectRef),
@@ -1177,6 +1178,7 @@ pub enum Command {
11771178

11781179
/// An argument to a programmable transaction command
11791180
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Serialize, Deserialize)]
1181+
#[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))]
11801182
pub enum Argument {
11811183
/// The gas coin. The gas coin can only be used by-ref, except for with
11821184
/// `TransferObjects`, which can use it by-value.
@@ -4584,6 +4586,7 @@ pub enum InputObjectKind {
45844586
}
45854587

45864588
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, PartialOrd, Ord, Hash)]
4589+
#[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))]
45874590
pub enum SharedObjectMutability {
45884591
// The "classic" mutable/immutable modes.
45894592
Immutable,

crates/transaction-fuzzer/Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@ tracing.workspace = true
2222
once_cell.workspace = true
2323
sui-core.workspace = true
2424
sui-protocol-config.workspace = true
25-
sui-types = { workspace = true, features = ["fuzzing"] }
25+
sui-types = { workspace = true, features = ["fuzzing", "testing"] }
2626
sui-move-build.workspace = true
2727

2828

2929
[dev-dependencies]
30+
prometheus.workspace = true
31+
shared-crypto.workspace = true
32+
sui-keys.workspace = true
33+
sui-macros.workspace = true
3034
sui-protocol-config.workspace = true
35+
sui-simulator.workspace = true
36+
test-cluster.workspace = true
37+
sui-test-transaction-builder.workspace = true

0 commit comments

Comments
 (0)