Skip to content

Commit

Permalink
fixed test dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dan13ram committed Sep 4, 2024
1 parent ef00df4 commit 0e3dccb
Show file tree
Hide file tree
Showing 8 changed files with 983 additions and 19 deletions.
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"@layerzerolabs/lz-evm-messagelib-v2": "^2.1.27",
"@layerzerolabs/lz-evm-oapp-v2": "^2.1.18",
"@layerzerolabs/lz-evm-protocol-v2": "^2.1.27",
"@openzeppelin/contracts": "^5.0.1",
"@openzeppelin/contracts-upgradeable": "^5.0.2",
"@openzeppelin/contracts": "4.9.2",
"@openzeppelin/contracts-upgradeable": "4.9.2",
"forge-std": "github:foundry-rs/forge-std#v1.8.1",
"husky": "^9.1.5",
"layerzero-v2": "github:JorgeAtPaladin/LayerZero-v2#lz-upgrade",
Expand All @@ -22,5 +22,9 @@
"format": "forge fmt --root .",
"test": "forge test -vvv",
"prepare": "husky"
},
"dependencies": {
"@layerzerolabs/lz-evm-v1-0.7": "^2.3.40",
"hardhat-deploy": "^0.12.4"
}
}
}
8 changes: 6 additions & 2 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
ds-test/=node_modules/ds-test/src/
forge-std/=node_modules/forge-std/src/
@layerzerolabs/lz-evm-oapp-v2/contracts/=node_modules/@layerzerolabs/lz-evm-oapp-v2/contracts/
@layerzerolabs/lz-evm-protocol-v2/contracts/=node_modules/@layerzerolabs/lz-evm-protocol-v2/contracts/
@layerzerolabs/lz-evm-messagelib-v2/contracts/=node_modules/@layerzerolabs/lz-evm-messagelib-v2/contracts/
@layerzerolabs/lz-evm-protocol-v2/contracts/=node_modules/layerzero-v2/protocol/contracts/
@layerzerolabs/lz-evm-messagelib-v2/contracts/=node_modules/layerzero-v2/messagelib/contracts/
@layerzerolabs/lz-evm-oapp-v2/contracts-upgradeable/=node_modules/layerzero-v2/oapp/contracts/
@layerzerolabs/lz-evm-oapp-v2/test/=node_modules/layerzero-v2/oapp/test/
@layerzerolabs/lz-evm-v1-0.7/=node_modules/@layerzerolabs/lz-evm-v1-0.7/
@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/
@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/
@solmate/=lib/solmate/src/
@adapters/=src/
@factory/=src/factory/
@interfaces/=src/interfaces/
solidity-bytes-utils/=node_modules/solidity-bytes-utils/
hardhat-deploy/=node_modules/hardhat-deploy/

