Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1673 from 0xProject/feature/contracts/erc1155Prox…
Browse files Browse the repository at this point in the history
…yIntegrationTests-2

 Exchange & Proxy Integration Tests - ERC1155
  • Loading branch information
hysz committed Mar 19, 2019
2 parents 3fff3d9 + 98c6fa1 commit e8be5a0
Show file tree
Hide file tree
Showing 10 changed files with 952 additions and 32 deletions.
4 changes: 4 additions & 0 deletions contracts/asset-proxy/CHANGELOG.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
{
"note": "Bumped solidity version to ^0.5.5",
"pr": 1701
},
{
"note": "Integration testing for ERC1155Proxy",
"pr": 1673
}
]
},
Expand Down
44 changes: 44 additions & 0 deletions contracts/asset-proxy/test/erc1155_proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,50 @@ describe('ERC1155Proxy', () => {
];
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances);
});
it('should successfully transfer value to a smart contract and trigger its callback, when callback `data` is NULL', async () => {
// setup test parameters
const tokenHolders = [spender, receiverContract];
const tokensToTransfer = fungibleTokens.slice(0, 1);
const valuesToTransfer = [fungibleValueToTransferLarge];
const valueMultiplier = valueMultiplierSmall;
const totalValuesTransferred = _.map(valuesToTransfer, (value: BigNumber) => {
return value.times(valueMultiplier);
});
// check balances before transfer
const expectedInitialBalances = [spenderInitialFungibleBalance, receiverContractInitialFungibleBalance];
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances);
// execute transfer
const nullReceiverCallbackData = '0x';
const txReceipt = await erc1155ProxyWrapper.transferFromWithLogsAsync(
spender,
receiverContract,
erc1155Contract.address,
tokensToTransfer,
valuesToTransfer,
valueMultiplier,
nullReceiverCallbackData,
authorized,
);
// check receiver log ignored extra asset data
expect(txReceipt.logs.length).to.be.equal(2);
const receiverLog = txReceipt.logs[1] as LogWithDecodedArgs<
DummyERC1155ReceiverBatchTokenReceivedEventArgs
>;
expect(receiverLog.args.operator).to.be.equal(erc1155Proxy.address);
expect(receiverLog.args.from).to.be.equal(spender);
expect(receiverLog.args.tokenIds.length).to.be.deep.equal(1);
expect(receiverLog.args.tokenIds[0]).to.be.bignumber.equal(tokensToTransfer[0]);
expect(receiverLog.args.tokenValues.length).to.be.deep.equal(1);
expect(receiverLog.args.tokenValues[0]).to.be.bignumber.equal(totalValuesTransferred[0]);
// note - if the `extraData` is ignored then the receiver log should ignore it as well.
expect(receiverLog.args.data).to.be.deep.equal(nullReceiverCallbackData);
// check balances after transfer
const expectedFinalBalances = [
expectedInitialBalances[0].minus(totalValuesTransferred[0]),
expectedInitialBalances[1].plus(totalValuesTransferred[0]),
];
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances);
});
it('should successfully transfer value and ignore extra assetData', async () => {
// setup test parameters
const tokenHolders = [spender, receiverContract];
Expand Down
357 changes: 357 additions & 0 deletions contracts/asset-proxy/test/proxies.ts

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions contracts/exchange/CHANGELOG.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
{
"note": "Upgrade contracts to Solidity 0.5.5",
"pr": 1682
},
{
"note": "Integration testing for ERC1155Proxy",
"pr": 1673
}
]
},
Expand Down
1 change: 1 addition & 0 deletions contracts/exchange/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"@0x/contracts-asset-proxy": "^1.0.9",
"@0x/contracts-erc20": "^1.0.9",
"@0x/contracts-erc721": "^1.0.9",
"@0x/contracts-erc1155": "^1.0.0",
"@0x/contracts-exchange-libs": "^1.1.3",
"@0x/contracts-utils": "^2.0.8",
"@0x/order-utils": "^7.0.2",
Expand Down
Loading

0 comments on commit e8be5a0

Please sign in to comment.