Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
781ece27
Commit
781ece27
authored
Mar 08, 2023
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
contracts-bedrock: lint
parent
9bc5a547
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
18 deletions
+35
-18
ResourceMetering.t.sol
...s/contracts-bedrock/contracts/test/ResourceMetering.t.sol
+35
-18
No files found.
packages/contracts-bedrock/contracts/test/ResourceMetering.t.sol
View file @
781ece27
...
@@ -200,11 +200,11 @@ contract MeterUserCustom is ResourceMetering {
...
@@ -200,11 +200,11 @@ contract MeterUserCustom is ResourceMetering {
uint64 _prevBoughtGas,
uint64 _prevBoughtGas,
uint64 _prevBlockNum
uint64 _prevBlockNum
) {
) {
params = ResourceMetering.ResourceParams({
params = ResourceMetering.ResourceParams({
prevBaseFee: _prevBaseFee,
prevBaseFee: _prevBaseFee,
prevBoughtGas: _prevBoughtGas,
prevBoughtGas: _prevBoughtGas,
prevBlockNum: _prevBlockNum
prevBlockNum: _prevBlockNum
});
});
}
}
function use(uint64 _amount) public returns (uint256) {
function use(uint64 _amount) public returns (uint256) {
...
@@ -229,9 +229,11 @@ contract ResourceMeteringCustom_Test is Test {
...
@@ -229,9 +229,11 @@ contract ResourceMeteringCustom_Test is Test {
string internal outfile;
string internal outfile;
// keccak256(abi.encodeWithSignature("Error(string)", "ResourceMetering: cannot buy more gas than available gas limit"))
// keccak256(abi.encodeWithSignature("Error(string)", "ResourceMetering: cannot buy more gas than available gas limit"))
bytes32 internal cannotBuyMoreGas = 0x84edc668cfd5e050b8999f43ff87a1faaa93e5f935b20bc1dd4d3ff157ccf429;
bytes32 internal cannotBuyMoreGas =
0x84edc668cfd5e050b8999f43ff87a1faaa93e5f935b20bc1dd4d3ff157ccf429;
// keccak256(abi.encodeWithSignature("Panic(uint256)", 0x11))
// keccak256(abi.encodeWithSignature("Panic(uint256)", 0x11))
bytes32 internal overflowErr = 0x1ca389f2c8264faa4377de9ce8e14d6263ef29c68044a9272d405761bab2db27;
bytes32 internal overflowErr =
0x1ca389f2c8264faa4377de9ce8e14d6263ef29c68044a9272d405761bab2db27;
/**
/**
* @notice Sets the initial block number to something sane for the
* @notice Sets the initial block number to something sane for the
...
@@ -245,7 +247,10 @@ contract ResourceMeteringCustom_Test is Test {
...
@@ -245,7 +247,10 @@ contract ResourceMeteringCustom_Test is Test {
outfile = string.concat(vm.projectRoot(), "/.resource-metering.csv");
outfile = string.concat(vm.projectRoot(), "/.resource-metering.csv");
try vm.removeFile(outfile) {} catch {}
try vm.removeFile(outfile) {} catch {}
vm.writeLine(outfile, "prevBaseFee,prevBoughtGas,prevBlockNumDiff,l1BaseFee,requestedGas,gasConsumed,ethPrice,usdCost,success");
vm.writeLine(
outfile,
"prevBaseFee,prevBoughtGas,prevBlockNumDiff,l1BaseFee,requestedGas,gasConsumed,ethPrice,usdCost,success"
);
}
}
/**
/**
...
@@ -319,7 +324,9 @@ contract ResourceMeteringCustom_Test is Test {
...
@@ -319,7 +324,9 @@ contract ResourceMeteringCustom_Test is Test {
vm.roll(block.number + prevBlockNumDiff);
vm.roll(block.number + prevBlockNumDiff);
uint256 gasConsumed = 0;
uint256 gasConsumed = 0;
try meter.use{ gas: 30_000_000 }(requestedGas) returns (uint256 _gasConsumed) {
try meter.use{ gas: 30_000_000 }(requestedGas) returns (
uint256 _gasConsumed
) {
gasConsumed = _gasConsumed;
gasConsumed = _gasConsumed;
} catch (bytes memory err) {
} catch (bytes memory err) {
bytes32 hash = keccak256(err);
bytes32 hash = keccak256(err);
...
@@ -334,19 +341,29 @@ contract ResourceMeteringCustom_Test is Test {
...
@@ -334,19 +341,29 @@ contract ResourceMeteringCustom_Test is Test {
// Compute the USD cost of the gas used, don't
// Compute the USD cost of the gas used, don't
// worry too much about loss of precison under $1
// worry too much about loss of precison under $1
uint256 usdCost =
gasConsumed * l1BaseFee * ethPrice
/ 1 ether;
uint256 usdCost =
(gasConsumed * l1BaseFee * ethPrice)
/ 1 ether;
vm.writeLine(
vm.writeLine(
outfile,
outfile,
string.concat(
string.concat(
vm.toString(prevBaseFee), ",",
vm.toString(prevBaseFee),
vm.toString(prevBoughtGas), ",",
",",
vm.toString(prevBlockNumDiff), ",",
vm.toString(prevBoughtGas),
vm.toString(l1BaseFee), ",",
",",
vm.toString(requestedGas), ",",
vm.toString(prevBlockNumDiff),
vm.toString(gasConsumed), ",",
",",
"$", vm.toString(ethPrice), ",",
vm.toString(l1BaseFee),
"$", vm.toString(usdCost), ",",
",",
vm.toString(requestedGas),
",",
vm.toString(gasConsumed),
",",
"$",
vm.toString(ethPrice),
",",
"$",
vm.toString(usdCost),
",",
result
result
)
)
);
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment