Update ERC1155Proxy tests
This commit is contained in:
parent
77484dc69e
commit
10d767c5ab
@ -1085,7 +1085,7 @@ describe('ERC1155Proxy', () => {
|
|||||||
badEncodedOffsetToTokenIds,
|
badEncodedOffsetToTokenIds,
|
||||||
);
|
);
|
||||||
// execute transfer
|
// execute transfer
|
||||||
await expectTransactionFailedAsync(
|
await expectTransactionFailedWithoutReasonAsync(
|
||||||
erc1155ProxyWrapper.transferFromAsync(
|
erc1155ProxyWrapper.transferFromAsync(
|
||||||
spender,
|
spender,
|
||||||
receiverContract,
|
receiverContract,
|
||||||
@ -1097,7 +1097,6 @@ describe('ERC1155Proxy', () => {
|
|||||||
authorized,
|
authorized,
|
||||||
assetDataWithBadTokenIdsOffset,
|
assetDataWithBadTokenIdsOffset,
|
||||||
),
|
),
|
||||||
RevertReason.InvalidIdsOffset,
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('should revert if an element of token ids lies to outside the bounds of calldata', async () => {
|
it('should revert if an element of token ids lies to outside the bounds of calldata', async () => {
|
||||||
@ -1137,7 +1136,7 @@ describe('ERC1155Proxy', () => {
|
|||||||
const encodedTokenIdValues = '0000000000000000000000000000000000000000000000000000000000000001';
|
const encodedTokenIdValues = '0000000000000000000000000000000000000000000000000000000000000001';
|
||||||
const assetDataWithBadTokenIds = `${assetDataWithNewTokenIdsOffset}${encodedTokenIdsLength}${encodedTokenIdValues}`;
|
const assetDataWithBadTokenIds = `${assetDataWithNewTokenIdsOffset}${encodedTokenIdsLength}${encodedTokenIdValues}`;
|
||||||
// execute transfer
|
// execute transfer
|
||||||
await expectTransactionFailedAsync(
|
await expectTransactionFailedWithoutReasonAsync(
|
||||||
erc1155ProxyWrapper.transferFromAsync(
|
erc1155ProxyWrapper.transferFromAsync(
|
||||||
spender,
|
spender,
|
||||||
receiverContract,
|
receiverContract,
|
||||||
@ -1149,7 +1148,6 @@ describe('ERC1155Proxy', () => {
|
|||||||
authorized,
|
authorized,
|
||||||
assetDataWithBadTokenIds,
|
assetDataWithBadTokenIds,
|
||||||
),
|
),
|
||||||
RevertReason.InvalidIdsOffset,
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('should revert token ids length overflows', async () => {
|
it('should revert token ids length overflows', async () => {
|
||||||
@ -1189,7 +1187,7 @@ describe('ERC1155Proxy', () => {
|
|||||||
const buffer = '0'.repeat(64 * 10);
|
const buffer = '0'.repeat(64 * 10);
|
||||||
const assetDataWithOverflow = `${assetDataWithBadTokenIdsOffset}${encodedIdsLengthOverflow}${buffer}`;
|
const assetDataWithOverflow = `${assetDataWithBadTokenIdsOffset}${encodedIdsLengthOverflow}${buffer}`;
|
||||||
// execute transfer
|
// execute transfer
|
||||||
await expectTransactionFailedAsync(
|
await expectTransactionFailedWithoutReasonAsync(
|
||||||
erc1155ProxyWrapper.transferFromAsync(
|
erc1155ProxyWrapper.transferFromAsync(
|
||||||
spender,
|
spender,
|
||||||
receiverContract,
|
receiverContract,
|
||||||
@ -1201,7 +1199,6 @@ describe('ERC1155Proxy', () => {
|
|||||||
authorized,
|
authorized,
|
||||||
assetDataWithOverflow,
|
assetDataWithOverflow,
|
||||||
),
|
),
|
||||||
RevertReason.Uint256Overflow,
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('should revert token values length overflows', async () => {
|
it('should revert token values length overflows', async () => {
|
||||||
@ -1241,7 +1238,7 @@ describe('ERC1155Proxy', () => {
|
|||||||
const buffer = '0'.repeat(64 * 10);
|
const buffer = '0'.repeat(64 * 10);
|
||||||
const assetDataWithOverflow = `${assetDataWithBadTokenIdsOffset}${encodedIdsLengthOverflow}${buffer}`;
|
const assetDataWithOverflow = `${assetDataWithBadTokenIdsOffset}${encodedIdsLengthOverflow}${buffer}`;
|
||||||
// execute transfer
|
// execute transfer
|
||||||
await expectTransactionFailedAsync(
|
await expectTransactionFailedWithoutReasonAsync(
|
||||||
erc1155ProxyWrapper.transferFromAsync(
|
erc1155ProxyWrapper.transferFromAsync(
|
||||||
spender,
|
spender,
|
||||||
receiverContract,
|
receiverContract,
|
||||||
@ -1253,7 +1250,6 @@ describe('ERC1155Proxy', () => {
|
|||||||
authorized,
|
authorized,
|
||||||
assetDataWithOverflow,
|
assetDataWithOverflow,
|
||||||
),
|
),
|
||||||
RevertReason.Uint256Overflow,
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('should revert token data length overflows', async () => {
|
it('should revert token data length overflows', async () => {
|
||||||
@ -1294,7 +1290,7 @@ describe('ERC1155Proxy', () => {
|
|||||||
const buffer = '0'.repeat(64 * 10);
|
const buffer = '0'.repeat(64 * 10);
|
||||||
const assetDataWithOverflow = `${assetDataWithBadTokenIdsOffset}${encodedIdsLengthOverflow}${buffer}`;
|
const assetDataWithOverflow = `${assetDataWithBadTokenIdsOffset}${encodedIdsLengthOverflow}${buffer}`;
|
||||||
// execute transfer
|
// execute transfer
|
||||||
await expectTransactionFailedAsync(
|
await expectTransactionFailedWithoutReasonAsync(
|
||||||
erc1155ProxyWrapper.transferFromAsync(
|
erc1155ProxyWrapper.transferFromAsync(
|
||||||
spender,
|
spender,
|
||||||
receiverContract,
|
receiverContract,
|
||||||
@ -1306,7 +1302,6 @@ describe('ERC1155Proxy', () => {
|
|||||||
authorized,
|
authorized,
|
||||||
assetDataWithOverflow,
|
assetDataWithOverflow,
|
||||||
),
|
),
|
||||||
RevertReason.InvalidDataOffset,
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('should revert if token values resolves to outside the bounds of calldata', async () => {
|
it('should revert if token values resolves to outside the bounds of calldata', async () => {
|
||||||
@ -1342,7 +1337,7 @@ describe('ERC1155Proxy', () => {
|
|||||||
badEncodedOffsetToTokenValues,
|
badEncodedOffsetToTokenValues,
|
||||||
);
|
);
|
||||||
// execute transfer
|
// execute transfer
|
||||||
await expectTransactionFailedAsync(
|
await expectTransactionFailedWithoutReasonAsync(
|
||||||
erc1155ProxyWrapper.transferFromAsync(
|
erc1155ProxyWrapper.transferFromAsync(
|
||||||
spender,
|
spender,
|
||||||
receiverContract,
|
receiverContract,
|
||||||
@ -1354,7 +1349,6 @@ describe('ERC1155Proxy', () => {
|
|||||||
authorized,
|
authorized,
|
||||||
assetDataWithBadTokenIdsOffset,
|
assetDataWithBadTokenIdsOffset,
|
||||||
),
|
),
|
||||||
RevertReason.InvalidValuesOffset,
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('should revert if an element of token values lies to outside the bounds of calldata', async () => {
|
it('should revert if an element of token values lies to outside the bounds of calldata', async () => {
|
||||||
@ -1394,7 +1388,7 @@ describe('ERC1155Proxy', () => {
|
|||||||
const encodedTokenValuesElements = '0000000000000000000000000000000000000000000000000000000000000001';
|
const encodedTokenValuesElements = '0000000000000000000000000000000000000000000000000000000000000001';
|
||||||
const assetDataWithBadTokenIds = `${assetDataWithNewTokenValuesOffset}${encodedTokenValuesLength}${encodedTokenValuesElements}`;
|
const assetDataWithBadTokenIds = `${assetDataWithNewTokenValuesOffset}${encodedTokenValuesLength}${encodedTokenValuesElements}`;
|
||||||
// execute transfer
|
// execute transfer
|
||||||
await expectTransactionFailedAsync(
|
await expectTransactionFailedWithoutReasonAsync(
|
||||||
erc1155ProxyWrapper.transferFromAsync(
|
erc1155ProxyWrapper.transferFromAsync(
|
||||||
spender,
|
spender,
|
||||||
receiverContract,
|
receiverContract,
|
||||||
@ -1406,7 +1400,6 @@ describe('ERC1155Proxy', () => {
|
|||||||
authorized,
|
authorized,
|
||||||
assetDataWithBadTokenIds,
|
assetDataWithBadTokenIds,
|
||||||
),
|
),
|
||||||
RevertReason.InvalidValuesOffset,
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('should revert if token data resolves to outside the bounds of calldata', async () => {
|
it('should revert if token data resolves to outside the bounds of calldata', async () => {
|
||||||
@ -1442,7 +1435,7 @@ describe('ERC1155Proxy', () => {
|
|||||||
badEncodedOffsetToTokenData,
|
badEncodedOffsetToTokenData,
|
||||||
);
|
);
|
||||||
// execute transfer
|
// execute transfer
|
||||||
await expectTransactionFailedAsync(
|
await expectTransactionFailedWithoutReasonAsync(
|
||||||
erc1155ProxyWrapper.transferFromAsync(
|
erc1155ProxyWrapper.transferFromAsync(
|
||||||
spender,
|
spender,
|
||||||
receiverContract,
|
receiverContract,
|
||||||
@ -1454,7 +1447,6 @@ describe('ERC1155Proxy', () => {
|
|||||||
authorized,
|
authorized,
|
||||||
assetDataWithBadTokenDataOffset,
|
assetDataWithBadTokenDataOffset,
|
||||||
),
|
),
|
||||||
RevertReason.InvalidDataOffset,
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('should revert if an element of token data lies to outside the bounds of calldata', async () => {
|
it('should revert if an element of token data lies to outside the bounds of calldata', async () => {
|
||||||
@ -1494,7 +1486,7 @@ describe('ERC1155Proxy', () => {
|
|||||||
const encodedTokenDataElements = '0000000000000000000000000000000000000000000000000000000000000001';
|
const encodedTokenDataElements = '0000000000000000000000000000000000000000000000000000000000000001';
|
||||||
const assetDataWithBadTokenData = `${assetDataWithNewTokenDataOffset}${encodedTokenDataLength}${encodedTokenDataElements}`;
|
const assetDataWithBadTokenData = `${assetDataWithNewTokenDataOffset}${encodedTokenDataLength}${encodedTokenDataElements}`;
|
||||||
// execute transfer
|
// execute transfer
|
||||||
await expectTransactionFailedAsync(
|
await expectTransactionFailedWithoutReasonAsync(
|
||||||
erc1155ProxyWrapper.transferFromAsync(
|
erc1155ProxyWrapper.transferFromAsync(
|
||||||
spender,
|
spender,
|
||||||
receiverContract,
|
receiverContract,
|
||||||
@ -1506,7 +1498,6 @@ describe('ERC1155Proxy', () => {
|
|||||||
authorized,
|
authorized,
|
||||||
assetDataWithBadTokenData,
|
assetDataWithBadTokenData,
|
||||||
),
|
),
|
||||||
RevertReason.InvalidDataOffset,
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('should revert if asset data lies outside the bounds of calldata', async () => {
|
it('should revert if asset data lies outside the bounds of calldata', async () => {
|
||||||
@ -1536,9 +1527,8 @@ describe('ERC1155Proxy', () => {
|
|||||||
const invalidOffsetToAssetData = '0000000000000000000000000000000000000000000000000000000000000180';
|
const invalidOffsetToAssetData = '0000000000000000000000000000000000000000000000000000000000000180';
|
||||||
const badTxData = txData.replace(offsetToAssetData, invalidOffsetToAssetData);
|
const badTxData = txData.replace(offsetToAssetData, invalidOffsetToAssetData);
|
||||||
// execute transfer
|
// execute transfer
|
||||||
await expectTransactionFailedAsync(
|
await expectTransactionFailedWithoutReasonAsync(
|
||||||
erc1155ProxyWrapper.transferFromRawAsync(badTxData, authorized),
|
erc1155ProxyWrapper.transferFromRawAsync(badTxData, authorized),
|
||||||
RevertReason.InvalidAssetDataLength,
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('should revert if asset data lies outside the bounds of calldata', async () => {
|
it('should revert if asset data lies outside the bounds of calldata', async () => {
|
||||||
@ -1570,39 +1560,8 @@ describe('ERC1155Proxy', () => {
|
|||||||
const newAssetData = '0000000000000000000000000000000000000000000000000000000000000304';
|
const newAssetData = '0000000000000000000000000000000000000000000000000000000000000304';
|
||||||
const badTxData = `${txData.replace(offsetToAssetData, invalidOffsetToAssetData)}${newAssetData}`;
|
const badTxData = `${txData.replace(offsetToAssetData, invalidOffsetToAssetData)}${newAssetData}`;
|
||||||
// execute transfer
|
// execute transfer
|
||||||
await expectTransactionFailedAsync(
|
await expectTransactionFailedWithoutReasonAsync(
|
||||||
erc1155ProxyWrapper.transferFromRawAsync(badTxData, authorized),
|
erc1155ProxyWrapper.transferFromRawAsync(badTxData, authorized),
|
||||||
RevertReason.InvalidAssetDataEnd,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it('should revert if length of assetData, excluding the selector, is not a multiple of 32', async () => {
|
|
||||||
// setup test parameters
|
|
||||||
const tokensToTransfer = fungibleTokens.slice(0, 1);
|
|
||||||
const valuesToTransfer = [fungibleValueToTransferLarge];
|
|
||||||
const valueMultiplier = valueMultiplierSmall;
|
|
||||||
const erc1155ContractAddress = erc1155Wrapper.getContract().address;
|
|
||||||
const assetData = assetDataUtils.encodeERC1155AssetData(
|
|
||||||
erc1155ContractAddress,
|
|
||||||
tokensToTransfer,
|
|
||||||
valuesToTransfer,
|
|
||||||
receiverCallbackData,
|
|
||||||
);
|
|
||||||
const extraData = '01';
|
|
||||||
const assetDataWithExtraData = `${assetData}${extraData}`;
|
|
||||||
// execute transfer
|
|
||||||
await expectTransactionFailedAsync(
|
|
||||||
erc1155ProxyWrapper.transferFromAsync(
|
|
||||||
spender,
|
|
||||||
receiverContract,
|
|
||||||
erc1155Contract.address,
|
|
||||||
tokensToTransfer,
|
|
||||||
valuesToTransfer,
|
|
||||||
valueMultiplier,
|
|
||||||
receiverCallbackData,
|
|
||||||
authorized,
|
|
||||||
assetDataWithExtraData,
|
|
||||||
),
|
|
||||||
RevertReason.InvalidAssetDataLength,
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('should revert if length of assetData is less than 132 bytes', async () => {
|
it('should revert if length of assetData is less than 132 bytes', async () => {
|
||||||
@ -1618,7 +1577,7 @@ describe('ERC1155Proxy', () => {
|
|||||||
const zeros96Bytes = '0'.repeat(188);
|
const zeros96Bytes = '0'.repeat(188);
|
||||||
const assetData131Bytes = `${AssetProxyId.ERC1155}${zeros96Bytes}`;
|
const assetData131Bytes = `${AssetProxyId.ERC1155}${zeros96Bytes}`;
|
||||||
// execute transfer
|
// execute transfer
|
||||||
await expectTransactionFailedAsync(
|
await expectTransactionFailedWithoutReasonAsync(
|
||||||
erc1155ProxyWrapper.transferFromAsync(
|
erc1155ProxyWrapper.transferFromAsync(
|
||||||
spender,
|
spender,
|
||||||
receiverContract,
|
receiverContract,
|
||||||
@ -1630,7 +1589,6 @@ describe('ERC1155Proxy', () => {
|
|||||||
authorized,
|
authorized,
|
||||||
assetData131Bytes,
|
assetData131Bytes,
|
||||||
),
|
),
|
||||||
RevertReason.InvalidAssetDataLength,
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('should transfer nothing if value is zero', async () => {
|
it('should transfer nothing if value is zero', async () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user