Skip to content

Commit fe87e49

Browse files
authored
Update Base64.test.js
1 parent 6f49993 commit fe87e49

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

test/utils/Base64.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,21 @@ describe('Base64', function () {
5151
});
5252

5353
it('Decode invalid base64 string', async function () {
54+
const getHexCode = str => ethers.hexlify(ethers.toUtf8Bytes(str));
5455
const helper = { interface: ethers.Interface.from(['error InvalidBase64Digit(bytes1)']) };
5556

5657
// ord('$') < 43
5758
await expect(this.mock.$decode('dGVzd$=='))
5859
.to.be.revertedWithCustomError(helper, 'InvalidBase64Digit')
59-
.withArgs(`0x${'$'.charCodeAt(0).toString(16)}`);
60+
.withArgs(getHexCode('$'));
6061
// ord('~') > 122
6162
await expect(this.mock.$decode('dGVzd~=='))
6263
.to.be.revertedWithCustomError(helper, 'InvalidBase64Digit')
63-
.withArgs(`0x${'~'.charCodeAt(0).toString(16)}`);
64+
.withArgs(getHexCode('~'));
6465
// ord('@') in range, but '@' not in the dictionary
6566
await expect(this.mock.$decode('dGVzd@=='))
6667
.to.be.revertedWithCustomError(helper, 'InvalidBase64Digit')
67-
.withArgs(`0x${'@'.charCodeAt(0).toString(16)}`);
68+
.withArgs(getHexCode('@'));
6869
});
6970

7071
it('Encode reads beyond the input buffer into dirty memory', async function () {

0 commit comments

Comments
 (0)