Add byteLengthWithFallback to ShortStrings (#4089)

Co-authored-by: Francisco <fg@frang.io>
This commit is contained in:
Hadrien Croubois
2023-03-06 21:44:58 +01:00
committed by GitHub
parent 7f028d6959
commit de520fe25a
2 changed files with 20 additions and 3 deletions

View File

@ -23,7 +23,7 @@ contract('ShortStrings', function () {
const encoded = await this.mock.$toShortString(str);
expect(decode(encoded)).to.be.equal(str);
const length = await this.mock.$length(encoded);
const length = await this.mock.$byteLength(encoded);
expect(length.toNumber()).to.be.equal(str.length);
const decoded = await this.mock.$toString(encoded);
@ -44,6 +44,9 @@ contract('ShortStrings', function () {
await expectRevertCustomError(promise, 'InvalidShortString()');
}
const length = await this.mock.$byteLengthWithFallback(ret0, 0);
expect(length.toNumber()).to.be.equal(str.length);
const recovered = await this.mock.$toStringWithFallback(ret0, 0);
expect(recovered).to.be.equal(str);
});