Skip to content

Commit

Permalink
Add 2 more restricted tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez committed Oct 30, 2023
1 parent 11c7c9d commit 3a403c3
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions sdk/tests/client/input_selection/basic_outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,99 @@ fn restricted_ed25519() {
assert!(unsorted_eq(&selected.outputs, &outputs));
}

#[test]
fn restricted_nft() {
let protocol_parameters = protocol_parameters();
let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap();
let nft_address = Address::from(nft_id_1);
let restricted = RestrictedAddress::new(nft_address.clone()).unwrap();
let restricted_bech32 = restricted.to_bech32_unchecked("rms").to_string();

let inputs = build_inputs([
Basic(2_000_000, &restricted_bech32, None, None, None, None, None, None),
Nft(
2_000_000,
nft_id_1,
BECH32_ADDRESS_ED25519_0,
None,
None,
None,
None,
None,
None,
),
]);
let outputs = build_outputs([Basic(
3_000_000,
BECH32_ADDRESS_ED25519_0,
None,
None,
None,
None,
None,
None,
)]);

let selected = InputSelection::new(
inputs.clone(),
outputs.clone(),
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.select()
.unwrap();

assert!(unsorted_eq(&selected.inputs, &inputs));
assert_eq!(selected.outputs.len(), 2);
assert!(selected.outputs.contains(&outputs[0]));
}

#[test]
fn restricted_account() {
let protocol_parameters = protocol_parameters();
let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap();
let account_address = Address::from(account_id_1);
let restricted = RestrictedAddress::new(account_address.clone()).unwrap();
let restricted_bech32 = restricted.to_bech32_unchecked("rms").to_string();

let inputs = build_inputs([
Basic(2_000_000, &restricted_bech32, None, None, None, None, None, None),
Account(
2_000_000,
account_id_1,
BECH32_ADDRESS_ED25519_0,
None,
None,
None,
None,
),
]);

let outputs = build_outputs([Basic(
3_000_000,
BECH32_ADDRESS_ED25519_0,
None,
None,
None,
None,
None,
None,
)]);

let selected = InputSelection::new(
inputs.clone(),
outputs.clone(),
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.select()
.unwrap();

assert!(unsorted_eq(&selected.inputs, &inputs));
assert_eq!(selected.outputs.len(), 2);
assert!(selected.outputs.contains(&outputs[0]));
}

#[test]
fn restricted_ed25519_sender() {
let protocol_parameters = protocol_parameters();
Expand Down

0 comments on commit 3a403c3

Please sign in to comment.