From 01eb3347dc4d68559d95100dbb6c240c0d431100 Mon Sep 17 00:00:00 2001 From: tr-Kalyan Date: Thu, 1 Jan 2026 22:19:47 +0530 Subject: [PATCH 1/3] test: add decodeBatch error case coverage for ERC7579Utils --- test/account/utils/draft-ERC7579Utils.test.js | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/test/account/utils/draft-ERC7579Utils.test.js b/test/account/utils/draft-ERC7579Utils.test.js index b0ca86c46fa..f1f225c73a7 100644 --- a/test/account/utils/draft-ERC7579Utils.test.js +++ b/test/account/utils/draft-ERC7579Utils.test.js @@ -397,3 +397,43 @@ describe('ERC7579Utils', function () { }); }); }); + +describe('decodeBatch error cases', function () { + it('reverts when executionCalldata is empty', async function () { + const emptyData = '0x'; + await expect(this.utils.$decodeBatch(emptyData)).to.be.revertedWithCustomError(this.utils, 'ERC7579DecodingError'); + }); + + it('reverts when executionCalldata is too short', async function () { + const shortData = '0x' + '00'.repeat(16); + await expect(this.utils.$decodeBatch(shortData)).to.be.revertedWithCustomError(this.utils, 'ERC7579DecodingError'); + }); + + it('reverts when array offset points outside buffer', async function () { + const malformedData = ethers.toBeHex(0x100, 32); + await expect(this.utils.$decodeBatch(malformedData)).to.be.revertedWithCustomError( + this.utils, + 'ERC7579DecodingError', + ); + }); + + it('reverts when array length exceeds uint64 max', async function () { + const offsetData = ethers.toBeHex(32, 32); + const tooLargeLength = ethers.toBeHex(ethers.toBigInt('0xFFFFFFFFFFFFFFFF') + 1n, 32); + const malformedData = offsetData + tooLargeLength.slice(2); + await expect(this.utils.$decodeBatch(malformedData)).to.be.revertedWithCustomError( + this.utils, + 'ERC7579DecodingError', + ); + }); + + it('reverts when buffer too small for array element pointers', async function () { + const offsetData = ethers.toBeHex(32, 32); + const arrayLength = ethers.toBeHex(10, 32); + const malformedData = offsetData + arrayLength.slice(2); + await expect(this.utils.$decodeBatch(malformedData)).to.be.revertedWithCustomError( + this.utils, + 'ERC7579DecodingError', + ); + }); +}); From a92865e28a3790fe5ec9759e0d2aeb5e30432220 Mon Sep 17 00:00:00 2001 From: tr-Kalyan Date: Thu, 1 Jan 2026 22:40:20 +0530 Subject: [PATCH 2/3] chore: add changeset for ERC7579Utils test coverage --- .changeset/fruity-buttons-shine.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fruity-buttons-shine.md diff --git a/.changeset/fruity-buttons-shine.md b/.changeset/fruity-buttons-shine.md new file mode 100644 index 00000000000..8f7ed25e217 --- /dev/null +++ b/.changeset/fruity-buttons-shine.md @@ -0,0 +1,5 @@ +--- +'openzeppelin-solidity': patch +--- + +test: add decodeBatch error case coverage for ERC7579Utils From f6c1d8d7fc12b58e48f1356a1a90d8a56b7688ab Mon Sep 17 00:00:00 2001 From: tr-Kalyan Date: Thu, 1 Jan 2026 23:58:25 +0530 Subject: [PATCH 3/3] test: add decodeBatch error case coverage --- test/account/utils/draft-ERC7579Utils.test.js | 90 ++++++++++--------- 1 file changed, 50 insertions(+), 40 deletions(-) diff --git a/test/account/utils/draft-ERC7579Utils.test.js b/test/account/utils/draft-ERC7579Utils.test.js index f1f225c73a7..ea501c7fefd 100644 --- a/test/account/utils/draft-ERC7579Utils.test.js +++ b/test/account/utils/draft-ERC7579Utils.test.js @@ -353,6 +353,56 @@ describe('ERC7579Utils', function () { ]); }); + describe('decodeBatch error cases', function () { + beforeEach(async function () { + Object.assign(this, await loadFixture(fixture)); + }); + + it('reverts when executionCalldata is empty', async function () { + const emptyData = '0x'; + await expect(this.utils.$decodeBatch(emptyData)).to.be.revertedWithCustomError( + this.utils, + 'ERC7579DecodingError', + ); + }); + + it('reverts when executionCalldata is too short', async function () { + const shortData = '0x' + '00'.repeat(16); + await expect(this.utils.$decodeBatch(shortData)).to.be.revertedWithCustomError( + this.utils, + 'ERC7579DecodingError', + ); + }); + + it('reverts when array offset points outside buffer', async function () { + const malformedData = ethers.toBeHex(0x100, 32); + await expect(this.utils.$decodeBatch(malformedData)).to.be.revertedWithCustomError( + this.utils, + 'ERC7579DecodingError', + ); + }); + + it('reverts when array length exceeds uint64 max', async function () { + const offsetData = ethers.toBeHex(32, 32); + const tooLargeLength = ethers.toBeHex(ethers.toBigInt('0xFFFFFFFFFFFFFFFF') + 1n, 32); + const malformedData = offsetData + tooLargeLength.slice(2); + await expect(this.utils.$decodeBatch(malformedData)).to.be.revertedWithCustomError( + this.utils, + 'ERC7579DecodingError', + ); + }); + + it('reverts when buffer too small for array element pointers', async function () { + const offsetData = ethers.toBeHex(32, 32); + const arrayLength = ethers.toBeHex(10, 32); + const malformedData = offsetData + arrayLength.slice(2); + await expect(this.utils.$decodeBatch(malformedData)).to.be.revertedWithCustomError( + this.utils, + 'ERC7579DecodingError', + ); + }); + }); + describe('global', function () { describe('eqCallTypeGlobal', function () { it('returns true if both call types are equal', async function () { @@ -397,43 +447,3 @@ describe('ERC7579Utils', function () { }); }); }); - -describe('decodeBatch error cases', function () { - it('reverts when executionCalldata is empty', async function () { - const emptyData = '0x'; - await expect(this.utils.$decodeBatch(emptyData)).to.be.revertedWithCustomError(this.utils, 'ERC7579DecodingError'); - }); - - it('reverts when executionCalldata is too short', async function () { - const shortData = '0x' + '00'.repeat(16); - await expect(this.utils.$decodeBatch(shortData)).to.be.revertedWithCustomError(this.utils, 'ERC7579DecodingError'); - }); - - it('reverts when array offset points outside buffer', async function () { - const malformedData = ethers.toBeHex(0x100, 32); - await expect(this.utils.$decodeBatch(malformedData)).to.be.revertedWithCustomError( - this.utils, - 'ERC7579DecodingError', - ); - }); - - it('reverts when array length exceeds uint64 max', async function () { - const offsetData = ethers.toBeHex(32, 32); - const tooLargeLength = ethers.toBeHex(ethers.toBigInt('0xFFFFFFFFFFFFFFFF') + 1n, 32); - const malformedData = offsetData + tooLargeLength.slice(2); - await expect(this.utils.$decodeBatch(malformedData)).to.be.revertedWithCustomError( - this.utils, - 'ERC7579DecodingError', - ); - }); - - it('reverts when buffer too small for array element pointers', async function () { - const offsetData = ethers.toBeHex(32, 32); - const arrayLength = ethers.toBeHex(10, 32); - const malformedData = offsetData + arrayLength.slice(2); - await expect(this.utils.$decodeBatch(malformedData)).to.be.revertedWithCustomError( - this.utils, - 'ERC7579DecodingError', - ); - }); -});