Skip to content

Commit

Permalink
refactor: simplify PreparedTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbinth committed Dec 26, 2023
1 parent 0a29e02 commit 61ad737
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 202 deletions.
12 changes: 6 additions & 6 deletions miden-lib/src/tests/test_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn test_set_code_is_not_immediate() {
prepare_transaction(account, None, block_header, chain, notes, None, code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down Expand Up @@ -261,7 +261,7 @@ fn test_get_item() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let _process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down Expand Up @@ -321,7 +321,7 @@ fn test_set_item() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let _process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down Expand Up @@ -376,7 +376,7 @@ fn test_get_map_item() {
);

let _process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down Expand Up @@ -413,7 +413,7 @@ fn test_get_vault_commitment() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let _process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down Expand Up @@ -461,7 +461,7 @@ fn test_authenticate_procedure() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
);
Expand Down
16 changes: 5 additions & 11 deletions miden-lib/src/tests/test_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ fn test_create_fungible_asset_succeeds() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let mut advice_provider = MemAdviceProvider::from(transaction.advice_provider_inputs());
let _process = run_tx(
transaction.tx_program().clone(),
transaction.stack_inputs(),
&mut advice_provider,
);
let _process =
run_tx(transaction.program().clone(), transaction.stack_inputs(), &mut advice_provider);
}

#[test]
Expand Down Expand Up @@ -93,10 +90,7 @@ fn test_create_non_fungible_asset_succeeds() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let mut advice_provider = MemAdviceProvider::from(transaction.advice_provider_inputs());
let _process = run_tx(
transaction.tx_program().clone(),
transaction.stack_inputs(),
&mut advice_provider,
)
.unwrap();
let _process =
run_tx(transaction.program().clone(), transaction.stack_inputs(), &mut advice_provider)
.unwrap();
}
24 changes: 12 additions & 12 deletions miden-lib/src/tests/test_asset_vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn test_get_balance() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down Expand Up @@ -74,7 +74,7 @@ fn test_get_balance_non_fungible_fails() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
);
Expand Down Expand Up @@ -106,7 +106,7 @@ fn test_has_non_fungible_asset() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
inputs.tx_program().clone(),
inputs.program().clone(),
inputs.stack_inputs(),
MemAdviceProvider::from(inputs.advice_provider_inputs()),
)
Expand Down Expand Up @@ -144,7 +144,7 @@ fn test_add_fungible_asset_success() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down Expand Up @@ -190,7 +190,7 @@ fn test_add_non_fungible_asset_fail_overflow() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
);
Expand Down Expand Up @@ -231,7 +231,7 @@ fn test_add_non_fungible_asset_success() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down Expand Up @@ -278,7 +278,7 @@ fn test_add_non_fungible_asset_fail_duplicate() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
);
Expand Down Expand Up @@ -316,7 +316,7 @@ fn test_remove_fungible_asset_success_no_balance_remaining() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down Expand Up @@ -361,7 +361,7 @@ fn test_remove_fungible_asset_fail_remove_too_much() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
);
Expand Down Expand Up @@ -397,7 +397,7 @@ fn test_remove_fungible_asset_success_balance_remaining() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down Expand Up @@ -444,7 +444,7 @@ fn test_remove_non_fungible_asset_fail_doesnt_exist() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
);
Expand Down Expand Up @@ -483,7 +483,7 @@ fn test_remove_non_fungible_asset_success() {
prepare_transaction(account, None, block_header, chain, notes, None, &code, "", None);

let process = run_tx(
transaction.tx_program().clone(),
transaction.program().clone(),
transaction.stack_inputs(),
MemAdviceProvider::from(transaction.advice_provider_inputs()),
)
Expand Down
Loading

0 comments on commit 61ad737

Please sign in to comment.