Add trailing garbage testcase for LibBytes.equals

This commit is contained in:
Remco Bloemen 2018-06-13 18:12:45 +02:00
parent 425af46f98
commit 384cd2f605
2 changed files with 21 additions and 0 deletions

View File

@ -62,6 +62,17 @@ contract TestLibBytes {
return equal;
}
function publicEqualsPop1(bytes memory lhs, bytes memory rhs)
public
pure
returns (bool equal)
{
lhs.popByte();
rhs.popByte();
equal = lhs.equals(rhs);
return equal;
}
/// @dev Performs a deep copy of a byte array onto another byte array of greater than or equal length.
/// @param dest Byte array that will be overwritten with source bytes.
/// @param source Byte array to copy onto dest bytes.

View File

@ -172,6 +172,16 @@ describe('LibBytes', () => {
);
return expect(equals).to.be.false();
});
describe('should ignore trailing data', () => {
it('should return true when both < 32 bytes', async () => {
const equals = await libBytes.publicEqualsPop1.callAsync(
'0x0102',
'0x0103',
);
return expect(equals).to.be.true();
});
});
});
describe('deepCopyBytes', () => {