Skip to content

Commit 1fd044b

Browse files
committed
feat: implement _resolveRpcUrl function to dynamically resolve RPC URLs for RSK mainnet and testnet
1 parent 04af03a commit 1fd044b

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

test/differential/base/DifferentialBase.sol

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ abstract contract DifferentialBase is Test {
4949
uint256 pinBlock,
5050
uint256 btcBlockTime
5151
) internal {
52-
string memory rpcUrl = vm.rpcUrl(networkKey);
52+
string memory rpcUrl = _resolveRpcUrl(networkKey);
5353
harness.forkId = _createForkSafe(rpcUrl, pinBlock);
5454

5555
vm.selectFork(harness.forkId);
@@ -128,6 +128,27 @@ abstract contract DifferentialBase is Test {
128128
return vm.parseJsonAddress(addressesJson, key);
129129
}
130130

131+
function _resolveRpcUrl(
132+
string memory networkKey
133+
) internal view returns (string memory) {
134+
bytes32 networkHash = keccak256(bytes(networkKey));
135+
if (networkHash == keccak256(bytes("rskMainnet"))) {
136+
return
137+
vm.envOr(
138+
"MAINNET_RPC_URL",
139+
string("https://public-node.rsk.co")
140+
);
141+
}
142+
if (networkHash == keccak256(bytes("rskTestnet"))) {
143+
return
144+
vm.envOr(
145+
"TESTNET_RPC_URL",
146+
string("https://public-node.testnet.rsk.co")
147+
);
148+
}
149+
revert("Unsupported differential network key");
150+
}
151+
131152
function _assertReferenceCompatibility(
132153
address referenceTarget
133154
) internal view {

0 commit comments

Comments
 (0)