Skip to content

Commit

Permalink
Fix snapshot tests and some other gas price issues in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchTurner committed Feb 13, 2024
1 parent 2d307d2 commit d9091fe
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 68 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: fuel-tx/src/transaction/types/input/snapshot_tests.rs
assertion_line: 72
expression: hex
---
0000000000000000000000000000000000000000000000000000000000000000000000000000000d00000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000007b00000000000f424000000000000000010101010101010101010101010101010101010101010101010101010101010101000000000000000202020202020202020202020202020202020202020202020202020202020202020303030303030303030303030303030303030303030303030303030303030303000000000000002e00000000000000050505050505050505050505050505050505050505050505050505050505050505
0000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b00000000000f424000000000000000010101010101010101010101010101010101010101010101010101010101010101000000000000000202020202020202020202020202020202020202020202020202020202020202020303030303030303030303030303030303030303030303030303030303030303000000000000002e00000000000000050505050505050505050505050505050505050505050505050505050505050505

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: fuel-tx/src/transaction/types/input/snapshot_tests.rs
assertion_line: 53
expression: hex
---
0000000000000000000000000000000000000000000000000000000000000000000000000000000d00000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000007b00000000000f42400000000000000000010101010101010101010101010101010101010101010101010101010101010100000000000000020202020202020202020202020202020202020202020202020202020202020202000000000000000b0505050505050505050505050505050505050505050505050505050505050505000000000000002e00000000000000050000000000000000000000000000000200000000000186a0000000000000000a000000000000000c0303030303030303030300000000000004040404040404040404040400000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b00000000000f42400000000000000000010101010101010101010101010101010101010101010101010101010101010100000000000000020202020202020202020202020202020202020202020202020202020202020202000000000000000b0505050505050505050505050505050505050505050505050505050505050505000000000000002e00000000000000050000000000000000000000000000000200000000000186a0000000000000000a000000000000000c0303030303030303030300000000000004040404040404040404040400000000

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: fuel-tx/src/transaction/types/input/snapshot_tests.rs
assertion_line: 119
expression: hex
---
0000000000000000000000000000000000000000000000000000000000000000000000000000000d00000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000007b00000000000f424000000000000000020202020202020202020202020202020202020202020202020202020202020202030303030303030303030303030303030303030303030303030303030303030300000000000000040505050505050505050505050505050505050505050505050505050505050505000000000000000000000000000186a00000000000000000000000000000000b000000000000000c0707070707070707070707000000000008080808080808080808080800000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b00000000000f424000000000000000020202020202020202020202020202020202020202020202020202020202020202030303030303030303030303030303030303030303030303030303030303030300000000000000040505050505050505050505050505050505050505050505050505050505050505000000000000000000000000000186a00000000000000000000000000000000b000000000000000c0707070707070707070707000000000008080808080808080808080800000000

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: fuel-tx/src/transaction/types/input/snapshot_tests.rs
assertion_line: 166
expression: hex
---
0000000000000000000000000000000000000000000000000000000000000000000000000000000d00000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000007b00000000000f424000000000000000020202020202020202020202020202020202020202020202020202020202020202030303030303030303030303030303030303030303030303030303030303030300000000000000040505050505050505050505050505050505050505050505050505050505050505000000000000000000000000000186a0000000000000000a000000000000000b000000000000000c060606060606060606060000000000000707070707070707070707000000000008080808080808080808080800000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b00000000000f424000000000000000020202020202020202020202020202020202020202020202020202020202020202030303030303030303030303030303030303030303030303030303030303030300000000000000040505050505050505050505050505050505050505050505050505050505050505000000000000000000000000000186a0000000000000000a000000000000000b000000000000000c060606060606060606060000000000000707070707070707070707000000000008080808080808080808080800000000

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: fuel-tx/src/transaction/types/input/snapshot_tests.rs
assertion_line: 29
expression: hex
---
0000000000000000000000000000000000000000000000000000000000000000000000000000000f0000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000003e8000000000000007b00000000000f42400000000000000000010101010101010101010101010101010101010101010101010101010101010100000000000000020202020202020202020202020202020202020202020202020202020202020202000000000000000b0505050505050505050505050505050505050505050505050505050505050505000000000000002e000000000000000500000000000000040000000000000002000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003e8000000000000007b00000000000f42400000000000000000010101010101010101010101010101010101010101010101010101010101010100000000000000020202020202020202020202020202020202020202020202020202020202020202000000000000000b0505050505050505050505050505050505050505050505050505050505050505000000000000002e000000000000000500000000000000040000000000000002000000000000000000000000000000000000000000000000

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: fuel-tx/src/transaction/types/input/snapshot_tests.rs
assertion_line: 96
expression: hex
---
0000000000000000000000000000000000000000000000000000000000000000000000000000000f0000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000003e8000000000000007b00000000000f42400000000000000002020202020202020202020202020202020202020202020202020202020202020203030303030303030303030303030303030303030303030303030303030303030000000000000004050505050505050505050505050505050505050505050505050505050505050500000000000000060000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003e8000000000000007b00000000000f42400000000000000002020202020202020202020202020202020202020202020202020202020202020203030303030303030303030303030303030303030303030303030303030303030000000000000004050505050505050505050505050505050505050505050505050505050505050500000000000000060000000000000000000000000000000000000000000000000000000000000000

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: fuel-tx/src/transaction/types/input/snapshot_tests.rs
assertion_line: 143
expression: hex
---
0000000000000000000000000000000000000000000000000000000000000000000000000000000f0000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000003e8000000000000007b00000000000f42400000000000000002020202020202020202020202020202020202020202020202020202020202020203030303030303030303030303030303030303030303030303030303030303030000000000000004050505050505050505050505050505050505050505050505050505050505050500000000000000060000000000000000000000000000000a0000000000000000000000000000000007070707070707070707000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003e8000000000000007b00000000000f42400000000000000002020202020202020202020202020202020202020202020202020202020202020203030303030303030303030303030303030303030303030303030303030303030000000000000004050505050505050505050505050505050505050505050505050505050505050500000000000000060000000000000000000000000000000a0000000000000000000000000000000007070707070707070707000000000000

This file was deleted.

12 changes: 6 additions & 6 deletions fuel-vm/src/interpreter/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn breakpoint_script() {
let mut vm = Interpreter::<_, _>::with_memory_storage();

let gas_limit = 1_000_000;
let arb_gas_price = 1;
let zero_gas_price = 0;
let height = Default::default();

let script = [
Expand All @@ -91,7 +91,7 @@ fn breakpoint_script() {
.script_gas_limit(gas_limit)
.add_random_fee_input()
.finalize()
.into_checked(height, &consensus_params, arb_gas_price)
.into_checked(height, &consensus_params, zero_gas_price)
.expect("failed to generate checked tx");

let suite = vec![
Expand All @@ -116,7 +116,7 @@ fn breakpoint_script() {
suite.iter().for_each(|(b, _)| vm.set_breakpoint(*b));

let state = vm
.transact(tx, arb_gas_price)
.transact(tx, zero_gas_price)
.map(ProgramState::from)
.expect("Failed to execute script!");

Expand Down Expand Up @@ -144,7 +144,7 @@ fn single_stepping() {

let mut vm = Interpreter::<_, _>::with_memory_storage();

let arb_gas_price = 1;
let zero_gas_price = 0;

let gas_limit = 1_000_000;
let height = Default::default();
Expand All @@ -165,13 +165,13 @@ fn single_stepping() {
.script_gas_limit(gas_limit)
.add_random_fee_input()
.finalize()
.into_checked(height, &consensus_params, arb_gas_price)
.into_checked(height, &consensus_params, zero_gas_price)
.expect("failed to generate checked tx");

vm.set_single_stepping(true);

let mut state = vm
.transact(tx, arb_gas_price)
.transact(tx, zero_gas_price)
.map(ProgramState::from)
.expect("Failed to execute script!");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use quickcheck_macros::quickcheck;
// Ensure none of the opcodes can write to reserved registers
#[quickcheck]
fn cant_write_to_reserved_registers(raw_random_instruction: u32) -> TestResult {
let arb_gas_price = 1;
let zero_gas_price = 0;

let random_instruction = match Instruction::try_from(raw_random_instruction) {
Ok(inst) => inst,
Expand Down Expand Up @@ -67,7 +67,7 @@ fn cant_write_to_reserved_registers(raw_random_instruction: u32) -> TestResult {
.finalize();

let tx = tx
.into_checked(block_height, &consensus_params, arb_gas_price)
.into_checked(block_height, &consensus_params, zero_gas_price)
.expect("failed to check tx");

vm.init_script(tx).expect("Failed to init VM");
Expand Down
27 changes: 16 additions & 11 deletions fuel-vm/src/tests/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ fn get_transaction_fields() {

let mut client = MemoryClient::default();

let gas_price = 1;
let zero_gas_price = 0;
let witness_limit = 1234;
let max_fee_limit = 4321;
let gas_limit = 10_000_000;
Expand All @@ -296,9 +296,9 @@ fn get_transaction_fields() {
let tx = TransactionBuilder::create(contract, salt, storage_slots)
.add_output(Output::contract_created(contract_id, state_root))
.add_random_fee_input()
.finalize_checked(height, gas_price);
.finalize_checked(height, zero_gas_price);

client.deploy(tx, gas_price);
client.deploy(tx, zero_gas_price);

let predicate = vec![op::ret(RegId::ONE)].into_iter().collect::<Vec<u8>>();
let mut predicate_data = vec![0u8; 512];
Expand Down Expand Up @@ -391,7 +391,7 @@ fn get_transaction_fields() {
maturity,
)
.add_output(Output::coin(rng.gen(), asset_amt, asset))
.finalize_checked(height, gas_price);
.finalize_checked(height, zero_gas_price);

let inputs = tx.as_ref().inputs();
let outputs = tx.as_ref().outputs();
Expand Down Expand Up @@ -469,11 +469,12 @@ fn get_transaction_fields() {
op::eq(0x10, 0x10, 0x11),
op::and(0x20, 0x20, 0x10),

op::movi(0x11, gas_price as Immediate18),
op::movi(0x19, 0x00),
op::gtf_args(0x10, 0x19, GTFArgs::PolicyTip),
op::eq(0x10, 0x10, 0x11),
op::and(0x20, 0x20, 0x10),
// TODO: Implement Tip stuff.
// op::movi(0x11, gas_price as Immediate18),
// op::movi(0x19, 0x00),
// op::gtf_args(0x10, 0x19, GTFArgs::PolicyTip),
// op::eq(0x10, 0x10, 0x11),
// op::and(0x20, 0x20, 0x10),

op::movi(0x19, 0x00),
op::movi(0x11, (gas_limit & 0x3ffff) as Immediate18),
Expand Down Expand Up @@ -888,11 +889,15 @@ fn get_transaction_fields() {
.script_gas_limit(gas_limit)
.witness_limit(witness_limit)
.max_fee_limit(max_fee_limit)
.finalize_checked_basic(height, gas_price);
.finalize_checked_basic(height, zero_gas_price);

let receipts = client.transact(tx, gas_price);
let receipts = client.transact(tx, zero_gas_price);
let success = receipts
.iter()
.map(|r| {
dbg!(&r);
r
})
.any(|r| matches!(r, Receipt::Log{ ra, .. } if ra == &1));

assert!(success);
Expand Down

0 comments on commit d9091fe

Please sign in to comment.