|
1 | 1 | import { expect } from "chai"; |
2 | 2 | import hre, { deployments, ethers } from "hardhat"; |
3 | 3 | import { deployContract, getMock, getMultiSend, getSafeWithOwners, getDelegateCaller } from "../utils/setup"; |
4 | | -import { buildContractCall, buildSafeTransaction, executeTx, MetaTransaction, safeApproveHash } from "../../src/utils/execution"; |
| 4 | +import { |
| 5 | + buildContractCall, |
| 6 | + buildSafeTransaction, |
| 7 | + executeTx, |
| 8 | + executeTxWithSigners, |
| 9 | + MetaTransaction, |
| 10 | + safeApproveHash, |
| 11 | +} from "../../src/utils/execution"; |
5 | 12 | import { buildMultiSendSafeTx, encodeMultiSend } from "../../src/utils/multisend"; |
6 | 13 |
|
7 | 14 | describe("MultiSend", () => { |
@@ -281,5 +288,39 @@ describe("MultiSend", () => { |
281 | 288 |
|
282 | 289 | await expect(delegateCaller.makeDelegatecall.staticCall(multiSendAddress, data)).to.be.revertedWith(errorMessage); |
283 | 290 | }); |
| 291 | + |
| 292 | + it("forwards the call to self when to is zero address", async () => { |
| 293 | + const { |
| 294 | + safe, |
| 295 | + multiSend, |
| 296 | + signers: [user1], |
| 297 | + } = await setupTests(); |
| 298 | + const randomAddress1 = ethers.hexlify(ethers.randomBytes(20)); |
| 299 | + const randomAddress2 = ethers.hexlify(ethers.randomBytes(20)); |
| 300 | + |
| 301 | + await expect(await safe.isOwner(randomAddress1)).to.be.false; |
| 302 | + await expect(await safe.isOwner(randomAddress2)).to.be.false; |
| 303 | + |
| 304 | + const txs: MetaTransaction[] = [ |
| 305 | + { |
| 306 | + to: ethers.ZeroAddress, |
| 307 | + value: 0, |
| 308 | + data: safe.interface.encodeFunctionData("addOwnerWithThreshold", [randomAddress1, 1]), |
| 309 | + operation: 0, |
| 310 | + }, |
| 311 | + { |
| 312 | + to: ethers.ZeroAddress, |
| 313 | + value: 0, |
| 314 | + data: safe.interface.encodeFunctionData("addOwnerWithThreshold", [randomAddress2, 1]), |
| 315 | + operation: 0, |
| 316 | + }, |
| 317 | + ]; |
| 318 | + const safeTx = await buildMultiSendSafeTx(multiSend, txs, await safe.nonce()); |
| 319 | + |
| 320 | + await executeTxWithSigners(safe, safeTx, [user1]); |
| 321 | + |
| 322 | + await expect(await safe.isOwner(randomAddress1)).to.be.true; |
| 323 | + await expect(await safe.isOwner(randomAddress2)).to.be.true; |
| 324 | + }); |
284 | 325 | }); |
285 | 326 | }); |
0 commit comments