Skip to content

Commit

Permalink
Update CHANGELOG.md
Browse files Browse the repository at this point in the history
Added a test to verify correct behaviour
  • Loading branch information
xgreenx committed Feb 21, 2025
1 parent ec92671 commit 694e45d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- [904](https://github.com/FuelLabs/fuel-vm/pull/904): Moved the logic of each opcode into its own function. It helps so reduce the size of the `instruction_inner` function, allowing compiler to do better optimizations. The Mira swaps receive performance improvement in 16.5%.

### Fixed
- [917](https://github.com/FuelLabs/fuel-vm/pull/917): Ignore predicate verification during the estimation.
- [895](https://github.com/FuelLabs/fuel-vm/pull/895): Fix elided lifetimes compilation warnings that became errors after the release of rust 1.83.0.
- [895](https://github.com/FuelLabs/fuel-vm/pull/895): Bump proptest-derive to version `0.5.1` to fix non-local impl errors on the derivation of `proptest_derive::Arbitrary` introduced by rust 1.83.0.
- [889](https://github.com/FuelLabs/fuel-vm/pull/889) and [908](https://github.com/FuelLabs/fuel-vm/pull/908): Debugger breakpoint caused receipts to be produced incorrectly.
Expand Down
37 changes: 37 additions & 0 deletions fuel-vm/src/tests/predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use crate::{
use core::iter;
use fuel_tx::{
consensus_parameters::gas::GasCostsValuesV5,
field::Inputs,
ConsensusParameters,
};

Expand Down Expand Up @@ -162,6 +163,42 @@ where
}
}

#[test]
fn estimate_predicate_works_when_predicate_address_incorrect() {
let mut rng = StdRng::seed_from_u64(2322u64);
let predicate: Vec<u8> = iter::once(op::ret(0x01)).collect();
let predicate_data = vec![];

let mut builder = TransactionBuilder::script(vec![], vec![]);

// Given
let predicate_owner = rng.gen();
let input = Input::coin_predicate(
rng.gen(),
predicate_owner,
rng.gen(),
rng.gen(),
rng.gen(),
0,
predicate.clone(),
predicate_data.clone(),
);
builder.add_input(input);
let mut script = builder.finalize();

// When
assert_eq!(script.inputs()[0].predicate_gas_used(), Some(0));
let result = script.estimate_predicates(
&ConsensusParameters::standard().into(),
MemoryInstance::new(),
&EmptyStorage,
);

// Then
result.expect("Should estimate predicate");
assert_ne!(script.inputs()[0].predicate_gas_used(), Some(0));
}

#[test]
fn estimate_predicate_works_when_max_gas_per_predicate_less_than_tx_gas__10_inputs() {
let mut rng = StdRng::seed_from_u64(2322u64);
Expand Down

0 comments on commit 694e45d

Please sign in to comment.