diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-05-25 15:31:03 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2018-06-08 06:38:42 +0800 |
commit | 842363200b3b8aded3b03fc8e46a329ff9534e36 (patch) | |
tree | 8f535e5a16c298594b4d3f0959ec4b73f707cf48 /packages/contracts/test/asset_proxy/decoder.ts | |
parent | d9f9895b2bcd3cde09febbe0e1af31be5ddc80e2 (diff) | |
download | dexon-0x-contracts-842363200b3b8aded3b03fc8e46a329ff9534e36.tar dexon-0x-contracts-842363200b3b8aded3b03fc8e46a329ff9534e36.tar.gz dexon-0x-contracts-842363200b3b8aded3b03fc8e46a329ff9534e36.tar.bz2 dexon-0x-contracts-842363200b3b8aded3b03fc8e46a329ff9534e36.tar.lz dexon-0x-contracts-842363200b3b8aded3b03fc8e46a329ff9534e36.tar.xz dexon-0x-contracts-842363200b3b8aded3b03fc8e46a329ff9534e36.tar.zst dexon-0x-contracts-842363200b3b8aded3b03fc8e46a329ff9534e36.zip |
Tons of tests around nested byte arrays and ERC721 receiver
Diffstat (limited to 'packages/contracts/test/asset_proxy/decoder.ts')
-rw-r--r-- | packages/contracts/test/asset_proxy/decoder.ts | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/packages/contracts/test/asset_proxy/decoder.ts b/packages/contracts/test/asset_proxy/decoder.ts index 4416334d1..0f1413ff1 100644 --- a/packages/contracts/test/asset_proxy/decoder.ts +++ b/packages/contracts/test/asset_proxy/decoder.ts @@ -56,21 +56,45 @@ describe('LibAssetProxyDecoder', () => { expect(decodedTokenAddress).to.be.equal(expectedDecodedProxyData.tokenAddress); }); - it('should correctly decode ERC721 proxy data)', async () => { + it('should correctly decode ERC721 proxy data', async () => { const tokenId = ZeroEx.generatePseudoRandomSalt(); const encodedProxyData = assetProxyUtils.encodeERC721ProxyData(testAddress, tokenId); const expectedDecodedProxyData = assetProxyUtils.decodeERC721ProxyData(encodedProxyData); let decodedAssetProxyId: number; let decodedTokenAddress: string; let decodedTokenId: BigNumber; + let decodedData: string; [ decodedAssetProxyId, decodedTokenAddress, decodedTokenId, + decodedData, ] = await testAssetProxyDecoder.publicDecodeERC721Data.callAsync(encodedProxyData); expect(decodedAssetProxyId).to.be.equal(expectedDecodedProxyData.assetProxyId); expect(decodedTokenAddress).to.be.equal(expectedDecodedProxyData.tokenAddress); expect(decodedTokenId).to.be.bignumber.equal(expectedDecodedProxyData.tokenId); + expect(decodedData).to.be.equal(expectedDecodedProxyData.data); + }); + + it('should correctly decode ERC721 proxy data with receiver data', async () => { + const tokenId = ZeroEx.generatePseudoRandomSalt(); + const data = ethUtil.bufferToHex(assetProxyUtils.encodeUint256(ZeroEx.generatePseudoRandomSalt())) + 'FFFF'; + const encodedProxyData = assetProxyUtils.encodeERC721ProxyData(testAddress, tokenId, data); + const expectedDecodedProxyData = assetProxyUtils.decodeERC721ProxyData(encodedProxyData); + let decodedAssetProxyId: number; + let decodedTokenAddress: string; + let decodedTokenId: BigNumber; + let decodedData: string; + [ + decodedAssetProxyId, + decodedTokenAddress, + decodedTokenId, + decodedData, + ] = await testAssetProxyDecoder.publicDecodeERC721Data.callAsync(encodedProxyData); + expect(decodedAssetProxyId).to.be.equal(expectedDecodedProxyData.assetProxyId); + expect(decodedTokenAddress).to.be.equal(expectedDecodedProxyData.tokenAddress); + expect(decodedTokenId).to.be.bignumber.equal(expectedDecodedProxyData.tokenId); + expect(decodedData).to.be.equal(expectedDecodedProxyData.data); }); }); }); |