-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add LightClientArbitrum * fix typos * contract-bindings * format and add test
- Loading branch information
Showing
7 changed files
with
192 additions
and
7 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import { LightClient } from "./LightClient.sol"; | ||
|
||
interface ArbSys { | ||
function arbBlockNumber() external view returns (uint256); | ||
} | ||
|
||
contract LightClientArbitrum is LightClient { | ||
function currentBlockNumber() public view virtual override returns (uint256) { | ||
return ArbSys(address(uint160(100))).arbBlockNumber(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-License-Identifier: Unlicensed | ||
pragma solidity ^0.8.0; | ||
|
||
import "forge-std/Test.sol"; | ||
import { LightClientArbitrum, ArbSys } from "../src/LightClientArbitrum.sol"; | ||
|
||
contract MockArbSys is ArbSys { | ||
function arbBlockNumber() external pure override returns (uint256) { | ||
return 123456; | ||
} | ||
} | ||
|
||
contract LightClientArbitrumTest is Test { | ||
LightClientArbitrum public lc; | ||
MockArbSys mockArbsys; | ||
|
||
function setUp() public { | ||
vm.createSelectFork("https://arb1.arbitrum.io/rpc"); | ||
mockArbsys = new MockArbSys(); | ||
vm.etch(address(100), address(mockArbsys).code); // Replace address(100) with mock | ||
// implementation | ||
lc = new LightClientArbitrum(); | ||
} | ||
|
||
function testCurrentBlockNumber() public { | ||
assertNotEq(lc.currentBlockNumber(), block.number); | ||
assertEq(lc.currentBlockNumber(), ArbSys(address(uint160(100))).arbBlockNumber()); | ||
} | ||
} |