Skip to content

Commit

Permalink
Adding tests for [OZ] Multicall example (#548)
Browse files Browse the repository at this point in the history
Adding tests for multicall

Signed-off-by: Stefan Stefanov <[email protected]>
  • Loading branch information
stefan-stefanooov authored Nov 8, 2023
1 parent 693c64f commit 231f85b
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
14 changes: 14 additions & 0 deletions contracts/oz/multicall/MulticallTest.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/utils/Multicall.sol";

contract MulticallTest is Multicall {
function foo() public pure returns (uint256) {
return 123;
}

function bar() public pure returns (uint256) {
return 456;
}
}
8 changes: 8 additions & 0 deletions test/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ const Path = {
TYPE_OPS: 'contracts/solidity/typeops/TypeOps.sol:TypeOps',
}

const OZ = {
ERC165: {
Test: 'Test_ERC165',
IClimber: 'IClimber',
ClimberSelector: 'ClimberSelector',
},
}

const Contract = {
ERC20Mock: 'ERC20Mock',
TokenCreateContract: 'TokenCreateContract',
Expand Down
45 changes: 45 additions & 0 deletions test/solidity/oz/multicall/multicall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*-
*
* Hedera Smart Contracts
*
* Copyright (C) 2023 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

const { expect } = require('chai')
const { ethers } = require('hardhat')
const { Contract } = require('../../../constants')

describe('@solidityequiv3 Solidity OZ Multicall', function () {
let contract

before(async function () {
const factoryErrorsExternal = await ethers.getContractFactory('MulticallTest')
contract = await factoryErrorsExternal.deploy()
await contract.deployed()
})

it('should perform a multicall', async function () {
const foo = await contract.populateTransaction.foo()
const bar = await contract.populateTransaction.bar()
const res = await contract.callStatic.multicall([
foo.data, bar.data
])

expect(ethers.BigNumber.from(res[0])).to.be.equal(ethers.BigNumber.from(123))
expect(ethers.BigNumber.from(res[1])).to.be.equal(ethers.BigNumber.from(456))
})

})

0 comments on commit 231f85b

Please sign in to comment.