-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding tests for [OZ] Multicall example (#548)
Adding tests for multicall Signed-off-by: Stefan Stefanov <[email protected]>
- Loading branch information
1 parent
693c64f
commit 231f85b
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
}) | ||
|
||
}) |