Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchTurner committed Feb 21, 2024
1 parent d7546e2 commit fd747ba
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion fuel-vm/src/checked_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,7 @@ mod tests {
)
.unwrap()
// Sets Checks::Predicates
.check_predicates(arb_gas_price, &check_predicate_params)
.check_predicates( &check_predicate_params)
.unwrap();
assert!(checked
.checks()
Expand Down
3 changes: 1 addition & 2 deletions fuel-vm/src/interpreter/executors/main/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn estimate_gas_gives_proper_gas_used() {

let transaction_without_predicate = builder
.finalize_checked_basic(Default::default(), gas_price)
.check_predicates(gas_price, &params.into())
.check_predicates(&params.into())
.expect("Predicate check failed even if we don't have any predicates");

let mut client = MemoryClient::default();
Expand Down Expand Up @@ -99,7 +99,6 @@ fn estimate_gas_gives_proper_gas_used() {

Interpreter::<PredicateStorage, _>::estimate_predicates(
&mut transaction,
gas_price,
&params.into(),
)
.expect("Should successfully estimate predicates");
Expand Down
1 change: 0 additions & 1 deletion fuel-vm/src/predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ mod tests {

let result = Interpreter::<PredicateStorage, Script>::check_predicates(
&tx,
zero_gas_price,
&CheckPredicateParams::default(),
);

Expand Down
4 changes: 2 additions & 2 deletions fuel-vm/src/tests/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ async fn recover_tx_id_predicate() {
// parallel version
let mut tx_for_async = tx.clone();
tx_for_async
.estimate_predicates_async::<TokioWithRayon>(gas_price, &check_params)
.estimate_predicates_async::<TokioWithRayon>(&check_params)
.await
.expect("Should estimate predicate successfully");

Expand All @@ -240,7 +240,7 @@ async fn recover_tx_id_predicate() {
}

// sequential version
tx.estimate_predicates(gas_price, &check_params)
tx.estimate_predicates(&check_params)
.expect("Should estimate predicate successfully");

tx.into_checked(maturity, &consensus_params, gas_price)
Expand Down
44 changes: 20 additions & 24 deletions fuel-vm/src/tests/predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ where

let mut transaction = builder.finalize();
transaction
.estimate_predicates(gas_price, &ConsensusParameters::standard().into())
.estimate_predicates(&ConsensusParameters::standard().into())
.expect("Should estiamte predicate");

let checked = transaction
Expand All @@ -123,16 +123,15 @@ where

let parallel_execution = {
Interpreter::<PredicateStorage, _>::check_predicates_async::<TokioWithRayon>(
&checked, gas_price, &params,
&checked, &params,
)
.await
.map(|checked| checked.gas_used())
};

let seq_execution = Interpreter::<PredicateStorage, _>::check_predicates(
&checked, gas_price, &params,
)
.map(|checked| checked.gas_used());
let seq_execution =
Interpreter::<PredicateStorage, _>::check_predicates(&checked, &params)
.map(|checked| checked.gas_used());

match (parallel_execution, seq_execution) {
(Ok(p_gas_used), Ok(s_gas_used)) => {
Expand Down Expand Up @@ -259,7 +258,7 @@ async fn execute_gas_metered_predicates(
let parallel_gas_used = {
let mut async_tx = transaction.clone();
async_tx
.estimate_predicates_async::<TokioWithRayon>(gas_price, &params)
.estimate_predicates_async::<TokioWithRayon>(&params)
.await
.map_err(|_| ())?;

Expand All @@ -272,17 +271,15 @@ async fn execute_gas_metered_predicates(
.expect("Should successfully create checked tranaction with predicate");

Interpreter::<PredicateStorage, _>::check_predicates_async::<TokioWithRayon>(
&tx, gas_price, &params,
&tx, &params,
)
.await
.map(|r| r.gas_used())
.map_err(|_| ())?
};

// sequential version
transaction
.estimate_predicates(gas_price, &params)
.map_err(|_| ())?;
transaction.estimate_predicates(&params).map_err(|_| ())?;

let tx = transaction
.into_checked_basic(
Expand All @@ -292,10 +289,9 @@ async fn execute_gas_metered_predicates(
)
.expect("Should successfully create checked tranaction with predicate");

let seq_gas_used =
Interpreter::<PredicateStorage, _>::check_predicates(&tx, gas_price, &params)
.map(|r| r.gas_used())
.map_err(|_| ())?;
let seq_gas_used = Interpreter::<PredicateStorage, _>::check_predicates(&tx, &params)
.map(|r| r.gas_used())
.map_err(|_| ())?;

assert_eq!(seq_gas_used, parallel_gas_used);

Expand Down Expand Up @@ -382,14 +378,14 @@ async fn gas_used_by_predicates_not_causes_out_of_gas_during_script() {
let _ = builder
.clone()
.finalize_checked_basic(Default::default(), gas_price)
.check_predicates_async::<TokioWithRayon>(gas_price, &params)
.check_predicates_async::<TokioWithRayon>(&params)
.await
.expect("Predicate check failed even if we don't have any predicates");
}

let tx_without_predicate = builder
.finalize_checked_basic(Default::default(), gas_price)
.check_predicates(gas_price, &params)
.check_predicates(&params)
.expect("Predicate check failed even if we don't have any predicates");

let mut client = MemoryClient::default();
Expand Down Expand Up @@ -424,7 +420,7 @@ async fn gas_used_by_predicates_not_causes_out_of_gas_during_script() {

let mut transaction = builder.finalize();
transaction
.estimate_predicates(gas_price, &params)
.estimate_predicates(&params)
.expect("Predicate estimation failed");

let checked = transaction
Expand All @@ -439,7 +435,7 @@ async fn gas_used_by_predicates_not_causes_out_of_gas_during_script() {
{
let tx_with_predicate = checked
.clone()
.check_predicates_async::<TokioWithRayon>(gas_price, &params)
.check_predicates_async::<TokioWithRayon>(&params)
.await
.expect("Predicate check failed");

Expand All @@ -457,7 +453,7 @@ async fn gas_used_by_predicates_not_causes_out_of_gas_during_script() {
}

let tx_with_predicate = checked
.check_predicates(gas_price, &params)
.check_predicates(&params)
.expect("Predicate check failed");

client.transact(tx_with_predicate);
Expand Down Expand Up @@ -510,14 +506,14 @@ async fn gas_used_by_predicates_more_than_limit() {
let _ = builder
.clone()
.finalize_checked_basic(Default::default(), gas_price)
.check_predicates_async::<TokioWithRayon>(gas_price, &params)
.check_predicates_async::<TokioWithRayon>(&params)
.await
.expect("Predicate check failed even if we don't have any predicates");
}

let tx_without_predicate = builder
.finalize_checked_basic(Default::default(), gas_price)
.check_predicates(gas_price, &params)
.check_predicates(&params)
.expect("Predicate check failed even if we don't have any predicates");

let mut client = MemoryClient::default();
Expand Down Expand Up @@ -561,7 +557,7 @@ async fn gas_used_by_predicates_more_than_limit() {
let tx_with_predicate = builder
.clone()
.finalize_checked_basic(Default::default(), gas_price)
.check_predicates_async::<TokioWithRayon>(gas_price, &params)
.check_predicates_async::<TokioWithRayon>(&params)
.await;

assert!(matches!(
Expand All @@ -572,7 +568,7 @@ async fn gas_used_by_predicates_more_than_limit() {

let tx_with_predicate = builder
.finalize_checked_basic(Default::default(), gas_price)
.check_predicates(gas_price, &params);
.check_predicates(&params);

assert!(matches!(
tx_with_predicate.unwrap_err(),
Expand Down

0 comments on commit fd747ba

Please sign in to comment.