Skip to content

Commit

Permalink
chore(protocol): add tests for LibNetwork (#18626)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaodino authored Dec 22, 2024
1 parent 18d6ab7 commit 0d26d18
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions packages/protocol/test/shared/libs/LibNetwork.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;

import "src/shared/libs/LibTrieProof.sol";
import "../CommonTest.sol";

contract LibNetworkTest is CommonTest {
function test_isEthereumTestnet() public pure {
assertTrue(LibNetwork.isEthereumTestnet(LibNetwork.ETHEREUM_ROPSTEN));
assertTrue(LibNetwork.isEthereumTestnet(LibNetwork.ETHEREUM_RINKEBY));
assertTrue(LibNetwork.isEthereumTestnet(LibNetwork.ETHEREUM_GOERLI));
assertTrue(LibNetwork.isEthereumTestnet(LibNetwork.ETHEREUM_KOVAN));
assertTrue(LibNetwork.isEthereumTestnet(LibNetwork.ETHEREUM_HOLESKY));
assertTrue(LibNetwork.isEthereumTestnet(LibNetwork.ETHEREUM_SEPOLIA));
assertFalse(LibNetwork.isEthereumTestnet(LibNetwork.ETHEREUM_MAINNET));
assertFalse(LibNetwork.isEthereumTestnet(LibNetwork.TAIKO_MAINNET));
}

function test_isEthereumMainnetOrTestnet() public pure {
assertTrue(LibNetwork.isEthereumMainnetOrTestnet(LibNetwork.ETHEREUM_MAINNET));
assertTrue(LibNetwork.isEthereumMainnetOrTestnet(LibNetwork.ETHEREUM_ROPSTEN));
assertTrue(LibNetwork.isEthereumMainnetOrTestnet(LibNetwork.ETHEREUM_RINKEBY));
assertTrue(LibNetwork.isEthereumMainnetOrTestnet(LibNetwork.ETHEREUM_GOERLI));
assertTrue(LibNetwork.isEthereumMainnetOrTestnet(LibNetwork.ETHEREUM_KOVAN));
assertTrue(LibNetwork.isEthereumMainnetOrTestnet(LibNetwork.ETHEREUM_HOLESKY));
assertTrue(LibNetwork.isEthereumMainnetOrTestnet(LibNetwork.ETHEREUM_SEPOLIA));
assertFalse(LibNetwork.isEthereumMainnetOrTestnet(LibNetwork.TAIKO_MAINNET));
}

function test_isTaikoMainnet() public pure {
assertTrue(LibNetwork.isTaikoMainnet(LibNetwork.TAIKO_MAINNET));
assertFalse(LibNetwork.isTaikoMainnet(LibNetwork.ETHEREUM_MAINNET));
assertFalse(LibNetwork.isTaikoMainnet(LibNetwork.TAIKO_HEKLA));
}

function test_isTaikoDevnet() public pure {
assertTrue(LibNetwork.isTaikoDevnet(32_300));
assertTrue(LibNetwork.isTaikoDevnet(32_350));
assertTrue(LibNetwork.isTaikoDevnet(32_400));
assertFalse(LibNetwork.isTaikoDevnet(32_299));
assertFalse(LibNetwork.isTaikoDevnet(32_401));
assertFalse(LibNetwork.isTaikoDevnet(LibNetwork.TAIKO_MAINNET));
}

function test_isDencunSupported() public pure {
assertTrue(LibNetwork.isDencunSupported(LibNetwork.ETHEREUM_MAINNET));
assertTrue(LibNetwork.isDencunSupported(LibNetwork.ETHEREUM_HOLESKY));
assertTrue(LibNetwork.isDencunSupported(LibNetwork.ETHEREUM_SEPOLIA));
assertTrue(LibNetwork.isDencunSupported(32_350)); // Taiko Devnet within range
assertFalse(LibNetwork.isDencunSupported(LibNetwork.ETHEREUM_ROPSTEN));
assertFalse(LibNetwork.isDencunSupported(LibNetwork.TAIKO_MAINNET));
}
}

0 comments on commit 0d26d18

Please sign in to comment.