Skip to content

Commit

Permalink
Merge pull request #119 from ethstorage/ownable2step
Browse files Browse the repository at this point in the history
Use Ownable2Step instead of Ownable
  • Loading branch information
qzhodl authored Oct 29, 2024
2 parents c4ca613 + fbbba8b commit 0aded1d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contracts/DecentralizedKV.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import "./libraries/MerkleLib.sol";
import "./libraries/BinaryRelated.sol";

/// @custom:upgradeable
/// @title DecentralizedKV
/// @notice The DecentralizedKV is a top base contract for the EthStorage contract. It provides the
/// basic key-value store functionalities.
contract DecentralizedKV is OwnableUpgradeable {
contract DecentralizedKV is Ownable2StepUpgradeable {
/// @notice Represents the metadata of the key-value .
/// @custom:field kvIdx Internal address seeking.
/// @custom:field kvSize BLOB size.
Expand Down
32 changes: 32 additions & 0 deletions contracts/test/DecentralizedKVTest.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.28;

import "./TestDecentralizedKV.sol";
import "forge-std/Test.sol";

contract DecentralizedKVTest is Test {
uint256 constant MAX_KV_SIZE = 17;
uint256 constant STORAGE_COST = 10000000;
uint256 constant SHARD_SIZE_BITS = 19;
uint256 constant PREPAID_AMOUNT = 2 * STORAGE_COST;
TestDecentralizedKV decentralizedKV;

function setUp() public {
decentralizedKV = new TestDecentralizedKV(MAX_KV_SIZE, 0, STORAGE_COST, 340282366367469178095360967382638002176);
decentralizedKV.initialize(vm.addr(1));
}

function testTransferOwnership() public {
vm.expectRevert();
vm.prank(address(vm.addr(2)));
decentralizedKV.transferOwnership(vm.addr(2));

vm.prank(address(vm.addr(1)));
decentralizedKV.transferOwnership(vm.addr(2));
assertEq(decentralizedKV.owner(), vm.addr(1));

vm.prank(address(vm.addr(2)));
decentralizedKV.acceptOwnership();
assertEq(decentralizedKV.owner(), vm.addr(2));
}
}

0 comments on commit 0aded1d

Please sign in to comment.