Skip to content

Commit 6754f00

Browse files
committed
fmt
1 parent 183f527 commit 6754f00

File tree

2 files changed

+61
-61
lines changed

2 files changed

+61
-61
lines changed

soroban-sdk/src/bytes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ macro_rules! impl_bytesn_repr {
158158
fn try_from_val(_env: &Env, elt: &$elem) -> Result<Self, Self::Error> {
159159
Ok(elt.to_val())
160160
}
161-
}
161+
}
162162

163163
#[cfg(not(target_family = "wasm"))]
164164
impl From<&$elem> for ScVal {
165165
fn from(v: &$elem) -> Self {
166166
Self::from(&v.0)
167167
}
168168
}
169-
169+
170170
#[cfg(not(target_family = "wasm"))]
171171
impl From<$elem> for ScVal {
172172
fn from(v: $elem) -> Self {

soroban-sdk/src/testutils/arbitrary.rs

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ mod objects {
320320

321321
use crate::xdr::{Int256Parts, ScVal, UInt256Parts};
322322
use crate::{
323-
Address, Bytes, BytesN, Duration, Map, String, Symbol, Timepoint, Val, Vec, I256, U256, crypto::bls12_381::{G1Affine, G2Affine, Fr}
323+
crypto::bls12_381::{Fr, G1Affine, G2Affine},
324+
Address, Bytes, BytesN, Duration, Map, String, Symbol, Timepoint, Val, Vec, I256, U256,
324325
};
325326

326327
use std::string::String as RustString;
@@ -681,64 +682,63 @@ mod objects {
681682
}
682683
}
683684

684-
// For G1Affine (96 bytes)
685-
#[derive(Arbitrary, Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
686-
pub struct ArbitraryG1Affine {
687-
bytes: [u8; 96]
688-
}
689-
690-
impl SorobanArbitrary for G1Affine {
691-
type Prototype = ArbitraryG1Affine;
692-
}
693-
694-
impl TryFromVal<Env, ArbitraryG1Affine> for G1Affine {
695-
type Error = ConversionError;
696-
697-
fn try_from_val(env: &Env, v: &ArbitraryG1Affine) -> Result<Self, Self::Error> {
698-
let mut bytes = v.bytes;
699-
bytes[0] &= 0b0001_1111; // Clear the top 3 bits
700-
Ok(G1Affine::from_array(env, &bytes))
701-
}
702-
}
703-
704-
// For G2Affine (192 bytes)
705-
#[derive(Arbitrary, Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
706-
pub struct ArbitraryG2Affine {
707-
bytes: [u8; 192]
708-
}
709-
710-
impl SorobanArbitrary for G2Affine {
711-
type Prototype = ArbitraryG2Affine;
712-
}
713-
714-
impl TryFromVal<Env, ArbitraryG2Affine> for G2Affine {
715-
type Error = ConversionError;
716-
717-
fn try_from_val(env: &Env, v: &ArbitraryG2Affine) -> Result<Self, Self::Error> {
718-
let mut bytes = v.bytes;
719-
bytes[0] &= 0b0001_1111; // Clear the top 3 bits
720-
Ok(G2Affine::from_array(env, &bytes))
721-
}
722-
}
723-
724-
725-
#[derive(Arbitrary, Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
726-
pub struct ArbitraryFr {
727-
bytes: [u8; 32]
728-
}
729-
730-
impl SorobanArbitrary for Fr {
731-
type Prototype = ArbitraryFr;
732-
}
733-
734-
impl TryFromVal<Env, ArbitraryFr> for Fr {
735-
type Error = ConversionError;
736-
737-
fn try_from_val(env: &Env, v: &ArbitraryFr) -> Result<Self, Self::Error> {
738-
// Convert bytes to Fr via U256
685+
// For G1Affine (96 bytes)
686+
#[derive(Arbitrary, Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
687+
pub struct ArbitraryG1Affine {
688+
bytes: [u8; 96],
689+
}
690+
691+
impl SorobanArbitrary for G1Affine {
692+
type Prototype = ArbitraryG1Affine;
693+
}
694+
695+
impl TryFromVal<Env, ArbitraryG1Affine> for G1Affine {
696+
type Error = ConversionError;
697+
698+
fn try_from_val(env: &Env, v: &ArbitraryG1Affine) -> Result<Self, Self::Error> {
699+
let mut bytes = v.bytes;
700+
bytes[0] &= 0b0001_1111; // Clear the top 3 bits
701+
Ok(G1Affine::from_array(env, &bytes))
702+
}
703+
}
704+
705+
// For G2Affine (192 bytes)
706+
#[derive(Arbitrary, Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
707+
pub struct ArbitraryG2Affine {
708+
bytes: [u8; 192],
709+
}
710+
711+
impl SorobanArbitrary for G2Affine {
712+
type Prototype = ArbitraryG2Affine;
713+
}
714+
715+
impl TryFromVal<Env, ArbitraryG2Affine> for G2Affine {
716+
type Error = ConversionError;
717+
718+
fn try_from_val(env: &Env, v: &ArbitraryG2Affine) -> Result<Self, Self::Error> {
719+
let mut bytes = v.bytes;
720+
bytes[0] &= 0b0001_1111; // Clear the top 3 bits
721+
Ok(G2Affine::from_array(env, &bytes))
722+
}
723+
}
724+
725+
#[derive(Arbitrary, Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
726+
pub struct ArbitraryFr {
727+
bytes: [u8; 32],
728+
}
729+
730+
impl SorobanArbitrary for Fr {
731+
type Prototype = ArbitraryFr;
732+
}
733+
734+
impl TryFromVal<Env, ArbitraryFr> for Fr {
735+
type Error = ConversionError;
736+
737+
fn try_from_val(env: &Env, v: &ArbitraryFr) -> Result<Self, Self::Error> {
738+
// Convert bytes to Fr via U256
739739
Ok(Fr::from_bytes(BytesN::from_array(env, &v.bytes)))
740-
}
741-
}
740+
}
741+
}
742742
}
743743

744744
/// Implementations of `soroban_sdk::testutils::arbitrary::api` for tuples of Soroban types.
@@ -829,7 +829,7 @@ mod composite {
829829
use super::objects::*;
830830
use super::simple::*;
831831
use crate::{
832-
Address, Bytes, BytesN, Duration, Map, String, Symbol, Timepoint, Val, Vec, I256, U256,
832+
Address, Bytes, BytesN, Duration, Map, String, Symbol, Timepoint, Val, Vec, I256, U256,
833833
};
834834

835835
#[derive(Arbitrary, Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]

0 commit comments

Comments
 (0)