Skip to content

Commit

Permalink
add more compilation conditions for SuiEvent::random_for_testing (Mys…
Browse files Browse the repository at this point in the history
…tenLabs#15210)

## Description 

As title

## Test Plan 

How did you test the new or updated feature?

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
  • Loading branch information
longbowlu authored Dec 5, 2023
1 parent a192a92 commit dfe0dbf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions crates/sui-bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ workspace-hack.workspace = true

[dev-dependencies]
sui-types = { workspace = true, features = ["test-utils"] }
sui-json-rpc-types = { workspace = true, features = ["test-utils"] }
3 changes: 3 additions & 0 deletions crates/sui-json-rpc-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ workspace-hack.workspace = true

[dev-dependencies]
sui-types = { workspace = true, features = ["test-utils"] }

[features]
test-utils = []
6 changes: 5 additions & 1 deletion crates/sui-json-rpc-types/src/sui_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use serde_json::{json, Value};
use serde_with::{serde_as, DisplayFromStr};
use std::fmt;
use std::fmt::Display;
use std::str::FromStr;
use sui_types::base_types::{ObjectID, SuiAddress, TransactionDigest};
use sui_types::error::SuiResult;
use sui_types::event::{Event, EventEnvelope, EventID};
Expand All @@ -23,6 +22,10 @@ use tabled::settings::Style as TableStyle;

use crate::{type_and_fields_from_move_struct, Page};
use sui_types::sui_serde::SuiStructTag;

#[cfg(any(feature = "test-utils", test))]
use std::str::FromStr;

pub type EventPage = Page<SuiEvent, EventID>;

#[serde_as]
Expand Down Expand Up @@ -151,6 +154,7 @@ impl Display for SuiEvent {
}
}

#[cfg(any(feature = "test-utils", test))]
impl SuiEvent {
pub fn random_for_testing() -> Self {
Self {
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-types/src/base_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ impl SuiAddress {
self.0.to_vec()
}

#[cfg(feature = "test-utils")]
#[cfg(any(feature = "test-utils", test))]
/// Return a random SuiAddress.
pub fn random_for_testing_only() -> Self {
AccountAddress::random().into()
Expand Down

0 comments on commit dfe0dbf

Please sign in to comment.