Skip to content

Commit

Permalink
ISA tests use Address instead of Bech32Address (#1727)
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez authored Dec 1, 2023
1 parent f83945b commit 93d7727
Show file tree
Hide file tree
Showing 13 changed files with 1,784 additions and 1,069 deletions.
423 changes: 286 additions & 137 deletions sdk/tests/client/input_selection/account_outputs.rs

Large diffs are not rendered by default.

820 changes: 630 additions & 190 deletions sdk/tests/client/input_selection/basic_outputs.rs

Large diffs are not rendered by default.

262 changes: 168 additions & 94 deletions sdk/tests/client/input_selection/expiration.rs

Large diffs are not rendered by default.

216 changes: 172 additions & 44 deletions sdk/tests/client/input_selection/foundry_outputs.rs

Large diffs are not rendered by default.

269 changes: 166 additions & 103 deletions sdk/tests/client/input_selection/nft_outputs.rs

Large diffs are not rendered by default.

83 changes: 61 additions & 22 deletions sdk/tests/client/input_selection/outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use std::str::FromStr;

use iota_sdk::{
client::api::input_selection::{Burn, Error, InputSelection},
types::block::{output::AccountId, protocol::protocol_parameters},
types::block::{address::Address, output::AccountId, protocol::protocol_parameters},
};
use pretty_assertions::assert_eq;

use crate::client::{
addresses, build_inputs, build_outputs, is_remainder_or_return, unsorted_eq,
build_inputs, build_outputs, is_remainder_or_return, unsorted_eq,
Build::{Account, Basic},
ACCOUNT_ID_2, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1,
};
Expand All @@ -22,7 +22,7 @@ fn no_inputs() {
let inputs = Vec::new();
let outputs = build_outputs([Basic(
1_000_000,
BECH32_ADDRESS_ED25519_0,
Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(),
None,
None,
None,
Expand All @@ -34,7 +34,7 @@ fn no_inputs() {
let selected = InputSelection::new(
inputs,
outputs,
addresses([BECH32_ADDRESS_ED25519_0]),
[Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()],
protocol_parameters,
)
.select();
Expand All @@ -48,7 +48,7 @@ fn no_outputs() {

let inputs = build_inputs([Basic(
1_000_000,
BECH32_ADDRESS_ED25519_0,
Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(),
None,
None,
None,
Expand All @@ -61,7 +61,7 @@ fn no_outputs() {
let selected = InputSelection::new(
inputs,
outputs,
addresses([BECH32_ADDRESS_ED25519_0]),
[Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()],
protocol_parameters,
)
.select();
Expand All @@ -77,7 +77,7 @@ fn no_outputs_but_burn() {
let inputs = build_inputs([Account(
2_000_000,
account_id_2,
BECH32_ADDRESS_ED25519_0,
Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(),
None,
None,
None,
Expand All @@ -87,7 +87,7 @@ fn no_outputs_but_burn() {
let selected = InputSelection::new(
inputs.clone(),
outputs,
addresses([BECH32_ADDRESS_ED25519_0]),
[Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()],
protocol_parameters,
)
.with_burn(Burn::new().add_account(account_id_2))
Expand All @@ -99,7 +99,7 @@ fn no_outputs_but_burn() {
assert!(is_remainder_or_return(
&selected.outputs[0],
2_000_000,
BECH32_ADDRESS_ED25519_0,
Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(),
None
));
}
Expand All @@ -110,7 +110,7 @@ fn no_address_provided() {

let inputs = build_inputs([Basic(
1_000_000,
BECH32_ADDRESS_ED25519_0,
Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(),
None,
None,
None,
Expand All @@ -120,7 +120,7 @@ fn no_address_provided() {
)]);
let outputs = build_outputs([Basic(
1_000_000,
BECH32_ADDRESS_ED25519_0,
Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(),
None,
None,
None,
Expand All @@ -140,7 +140,7 @@ fn no_matching_address_provided() {

let inputs = build_inputs([Basic(
1_000_000,
BECH32_ADDRESS_ED25519_0,
Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(),
None,
None,
None,
Expand All @@ -150,7 +150,7 @@ fn no_matching_address_provided() {
)]);
let outputs = build_outputs([Basic(
1_000_000,
BECH32_ADDRESS_ED25519_0,
Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(),
None,
None,
None,
Expand All @@ -162,7 +162,7 @@ fn no_matching_address_provided() {
let selected = InputSelection::new(
inputs,
outputs,
addresses([BECH32_ADDRESS_ED25519_1]),
[Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()],
protocol_parameters,
)
.select();
Expand All @@ -175,12 +175,30 @@ fn two_addresses_one_missing() {
let protocol_parameters = protocol_parameters();

let inputs = build_inputs([
Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None),
Basic(1_000_000, BECH32_ADDRESS_ED25519_1, None, None, None, None, None, None),
Basic(
1_000_000,
Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(),
None,
None,
None,
None,
None,
None,
),
Basic(
1_000_000,
Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(),
None,
None,
None,
None,
None,
None,
),
]);
let outputs = build_outputs([Basic(
2_000_000,
BECH32_ADDRESS_ED25519_0,
Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(),
None,
None,
None,
Expand All @@ -192,7 +210,7 @@ fn two_addresses_one_missing() {
let selected = InputSelection::new(
inputs,
outputs,
addresses([BECH32_ADDRESS_ED25519_0]),
[Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()],
protocol_parameters,
)
.select();
Expand All @@ -211,12 +229,30 @@ fn two_addresses() {
let protocol_parameters = protocol_parameters();

let inputs = build_inputs([
Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None),
Basic(1_000_000, BECH32_ADDRESS_ED25519_1, None, None, None, None, None, None),
Basic(
1_000_000,
Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(),
None,
None,
None,
None,
None,
None,
),
Basic(
1_000_000,
Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(),
None,
None,
None,
None,
None,
None,
),
]);
let outputs = build_outputs([Basic(
2_000_000,
BECH32_ADDRESS_ED25519_0,
Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(),
None,
None,
None,
Expand All @@ -228,7 +264,10 @@ fn two_addresses() {
let selected = InputSelection::new(
inputs.clone(),
outputs.clone(),
addresses([BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1]),
[
Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(),
Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(),
],
protocol_parameters,
)
.select()
Expand Down
Loading

0 comments on commit 93d7727

Please sign in to comment.