Skip to content

Commit

Permalink
Generate all types of addresses when fuzzing. (#1122)
Browse files Browse the repository at this point in the history
### What

Generate both ScAddress::Contract and ScAddress::Account when fuzzing.

### Why

Currently only ScAddress::Contract is generated.

Closes #1096

### Known limitations

I don't really understand the consequences for fuzz testers of making
this change. Maybe there aren't any. I have tested that the fuzzer in
soroban-examples continues to work.
  • Loading branch information
brson authored Oct 24, 2023
1 parent d9aac56 commit 6b04bfc
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions soroban-sdk/src/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ mod objects {

#[derive(Arbitrary, Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct ArbitraryAddress {
inner: [u8; 32],
inner: crate::env::xdr::ScAddress,
}

impl SorobanArbitrary for Address {
Expand All @@ -542,10 +542,7 @@ mod objects {
impl TryFromVal<Env, ArbitraryAddress> for Address {
type Error = ConversionError;
fn try_from_val(env: &Env, v: &ArbitraryAddress) -> Result<Self, Self::Error> {
use crate::env::xdr::{Hash, ScAddress};

let sc_addr = ScVal::Address(ScAddress::Contract(Hash(v.inner)));
Ok(sc_addr.into_val(env))
Ok(v.inner.into_val(env))
}
}

Expand Down

0 comments on commit 6b04bfc

Please sign in to comment.