3 changes: 2 additions & 1 deletion src/L1YnOFTAdapterUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ contract L1YnOFTAdapterUpgradeable is OFTAdapterUpgradeable, AccessControlUpgrad
*/
function initialize(address _owner, RateLimitConfig[] calldata _rateLimitConfigs) external virtual initializer {
__OFTAdapter_init(_owner);
__Ownable_init(_owner);
__Ownable_init();
__AccessControl_init();
_grantRole(DEFAULT_ADMIN_ROLE, _owner);
_setRateLimits(_rateLimitConfigs);
_transferOwnership(_owner);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/L2YnOFTAdapterUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ contract L2YnOFTAdapterUpgradeable is OFTAdapterUpgradeable, AccessControlUpgrad
*/
function initialize(address _owner, RateLimitConfig[] calldata _rateLimitConfigs) external virtual initializer {
__OFTAdapter_init(_owner);
__Ownable_init(_owner);
__Ownable_init();
__AccessControl_init();
_grantRole(DEFAULT_ADMIN_ROLE, _owner);
_setRateLimits(_rateLimitConfigs);
_transferOwnership(_owner);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions test/CrossChainBaseTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import {L2YnERC20Upgradeable} from "@adapters/L2YnERC20Upgradeable.sol";
import {L2YnOFTAdapterUpgradeable} from "@adapters/L2YnOFTAdapterUpgradeable.sol";
import {RateLimiter} from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/utils/RateLimiter.sol";
import {ERC20Mock} from "@layerzerolabs/lz-evm-oapp-v2/test/mocks/ERC20Mock.sol";
import {TestHelper} from "@layerzerolabs/lz-evm-oapp-v2/test/TestHelper.sol";
import "forge-std/console.sol";

contract CrossChainBaseTest is Test {
contract CrossChainBaseTest is TestHelper {
ImmutableMultiChainDeployer public mainnetDeployer;
ImmutableMultiChainDeployer public optimismDeployer;
ImmutableMultiChainDeployer public arbitrumDeployer;
Expand Down Expand Up @@ -48,7 +49,7 @@ contract CrossChainBaseTest is Test {
// uint256 fraxFork;
// uint256 baseFork;

function setUp() public {
function setUp() public override {
// create forks
optimismFork = vm.createFork(vm.envString("OPTIMISM_RPC_URL"), 124909408);
arbitrumFork = vm.createFork(vm.envString("ARBITRUM_RPC_URL"), 249855816);
Expand Down
42 changes: 42 additions & 0 deletions test/L1YnOFTAdapterUpgradeable.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,48 @@ import {L2YnERC20Upgradeable} from "@adapters/L2YnERC20Upgradeable.sol";
import {L2YnOFTAdapterUpgradeable} from "@adapters/L2YnOFTAdapterUpgradeable.sol";
import {RateLimiter} from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/utils/RateLimiter.sol";

import {IOFT, SendParam, OFTReceipt} from "@layerzerolabs/lz-evm-oapp-v2/contracts/oft/interfaces/IOFT.sol";

contract Test_L1YnOFTAdapterUpgradeable is CrossChainBaseTest {
// function test_contructor() public {
// vm.selectFork(mainnetFork);
// assertEq(aOFT.owner(), address(this));
// assertEq(bOFT.owner(), address(this));
// assertEq(cOFTAdapter.owner(), address(this));
//
// assertEq(aOFT.balanceOf(userA), initialBalance);
// assertEq(bOFT.balanceOf(userB), initialBalance);
// assertEq(IERC20(cOFTAdapter.token()).balanceOf(userC), initialBalance);
//
// assertEq(aOFT.token(), address(aOFT));
// assertEq(bOFT.token(), address(bOFT));
// assertEq(cOFTAdapter.token(), address(cERC20Mock));
// }

function test_L1OFTAdapterDeployment() public {}

// function test_send_oft() public {
// uint256 tokensToSend = 1 ether;
// bytes memory options = OptionsBuilder.newOptions().addExecutorLzReceiveOption(200000, 0);
// SendParam memory sendParam = SendParam(
// bEid,
// addressToBytes32(userB),
// tokensToSend,
// tokensToSend,
// options,
// "",
// ""
// );
// MessagingFee memory fee = aOFT.quoteSend(sendParam, false);
//
// assertEq(aOFT.balanceOf(userA), initialBalance);
// assertEq(bOFT.balanceOf(userB), initialBalance);
//
// vm.prank(userA);
// aOFT.send{ value: fee.nativeFee }(sendParam, fee, payable(address(this)));
// verifyPackets(bEid, addressToBytes32(address(bOFT)));
//
// assertEq(aOFT.balanceOf(userA), initialBalance - tokensToSend);
// assertEq(bOFT.balanceOf(userB), initialBalance + tokensToSend);
// }
}
5 changes: 3 additions & 2 deletions test/mocks/OFTAdapterHarness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {OFTAdapterUpgradeable} from "@layerzerolabs/lz-evm-oapp-v2/contracts-upg
import {OFTUpgradeable} from "@layerzerolabs/lz-evm-oapp-v2/contracts-upgradeable/oft/OFTUpgradeable.sol";

abstract contract OFTAdapterHarness is L2YnOFTAdapterUpgradeable {
constructor(address _token, address _lzEndpoint, address _delegate) {
constructor(address _token, address _lzEndpoint) L2YnOFTAdapterUpgradeable(_token, _lzEndpoint) {
_disableInitializers();
}

Expand All @@ -17,10 +17,11 @@ abstract contract OFTAdapterHarness is L2YnOFTAdapterUpgradeable {
initializer
{
super.__OFTAdapter_init(_owner);
super.__Ownable_init(_owner);
super.__Ownable_init();
super.__AccessControl_init();
super._grantRole(DEFAULT_ADMIN_ROLE, _owner);
super._setRateLimits(_rateLimitConfigs);
super._transferOwnership(_owner);
}
// @dev expose internal functions for testing purposes

Expand Down
Loading

0 comments on commit 0e3dccb

Please sign in to comment.