Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added _disableInitializers and the unit tests #252

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions apps/blockchain/ethereum/src/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import "./Messaging.sol";
import "./UUPSProxied.sol";

import "starknet/IStarknetMessaging.sol";
import "openzeppelin-contracts/contracts/proxy/utils/Initializable.sol";

import "./IStarklaneEvent.sol";

Expand Down Expand Up @@ -50,9 +51,12 @@ contract Starklane is

/**
* @notice Initializes the implementation, only callable once.
*
* @param data Data to init the implementation.
*/

constructor() {
_disableInitializers();
}

function initialize(bytes calldata data) public onlyInit {
(
address owner,
Expand Down
19 changes: 19 additions & 0 deletions apps/blockchain/ethereum/test/Bridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,25 @@ contract BridgeTest is Test, IStarklaneEvent {
IStarklane(bridge).enableBridge(true);
}

//
function test_initializersDisabled() public {
// Deploy a new instance of Starklane
Starklane newStarklane = new Starklane();

// Try to initialize the contract directly
bytes memory initData = abi.encode(
address(this),
address(0), // Mock Starknet Core address
uint256(0), // Mock Starklane L2 address
uint256(0) // Mock Starklane L2 selector
);

// Expect the initialization to revert
vm.expectRevert("Initializable: contract is already initialized");
newStarklane.initialize(initData);
}


//
function testFail_invalidIds() public {
uint256[] memory ids = new uint256[](0);
Expand Down
Loading