Skip to content

Commit f18557c

Browse files
committed
Fix rebaseOptIn selector and test setup ordering
1 parent cdc0790 commit f18557c

6 files changed

Lines changed: 22 additions & 29 deletions

File tree

contracts/foundry.toml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@ remappings = [
1515
"forge-std/=lib/forge-std/src/"
1616
]
1717

18-
# Exclude certora and test directories from compilation
19-
exclude = [
20-
"lib/openzeppelin-contracts/certora",
21-
"lib/openzeppelin-contracts-upgradeable/certora",
22-
"lib/openzeppelin-contracts-upgradeable/lib",
23-
"lib/openzeppelin-contracts-upgradeable/test"
24-
]
25-
2618
# Arbitrum specific settings
2719
gas_limit = 1099511627775
2820
block_gas_limit = 1125899906842624

contracts/src/X402RevenueSplitter.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ contract X402RevenueSplitter is Ownable, ReentrancyGuard {
115115

116116
// Opt into USDs rebase for auto-yield
117117
if (_usds != address(0)) {
118-
try IUSDs(_usds).optInRebase() {} catch {}
118+
try IUSDs(_usds).rebaseOptIn() {} catch {}
119119
}
120120
}
121121

contracts/test/CreditSystem.t.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ contract CreditSystemTest is Test {
4141

4242
function setUp() public {
4343
// Mock USDs
44+
// Use explicit selector for rebaseOptIn() - no params version
4445
vm.mockCall(
4546
USDS,
46-
abi.encodeWithSelector(IUSDs.rebaseOptIn.selector),
47+
abi.encodeWithSelector(bytes4(keccak256("rebaseOptIn()"))),
4748
abi.encode()
4849
);
4950

contracts/test/PaymentChannel.t.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ contract PaymentChannelTest is Test {
4646
sender = vm.addr(senderPrivateKey);
4747
recipient = vm.addr(recipientPrivateKey);
4848

49+
// Mock USDs rebaseOptIn - must happen before proxy deployment
50+
vm.mockCall(
51+
USDS,
52+
abi.encodeWithSelector(bytes4(keccak256("rebaseOptIn()"))),
53+
abi.encode()
54+
);
55+
4956
// Deploy implementation
5057
channelImpl = new X402PaymentChannel();
5158

@@ -54,13 +61,6 @@ contract PaymentChannelTest is Test {
5461
ERC1967Proxy proxy = new ERC1967Proxy(address(channelImpl), initData);
5562
channel = X402PaymentChannel(address(proxy));
5663

57-
// Mock USDs rebaseOptIn
58-
vm.mockCall(
59-
USDS,
60-
abi.encodeWithSelector(IUSDs.rebaseOptIn.selector),
61-
abi.encode()
62-
);
63-
6464
// Fund sender
6565
vm.deal(sender, 100 ether);
6666
}

contracts/test/Subscription.t.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,23 @@ contract SubscriptionTest is Test {
4444
event Withdrawn(address indexed subscriber, uint256 amount);
4545

4646
function setUp() public {
47+
// Mock USDs - must happen before proxy deployment
48+
_mockUSDs();
49+
4750
// Deploy implementation
4851
subscriptionImpl = new X402Subscription();
4952

5053
// Deploy proxy
5154
bytes memory initData = abi.encodeWithSelector(X402Subscription.initialize.selector);
5255
ERC1967Proxy proxy = new ERC1967Proxy(address(subscriptionImpl), initData);
5356
subscription = X402Subscription(address(proxy));
54-
55-
// Mock USDs
56-
_mockUSDs();
5757
}
5858

5959
function _mockUSDs() internal {
60-
// Mock rebaseOptIn
60+
// Mock rebaseOptIn - use explicit selector for no-params version
6161
vm.mockCall(
6262
USDS,
63-
abi.encodeWithSelector(IUSDs.rebaseOptIn.selector),
63+
abi.encodeWithSelector(bytes4(keccak256("rebaseOptIn()"))),
6464
abi.encode()
6565
);
6666

contracts/test/ToolRegistry.t.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ contract ToolRegistryTest is Test {
4545
// Uncomment for integration tests:
4646
// vm.createSelectFork(vm.envString("ARBITRUM_RPC_URL"));
4747

48+
// Mock USDs for unit tests - must happen before proxy deployment
49+
vm.mockCall(
50+
USDS,
51+
abi.encodeWithSelector(bytes4(keccak256("rebaseOptIn()"))),
52+
abi.encode()
53+
);
54+
4855
// Deploy implementation
4956
registryImpl = new ToolRegistry();
5057

@@ -56,13 +63,6 @@ contract ToolRegistryTest is Test {
5663
);
5764
ERC1967Proxy proxy = new ERC1967Proxy(address(registryImpl), initData);
5865
registry = ToolRegistry(address(proxy));
59-
60-
// Mock USDs for unit tests
61-
vm.mockCall(
62-
USDS,
63-
abi.encodeWithSelector(IUSDs.rebaseOptIn.selector),
64-
abi.encode()
65-
);
6666
}
6767

6868
/*//////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)