Skip to content

Commit

Permalink
fix gas amounts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ekleog-NEAR committed Jan 9, 2023
1 parent 442cc00 commit fdceb8b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion runtime/near-test-contracts/test-contract-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ fn attach_unspent_gas_but_burn_all_gas() {
gas_weight,
);
loop {
gas(10_000);
gas(1_000_000_000);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/near-vm-runner/src/tests/rs_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def_test_ext!(ext_block_timestamp, "ext_block_timestamp", &42u64.to_le_bytes());
def_test_ext!(ext_storage_usage, "ext_storage_usage", &12u64.to_le_bytes());
// Note, the used_gas is not a global used_gas at the beginning of method, but instead a diff
// in used_gas for computing fib(30) in a loop
def_test_ext!(ext_used_gas, "ext_used_gas", &[111, 10, 200, 15, 0, 0, 0, 0]);
def_test_ext!(ext_used_gas, "ext_used_gas", &[72, 146, 120, 16, 0, 0, 0, 0]);
def_test_ext!(
ext_sha256,
"ext_sha256",
Expand Down
18 changes: 18 additions & 0 deletions runtime/near-vm-runner/src/tests/runtime_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,24 @@ fn test_address_overflow() {
"#]]);
}

/// Load from address that is within bounds, validating that not all loads do overflow
#[test]
fn test_address_valid() {
let code = r#"
(module
(memory 1)
(func (export "main")
i32.const 10
i64.load32_u offset=10 align=1
drop
)
)"#;

test_builder().wat(code).expect(expect![[r#"
VMOutcome: balance 4 storage_usage 12 return data None burnt gas 50958989 used gas 50958989
"#]]);
}

/// Uses `f32.copysign` to observe a sign of `NaN`.
///
/// WASM specification allows different behaviors here:
Expand Down

0 comments on commit fdceb8b

Please sign in to comment.