Fix tests
This commit is contained in:
@@ -668,7 +668,7 @@ describe('LibBytes', () => {
|
||||
describe('writeBytesWithLength', () => {
|
||||
it('should successfully write short, nested array of bytes when it takes up the whole array', async () => {
|
||||
const testBytesOffset = new BigNumber(0);
|
||||
const emptyByteArray = ethUtil.bufferToHex(ethUtil.toBuffer(shortTestBytesAsBuffer.byteLength));
|
||||
const emptyByteArray = ethUtil.bufferToHex(Buffer.alloc(shortTestBytesAsBuffer.byteLength));
|
||||
const bytesWritten = await libBytes.publicWriteBytesWithLength.callAsync(
|
||||
emptyByteArray,
|
||||
testBytesOffset,
|
||||
@@ -683,7 +683,7 @@ describe('LibBytes', () => {
|
||||
const prefixDataAsBuffer = ethUtil.toBuffer(prefixData);
|
||||
const prefixOffset = new BigNumber(0);
|
||||
const emptyByteArray = ethUtil.bufferToHex(
|
||||
ethUtil.toBuffer(prefixDataAsBuffer.byteLength + shortTestBytesAsBuffer.byteLength),
|
||||
Buffer.alloc(prefixDataAsBuffer.byteLength + shortTestBytesAsBuffer.byteLength),
|
||||
);
|
||||
let bytesWritten = await libBytes.publicWriteBytesWithLength.callAsync(
|
||||
emptyByteArray,
|
||||
@@ -703,7 +703,7 @@ describe('LibBytes', () => {
|
||||
});
|
||||
it('should successfully write a nested array of bytes - one word in length - when it takes up the whole array', async () => {
|
||||
const testBytesOffset = new BigNumber(0);
|
||||
const emptyByteArray = ethUtil.bufferToHex(ethUtil.toBuffer(wordOfTestBytesAsBuffer.byteLength));
|
||||
const emptyByteArray = ethUtil.bufferToHex(Buffer.alloc(wordOfTestBytesAsBuffer.byteLength));
|
||||
const bytesWritten = await libBytes.publicWriteBytesWithLength.callAsync(
|
||||
emptyByteArray,
|
||||
testBytesOffset,
|
||||
@@ -718,7 +718,7 @@ describe('LibBytes', () => {
|
||||
const prefixDataAsBuffer = ethUtil.toBuffer(prefixData);
|
||||
const prefixOffset = new BigNumber(0);
|
||||
const emptyByteArray = ethUtil.bufferToHex(
|
||||
ethUtil.toBuffer(prefixDataAsBuffer.byteLength + wordOfTestBytesAsBuffer.byteLength),
|
||||
Buffer.alloc(prefixDataAsBuffer.byteLength + wordOfTestBytesAsBuffer.byteLength),
|
||||
);
|
||||
let bytesWritten = await libBytes.publicWriteBytesWithLength.callAsync(
|
||||
emptyByteArray,
|
||||
@@ -738,7 +738,7 @@ describe('LibBytes', () => {
|
||||
});
|
||||
it('should successfully write a long, nested bytes when it takes up the whole array', async () => {
|
||||
const testBytesOffset = new BigNumber(0);
|
||||
const emptyByteArray = ethUtil.bufferToHex(ethUtil.toBuffer(longTestBytesAsBuffer.byteLength));
|
||||
const emptyByteArray = ethUtil.bufferToHex(Buffer.alloc(longTestBytesAsBuffer.byteLength));
|
||||
const bytesWritten = await libBytes.publicWriteBytesWithLength.callAsync(
|
||||
emptyByteArray,
|
||||
testBytesOffset,
|
||||
@@ -753,7 +753,7 @@ describe('LibBytes', () => {
|
||||
const prefixDataAsBuffer = ethUtil.toBuffer(prefixData);
|
||||
const prefixOffset = new BigNumber(0);
|
||||
const emptyByteArray = ethUtil.bufferToHex(
|
||||
ethUtil.toBuffer(prefixDataAsBuffer.byteLength + longTestBytesAsBuffer.byteLength),
|
||||
Buffer.alloc(prefixDataAsBuffer.byteLength + longTestBytesAsBuffer.byteLength),
|
||||
);
|
||||
let bytesWritten = await libBytes.publicWriteBytesWithLength.callAsync(
|
||||
emptyByteArray,
|
||||
@@ -769,7 +769,7 @@ describe('LibBytes', () => {
|
||||
});
|
||||
it('should fail if the byte array is too short to hold the length of a nested byte array', async () => {
|
||||
const offset = new BigNumber(0);
|
||||
const emptyByteArray = ethUtil.bufferToHex(ethUtil.toBuffer(1));
|
||||
const emptyByteArray = ethUtil.bufferToHex(Buffer.alloc(1));
|
||||
const inputLen = new BigNumber((longData.length - 2) / 2);
|
||||
const expectedError = new LibBytesRevertErrors.InvalidByteOperationError(
|
||||
LibBytesRevertErrors.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsNestedBytesLengthRequired,
|
||||
@@ -781,7 +781,7 @@ describe('LibBytes', () => {
|
||||
).to.revertWith(expectedError);
|
||||
});
|
||||
it('should fail if the length between the offset and end of the byte array is too short to hold the length of a nested byte array', async () => {
|
||||
const emptyByteArray = ethUtil.bufferToHex(ethUtil.toBuffer(shortTestBytesAsBuffer.byteLength));
|
||||
const emptyByteArray = ethUtil.bufferToHex(Buffer.alloc(shortTestBytesAsBuffer.byteLength));
|
||||
const badOffset = new BigNumber(ethUtil.toBuffer(shortTestBytesAsBuffer).byteLength);
|
||||
const inputLen = new BigNumber((shortData.length - 2) / 2);
|
||||
const expectedError = new LibBytesRevertErrors.InvalidByteOperationError(
|
||||
|
Reference in New Issue
Block a user