From 0f6eb306ea952e5e33acda6073ffd5f0efdcf79b Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Wed, 23 Nov 2022 12:41:21 +0100 Subject: [PATCH] [marketplace] Remove resize() No longer needed --- contracts/libs/TestUtils.sol | 17 -------------- contracts/libs/Utils.sol | 19 --------------- test/Utils.test.js | 45 ------------------------------------ 3 files changed, 81 deletions(-) delete mode 100644 contracts/libs/TestUtils.sol delete mode 100644 test/Utils.test.js diff --git a/contracts/libs/TestUtils.sol b/contracts/libs/TestUtils.sol deleted file mode 100644 index 6ae06e1..0000000 --- a/contracts/libs/TestUtils.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import "./Utils.sol"; - -// exposes public functions for testing -contract TestUtils { - - function resize(bytes32[] memory array, - uint8 newSize) - public - pure - returns (bytes32[] memory) - { - return Utils._resize(array, newSize); - } -} diff --git a/contracts/libs/Utils.sol b/contracts/libs/Utils.sol index ea4bacb..12ed64e 100644 --- a/contracts/libs/Utils.sol +++ b/contracts/libs/Utils.sol @@ -6,25 +6,6 @@ import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; library Utils { using EnumerableSet for EnumerableSet.Bytes32Set; - function _resize(bytes32[] memory array, uint8 newSize) - internal - pure - returns (bytes32[] memory) - { - require(newSize <= array.length, "size out of bounds"); - - if (newSize == 0) { - bytes32[] memory empty; - return empty; - } else { - bytes32[] memory sized = new bytes32[](newSize); - for (uint8 i = 0; i < newSize; i++) { - sized[i] = array[i]; - } - return sized; - } - } - function filter( EnumerableSet.Bytes32Set storage set, function(bytes32) internal view returns (bool) include diff --git a/test/Utils.test.js b/test/Utils.test.js deleted file mode 100644 index 7d9799b..0000000 --- a/test/Utils.test.js +++ /dev/null @@ -1,45 +0,0 @@ -const { ethers } = require("hardhat") -const { expect } = require("chai") -const { hexlify, randomBytes } = ethers.utils -const { exampleAddress } = require("./examples") -const { hexZeroPad } = require("ethers/lib/utils") - -describe("Utils", function () { - let contract - let value1 - let value2 - let value3 - let value4 - let value5 - let array - - describe("resize", function () { - beforeEach(async function () { - let Utils = await ethers.getContractFactory("TestUtils") - contract = await Utils.deploy() - value1 = hexlify(randomBytes(32)) - value2 = hexlify(randomBytes(32)) - value3 = hexlify(randomBytes(32)) - value4 = hexZeroPad(0, 32) - value5 = hexZeroPad(0, 32) - array = [value1, value2, value3, value4, value5] - }) - - it("resizes to zero length if new size is 0", async function () { - await expect(await contract.resize(array, 0)).to.deep.equal([]) - }) - - it("resizes to specified length", async function () { - await expect(await contract.resize(array, 3)).to.deep.equal([ - value1, - value2, - value3, - ]) - }) - - it("fails to resize to out of bounds length", async function () { - await expect(contract.resize(array, 6)) - .to.be.revertedWith("size out of bounds") - }) - }) -})