File tree Expand file tree Collapse file tree 3 files changed +65
-1
lines changed
Expand file tree Collapse file tree 3 files changed +65
-1
lines changed Original file line number Diff line number Diff line change 1+ name : Forge Unit Tests
2+
3+ on :
4+ pull_request : {}
5+ push :
6+ branches : [ main ]
7+
8+ jobs :
9+ unit-tests :
10+ runs-on : ubuntu-latest
11+ env :
12+ CI : true
13+
14+ steps :
15+ - name : Setup Node.js
16+ uses : actions/setup-node@v3
17+ with :
18+ node-version : " 25"
19+
20+ - name : Checkout
21+ uses : actions/checkout@v3
22+
23+ - name : Install deps
24+ run : |
25+ npm ci
26+
27+ - name : Run unit tests
28+ run : npm test
Original file line number Diff line number Diff line change 55 "deploy" : " forge script script/DeployAll.s.sol --rpc-url anvil --broadcast" ,
66 "compile" : " forge build" ,
77 "postinstall" : " forge build" ,
8- "clean" : " rm -rf build"
8+ "clean" : " rm -rf build" ,
9+ "test" : " forge test -vvv"
910 },
1011 "dependencies" : {
1112 "@hyperledger-labs/yui-ibc-solidity" : " git+https://github.com/hyperledger-labs/yui-ibc-solidity.git#v0.3.40" ,
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: Apache-2.0
2+ pragma solidity ^ 0.8.20 ;
3+
4+ import "forge-std/src/Test.sol " ;
5+ import "../src/core/IBCKeeper.sol " ;
6+
7+ contract DummyHandler {}
8+
9+ contract TestableIBCKeeper is IBCKeeper {
10+ constructor (IIBCHandler h ) IBCKeeper (h) {}
11+
12+ function handlerAddr () external view returns (address ) {
13+ return address (getIBCHandler ());
14+ }
15+ }
16+
17+ contract IBCKeeperTest is Test {
18+ DummyHandler dummy;
19+ TestableIBCKeeper keeper;
20+
21+ function setUp () public {
22+ dummy = new DummyHandler ();
23+ keeper = new TestableIBCKeeper (IIBCHandler (address (dummy)));
24+ }
25+
26+ function test_GetIBCHandler_GetIBCHandlerReturnsSameAddress () public view {
27+ address h = keeper.handlerAddr ();
28+ assertEq (h, address (dummy));
29+ }
30+
31+ function test_Constructor_AllowsZeroAddress () public {
32+ TestableIBCKeeper k = new TestableIBCKeeper (IIBCHandler (address (0 )));
33+ assertEq (k.handlerAddr (), address (0 ));
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments