Skip to content

Commit 3c379c9

Browse files
committed
added non-testing std abi for mutators
1 parent 3db6f29 commit 3c379c9

4 files changed

Lines changed: 36 additions & 11 deletions

File tree

crates/movy-replay/src/env.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@ impl<
6262
Self { db }
6363
}
6464

65+
pub fn std_abi(&self, test: bool) -> Result<BTreeMap<MoveAddress, MovePackageAbi>, MovyError> {
66+
let std = if test {
67+
include_bytes!(concat!(env!("OUT_DIR"), "/std.testing")).to_vec()
68+
} else {
69+
include_bytes!(concat!(env!("OUT_DIR"), "/std")).to_vec()
70+
};
71+
let stds: Vec<SuiCompiledPackage> = serde_json::from_slice(&std)?;
72+
let mut out = BTreeMap::new();
73+
for std in stds {
74+
out.insert(std.package_id.into(), std.abi()?);
75+
}
76+
Ok(out)
77+
}
78+
6579
pub fn install_std(&self, test: bool) -> Result<(), MovyError> {
6680
// This is pretty hacky but works
6781
let stds = if test {
@@ -164,6 +178,15 @@ impl<
164178
gas,
165179
None,
166180
)?;
181+
if results.effects.status().is_err() {
182+
let err = eyre!(
183+
"movy_init failed at {}: {:?}",
184+
md.module_id,
185+
results.effects.status()
186+
);
187+
log::warn!("{err}");
188+
continue;
189+
}
167190
log::info!("Commiting movy_init effects...");
168191
log::debug!(
169192
"Status: {:?} Changed Objects: {}, Removed Objects: {}",

crates/movy-types/src/abi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ impl MoveAbiSignatureToken {
550550
}
551551

552552
pub fn is_balance(&self) -> bool {
553-
let MoveAbiSignatureToken::Struct(inner) = self else {
553+
let MoveAbiSignatureToken::StructInstantiation(inner, _) = self else {
554554
return false;
555555
};
556556
inner.module_id.module_address == MoveAddress::two()
@@ -559,7 +559,7 @@ impl MoveAbiSignatureToken {
559559
}
560560

561561
pub fn is_coin(&self) -> bool {
562-
let MoveAbiSignatureToken::Struct(inner) = self else {
562+
let MoveAbiSignatureToken::StructInstantiation(inner, _) = self else {
563563
return false;
564564
};
565565
inner.module_id.module_address == MoveAddress::two()

crates/movy/src/sui/env.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@ use sui_types::storage::{BackingPackageStore, BackingStore, ObjectStore};
2121

2222
#[derive(Args, Clone, Debug, Serialize, Deserialize)]
2323
pub struct SuiTargetArgs {
24-
#[arg(
25-
short,
26-
long,
27-
value_delimiter = ',',
28-
help = "The onchain packages to add."
29-
)]
24+
#[arg(long, value_delimiter = ',', help = "The onchain packages to add.")]
3025
pub onchains: Option<Vec<MoveAddress>>,
3126
#[arg(
3227
long,

crates/movy/src/sui/fuzz.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,17 @@ impl SuiFuzzArgs {
196196
let gas_id = ObjectID::random_from_rng(&mut rand);
197197
env.mint_coin_id(
198198
MoveTypeTag::from_str("0x2::sui::SUI").unwrap(),
199-
MoveOwner::AddressOwner(self.deployer),
199+
MoveOwner::AddressOwner(self.attacker),
200200
gas_id.into(),
201201
100_000_000_000,
202202
)?;
203+
// Mint SUI to attacker for fuzzing
204+
env.mint_coin_id(
205+
MoveTypeTag::from_str("0x2::sui::SUI").unwrap(),
206+
MoveOwner::AddressOwner(self.attacker),
207+
ObjectID::random_from_rng(&mut rand).into(),
208+
100_000_000_000,
209+
)?;
203210
let testing_env = SuiTestingEnv::new(env);
204211
testing_env.mock_testing_std()?;
205212

@@ -217,8 +224,8 @@ impl SuiFuzzArgs {
217224
&graphql,
218225
)
219226
.await?;
220-
let mut abis = BTreeMap::new();
221-
let mut testing_abis = BTreeMap::new();
227+
let mut abis = testing_env.std_abi(false)?;
228+
let mut testing_abis = testing_env.std_abi(true)?;
222229

223230
for (testing_abi, abi, names) in local_abis {
224231
let testing_pkg = testing_abi.package_id;

0 commit comments

Comments
 (0)