aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-05-25 04:03:17 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-06-08 06:36:18 +0800
commitbc0edd40427944349ac0c3e367c9638a1c7797dd (patch)
tree258c47aec8f342aef3438c71fcc524acfef46d60 /packages/contracts/test
parent9b82e2df58cfd7f4dc9954fa93167450919f457f (diff)
downloaddexon-sol-tools-bc0edd40427944349ac0c3e367c9638a1c7797dd.tar
dexon-sol-tools-bc0edd40427944349ac0c3e367c9638a1c7797dd.tar.gz
dexon-sol-tools-bc0edd40427944349ac0c3e367c9638a1c7797dd.tar.bz2
dexon-sol-tools-bc0edd40427944349ac0c3e367c9638a1c7797dd.tar.lz
dexon-sol-tools-bc0edd40427944349ac0c3e367c9638a1c7797dd.tar.xz
dexon-sol-tools-bc0edd40427944349ac0c3e367c9638a1c7797dd.tar.zst
dexon-sol-tools-bc0edd40427944349ac0c3e367c9638a1c7797dd.zip
LibAssetProxyDecoder tests
Diffstat (limited to 'packages/contracts/test')
-rw-r--r--packages/contracts/test/asset_proxy/decoder.ts56
1 files changed, 30 insertions, 26 deletions
diff --git a/packages/contracts/test/asset_proxy/decoder.ts b/packages/contracts/test/asset_proxy/decoder.ts
index 74e7547d3..b35cd0d43 100644
--- a/packages/contracts/test/asset_proxy/decoder.ts
+++ b/packages/contracts/test/asset_proxy/decoder.ts
@@ -9,23 +9,26 @@ import * as Web3 from 'web3';
import { TestLibAssetProxyDecoderContract } from '../../src/contract_wrappers/generated/test_lib_asset_proxy_decoder';
import { artifacts } from '../../src/utils/artifacts';
+import { assetProxyUtils } from '../../src/utils/asset_proxy_utils';
import { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants';
-import { AssetProxyId } from '../../src/utils/types';
+import { AssetProxyId, ERC20ProxyData, ERC721ProxyData, ProxyData } from '../../src/utils/types';
import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
-describe.only('AssetProxyDecoder', () => {
+describe.only('LibAssetProxyDecoder', () => {
let owner: string;
let testAssetProxyDecoder: TestLibAssetProxyDecoderContract;
+ let testAddress: string;
before(async () => {
// Setup accounts & addresses
const accounts = await web3Wrapper.getAvailableAddressesAsync();
owner = accounts[0];
+ testAddress = accounts[1];
// Deploy TestLibMem
testAssetProxyDecoder = await TestLibAssetProxyDecoderContract.deployFrom0xArtifactAsync(
artifacts.TestLibAssetProxyDecoder,
@@ -41,32 +44,33 @@ describe.only('AssetProxyDecoder', () => {
});
describe('LibAssetProxyDecoder', () => {
- /*it('should )', async () => {
- await testAssetProxyDecoder.test1.sendTransactionAsync();
+ it('should correctly decode ERC20 proxy data)', async () => {
+ const encodedProxyData = assetProxyUtils.encodeERC20ProxyData(testAddress);
+ const expectedDecodedProxyData = assetProxyUtils.decodeERC20ProxyData(encodedProxyData);
+ let decodedAssetProxyId: number;
+ let decodedTokenAddress: string;
+ [decodedAssetProxyId, decodedTokenAddress] = await testAssetProxyDecoder.publicDecodeERC20Data.callAsync(
+ encodedProxyData,
+ );
+ expect(decodedAssetProxyId).to.be.equal(expectedDecodedProxyData.assetProxyId);
+ expect(decodedTokenAddress).to.be.equal(expectedDecodedProxyData.tokenAddress);
});
- it('should )', async () => {
- await testLibMem.test2.sendTransactionAsync();
+ 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;
+ [
+ decodedAssetProxyId,
+ decodedTokenAddress,
+ decodedTokenId,
+ ] = 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);
});
-
- it('should )', async () => {
- await testLibMem.test3.sendTransactionAsync();
- });
-
- it('should )', async () => {
- await testLibMem.test4.sendTransactionAsync();
- });
-
- it('should )', async () => {
- await testLibMem.test5.sendTransactionAsync();
- });
-
- it('should )', async () => {
- await testLibMem.test6.sendTransactionAsync();
- });
-
- it('should )', async () => {
- return expect(testLibMem.test7.sendTransactionAsync()).to.be.rejectedWith(constants.REVERT);
- });*/
});
});