Skip to content

Commit

Permalink
Add output storage score tests (#1827)
Browse files Browse the repository at this point in the history
* Add fixtures from output TIPs and tests

* fmt

* fix test data

* expiration slot_index -> slot

* nits

---------

Co-authored-by: Thoralf-M <[email protected]>
Co-authored-by: /alex/ <[email protected]>
Co-authored-by: Thibault Martinez <[email protected]>
  • Loading branch information
4 people authored Jan 17, 2024
1 parent b809589 commit cb0d39f
Show file tree
Hide file tree
Showing 10 changed files with 443 additions and 488 deletions.
7 changes: 3 additions & 4 deletions sdk/src/types/block/output/unlock_condition/expiration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ pub(crate) mod dto {
#[serde(rename = "type")]
kind: u8,
return_address: Address,
slot_index: SlotIndex,
slot: SlotIndex,
}

impl From<&ExpirationUnlockCondition> for ExpirationUnlockConditionDto {
fn from(value: &ExpirationUnlockCondition) -> Self {
Self {
kind: ExpirationUnlockCondition::KIND,
return_address: value.return_address().clone(),
slot_index: value.slot_index(),
slot: value.slot_index(),
}
}
}
Expand All @@ -142,8 +142,7 @@ pub(crate) mod dto {
type Error = Error;

fn try_from(value: ExpirationUnlockConditionDto) -> Result<Self, Error> {
Self::new(value.return_address, value.slot_index)
.map_err(|_| Error::InvalidField("expirationUnlockCondition"))
Self::new(value.return_address, value.slot).map_err(|_| Error::InvalidField("expirationUnlockCondition"))
}
}

Expand Down
6 changes: 3 additions & 3 deletions sdk/src/types/block/output/unlock_condition/timelock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ pub(crate) mod dto {
struct TimelockUnlockConditionDto {
#[serde(rename = "type")]
kind: u8,
slot_index: SlotIndex,
slot: SlotIndex,
}

impl From<&TimelockUnlockCondition> for TimelockUnlockConditionDto {
fn from(value: &TimelockUnlockCondition) -> Self {
Self {
kind: TimelockUnlockCondition::KIND,
slot_index: value.slot_index(),
slot: value.slot_index(),
}
}
}
Expand All @@ -75,7 +75,7 @@ pub(crate) mod dto {
type Error = Error;

fn try_from(value: TimelockUnlockConditionDto) -> Result<Self, Error> {
Self::new(value.slot_index).map_err(|_| Error::InvalidField("timelockUnlockCondition"))
Self::new(value.slot).map_err(|_| Error::InvalidField("timelockUnlockCondition"))
}
}

Expand Down
Loading

0 comments on commit cb0d39f

Please sign in to comment.