File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -1954,7 +1954,10 @@ impl Cheatcodes {
19541954
19551955 #[ cold]
19561956 fn meter_gas_reset ( & mut self , interpreter : & mut Interpreter ) {
1957- interpreter. gas = Gas :: new ( interpreter. gas . limit ( ) ) ;
1957+ let mut gas = Gas :: new ( interpreter. gas . limit ( ) ) ;
1958+ gas. memory_mut ( ) . words_num = interpreter. gas . memory ( ) . words_num ;
1959+ gas. memory_mut ( ) . expansion_cost = interpreter. gas . memory ( ) . expansion_cost ;
1960+ interpreter. gas = gas;
19581961 self . gas_metering . reset = false ;
19591962 }
19601963
Original file line number Diff line number Diff line change @@ -1744,6 +1744,15 @@ contract ATest is DSTest {
17441744 b = new B();
17451745 vm.resetGasMetering();
17461746 }
1747+
1748+ // https://github.com/foundry-rs/foundry/issues/12474
1749+ function testMemoryOnReset(uint8[1] memory x) public {
1750+ uint8[1] memory z;
1751+ z[0] = x[0];
1752+ assertEq(z[0], x[0]);
1753+ vm.resetGasMetering();
1754+ assertEq(x[0], z[0]);
1755+ }
17471756}
17481757 "# ,
17491758 ) ;
You can’t perform that action at this time.
0 commit comments