aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-04-13 09:26:59 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-04-21 04:56:17 +0800
commit10707ebc3a8f04919db6d2210c267636036c10b7 (patch)
treec04426d093a5c5571df5197ac6f26f027ac3437b
parent8374a51e6aed171c64600205b1219c6f38550a06 (diff)
downloaddexon-sol-tools-10707ebc3a8f04919db6d2210c267636036c10b7.tar
dexon-sol-tools-10707ebc3a8f04919db6d2210c267636036c10b7.tar.gz
dexon-sol-tools-10707ebc3a8f04919db6d2210c267636036c10b7.tar.bz2
dexon-sol-tools-10707ebc3a8f04919db6d2210c267636036c10b7.tar.lz
dexon-sol-tools-10707ebc3a8f04919db6d2210c267636036c10b7.tar.xz
dexon-sol-tools-10707ebc3a8f04919db6d2210c267636036c10b7.tar.zst
dexon-sol-tools-10707ebc3a8f04919db6d2210c267636036c10b7.zip
Style improvements to the Asset Proxy tests
-rw-r--r--packages/contracts/test/asset_proxy_dispatcher/proxies.ts86
-rw-r--r--packages/contracts/test/exchange/core.ts188
2 files changed, 140 insertions, 134 deletions
diff --git a/packages/contracts/test/asset_proxy_dispatcher/proxies.ts b/packages/contracts/test/asset_proxy_dispatcher/proxies.ts
index 2b21b8cc9..e50059cb2 100644
--- a/packages/contracts/test/asset_proxy_dispatcher/proxies.ts
+++ b/packages/contracts/test/asset_proxy_dispatcher/proxies.ts
@@ -32,13 +32,14 @@ describe('Asset Transfer Proxies', () => {
let makerAddress: string;
let takerAddress: string;
let zrx: DummyTokenContract;
- let ck: DummyERC721TokenContract;
+ let erc721Token: DummyERC721TokenContract;
let dmyBalances: Balances;
let tokenTransferProxy: TokenTransferProxyContract;
let erc20TransferProxyV1: ERC20Proxy_v1Contract;
let erc20TransferProxy: ERC20ProxyContract;
let erc721TransferProxy: ERC721ProxyContract;
const makerTokenId = new BigNumber('0x1010101010101010101010101010101010101010101010101010101010101010');
+ const testAddressPaddedWithZeros = '0x0000000000000000056000000000000000000010';
const INITIAL_BALANCE = new BigNumber(10000);
before(async () => {
@@ -109,12 +110,19 @@ describe('Asset Transfer Proxies', () => {
await zrx.approve.sendTransactionAsync(erc20TransferProxy.address, INITIAL_BALANCE, {
from: makerAddress,
});
- // Deploy ck and set initial balances
- const ckInstance = await deployer.deployAsync(ContractName.DummyERC721Token, constants.DUMMY_ERC721TOKEN_ARGS);
- ck = new DummyERC721TokenContract(ckInstance.abi, ckInstance.address, provider);
- await ck.setApprovalForAll.sendTransactionAsync(erc721TransferProxy.address, true, { from: makerAddress });
- await ck.setApprovalForAll.sendTransactionAsync(erc721TransferProxy.address, true, { from: takerAddress });
- await ck.mint.sendTransactionAsync(makerAddress, makerTokenId, { from: tokenOwner });
+ // Deploy erc721Token and set initial balances
+ const erc721TokenInstance = await deployer.deployAsync(
+ ContractName.DummyERC721Token,
+ constants.DUMMY_ERC721TOKEN_ARGS,
+ );
+ erc721Token = new DummyERC721TokenContract(erc721TokenInstance.abi, erc721TokenInstance.address, provider);
+ await erc721Token.setApprovalForAll.sendTransactionAsync(erc721TransferProxy.address, true, {
+ from: makerAddress,
+ });
+ await erc721Token.setApprovalForAll.sendTransactionAsync(erc721TransferProxy.address, true, {
+ from: takerAddress,
+ });
+ await erc721Token.mint.sendTransactionAsync(makerAddress, makerTokenId, { from: tokenOwner });
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
@@ -136,17 +144,18 @@ describe('Asset Transfer Proxies', () => {
});
it('should successfully encode/decode metadata padded with zeros', async () => {
- const testAddress = '0x0000000000000000056000000000000000000010';
- const metadata = await erc20TransferProxyV1.encodeMetadata.callAsync(AssetProxyId.ERC20V1, testAddress);
+ const metadata = await erc20TransferProxyV1.encodeMetadata.callAsync(
+ AssetProxyId.ERC20V1,
+ testAddressPaddedWithZeros,
+ );
const address = await erc20TransferProxyV1.decodeMetadata.callAsync(metadata);
- expect(address).to.be.equal(testAddress);
+ expect(address).to.be.equal(testAddressPaddedWithZeros);
});
it('should successfully decode metadata encoded padded with zeros by typescript helpers', async () => {
- const testAddress = '0x0000000000000000056000000000000000000010';
- const metadata = encodeERC20V1ProxyData(testAddress);
+ const metadata = encodeERC20V1ProxyData(testAddressPaddedWithZeros);
const address = await erc20TransferProxyV1.decodeMetadata.callAsync(metadata);
- expect(address).to.be.equal(testAddress);
+ expect(address).to.be.equal(testAddressPaddedWithZeros);
});
it('should successfully transfer tokens', async () => {
@@ -204,17 +213,18 @@ describe('Asset Transfer Proxies', () => {
});
it('should successfully encode/decode metadata padded with zeros', async () => {
- const testAddress = '0x0000000000000000056000000000000000000010';
- const metadata = await erc20TransferProxy.encodeMetadata.callAsync(AssetProxyId.ERC20, testAddress);
+ const metadata = await erc20TransferProxy.encodeMetadata.callAsync(
+ AssetProxyId.ERC20,
+ testAddressPaddedWithZeros,
+ );
const address = await erc20TransferProxy.decodeMetadata.callAsync(metadata);
- expect(address).to.be.equal(testAddress);
+ expect(address).to.be.equal(testAddressPaddedWithZeros);
});
it('should successfully decode metadata encoded padded with zeros by typescript helpers', async () => {
- const testAddress = '0x0000000000000000056000000000000000000010';
- const metadata = encodeERC20ProxyData(testAddress);
+ const metadata = encodeERC20ProxyData(testAddressPaddedWithZeros);
const address = await erc20TransferProxy.decodeMetadata.callAsync(metadata);
- expect(address).to.be.equal(testAddress);
+ expect(address).to.be.equal(testAddressPaddedWithZeros);
});
it('should successfully transfer tokens', async () => {
@@ -262,46 +272,44 @@ describe('Asset Transfer Proxies', () => {
it('should successfully encode/decode metadata', async () => {
const metadata = await erc721TransferProxy.encodeMetadata.callAsync(
AssetProxyId.ERC721,
- ck.address,
+ erc721Token.address,
makerTokenId,
);
const [address, tokenId] = await erc721TransferProxy.decodeMetadata.callAsync(metadata);
- expect(address).to.be.equal(ck.address);
+ expect(address).to.be.equal(erc721Token.address);
expect(tokenId).to.be.bignumber.equal(makerTokenId);
});
it('should successfully decode metadata encoded by typescript helpers', async () => {
- const metadata = encodeERC721ProxyData(ck.address, makerTokenId);
+ const metadata = encodeERC721ProxyData(erc721Token.address, makerTokenId);
const [address, tokenId] = await erc721TransferProxy.decodeMetadata.callAsync(metadata);
- expect(address).to.be.equal(ck.address);
+ expect(address).to.be.equal(erc721Token.address);
expect(tokenId).to.be.bignumber.equal(makerTokenId);
});
it('should successfully encode/decode metadata padded with zeros', async () => {
- const testAddress = '0x0000000000000000056000000000000000000010';
const metadata = await erc721TransferProxy.encodeMetadata.callAsync(
AssetProxyId.ERC721,
- testAddress,
+ testAddressPaddedWithZeros,
makerTokenId,
);
const [address, tokenId] = await erc721TransferProxy.decodeMetadata.callAsync(metadata);
- expect(address).to.be.equal(testAddress);
+ expect(address).to.be.equal(testAddressPaddedWithZeros);
expect(tokenId).to.be.bignumber.equal(makerTokenId);
});
it('should successfully decode metadata encoded padded with zeros by typescript helpers', async () => {
- const testAddress = '0x0000000000000000056000000000000000000010';
- const metadata = encodeERC721ProxyData(testAddress, makerTokenId);
+ const metadata = encodeERC721ProxyData(testAddressPaddedWithZeros, makerTokenId);
const [address, tokenId] = await erc721TransferProxy.decodeMetadata.callAsync(metadata);
- expect(address).to.be.equal(testAddress);
+ expect(address).to.be.equal(testAddressPaddedWithZeros);
expect(tokenId).to.be.bignumber.equal(makerTokenId);
});
it('should successfully transfer tokens', async () => {
// Construct metadata for ERC20 proxy
- const encodedProxyMetadata = encodeERC721ProxyData(ck.address, makerTokenId);
+ const encodedProxyMetadata = encodeERC721ProxyData(erc721Token.address, makerTokenId);
// Verify pre-condition
- const ownerMakerToken = await ck.ownerOf.callAsync(makerTokenId);
+ const ownerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
expect(ownerMakerToken).to.be.bignumber.equal(makerAddress);
// Perform a transfer from makerAddress to takerAddress
const balances = await dmyBalances.getAsync();
@@ -314,15 +322,15 @@ describe('Asset Transfer Proxies', () => {
{ from: assetProxyDispatcherAddress },
);
// Verify transfer was successful
- const newOwnerMakerToken = await ck.ownerOf.callAsync(makerTokenId);
+ const newOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
expect(newOwnerMakerToken).to.be.bignumber.equal(takerAddress);
});
it('should throw if transferring 0 amount of a token', async () => {
// Construct metadata for ERC20 proxy
- const encodedProxyMetadata = encodeERC721ProxyData(ck.address, makerTokenId);
+ const encodedProxyMetadata = encodeERC721ProxyData(erc721Token.address, makerTokenId);
// Verify pre-condition
- const ownerMakerToken = await ck.ownerOf.callAsync(makerTokenId);
+ const ownerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
expect(ownerMakerToken).to.be.bignumber.equal(makerAddress);
// Perform a transfer from makerAddress to takerAddress
const balances = await dmyBalances.getAsync();
@@ -333,16 +341,16 @@ describe('Asset Transfer Proxies', () => {
makerAddress,
takerAddress,
amount,
- { from: notOwner },
+ { from: assetProxyDispatcherAddress },
),
).to.be.rejectedWith(constants.REVERT);
});
- it('should throw if transferring >1 amount of a token', async () => {
+ it('should throw if transferring > 1 amount of a token', async () => {
// Construct metadata for ERC20 proxy
- const encodedProxyMetadata = encodeERC721ProxyData(ck.address, makerTokenId);
+ const encodedProxyMetadata = encodeERC721ProxyData(erc721Token.address, makerTokenId);
// Verify pre-condition
- const ownerMakerToken = await ck.ownerOf.callAsync(makerTokenId);
+ const ownerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
expect(ownerMakerToken).to.be.bignumber.equal(makerAddress);
// Perform a transfer from makerAddress to takerAddress
const balances = await dmyBalances.getAsync();
@@ -353,7 +361,7 @@ describe('Asset Transfer Proxies', () => {
makerAddress,
takerAddress,
amount,
- { from: notOwner },
+ { from: assetProxyDispatcherAddress },
),
).to.be.rejectedWith(constants.REVERT);
});
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index 9f8fc5189..00d6ea37f 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -54,7 +54,7 @@ describe('Exchange', () => {
let rep: DummyTokenContract;
let dgd: DummyTokenContract;
let zrx: DummyTokenContract;
- let ck: DummyERC721TokenContract;
+ let erc721Token: DummyERC721TokenContract;
let exchange: ExchangeContract;
let tokenTransferProxy: TokenTransferProxyContract;
let assetProxyDispatcher: AssetProxyDispatcherContract;
@@ -68,6 +68,16 @@ describe('Exchange', () => {
let dmyBalances: Balances;
let orderFactory: OrderFactory;
+ const erc721MakerTokenIds = [
+ new BigNumber('0x1010101010101010101010101010101010101010101010101010101010101010'),
+ new BigNumber('0x2020202020202020202020202020202020202020202020202020202020202020'),
+ ];
+
+ const erc721TakerTokenIds = [
+ new BigNumber('0x3030303030303030303030303030303030303030303030303030303030303030'),
+ new BigNumber('0x4040404040404040404040404040404040404040404040404040404040404040'),
+ ];
+
let zeroEx: ZeroEx;
before(async () => {
@@ -75,7 +85,7 @@ describe('Exchange', () => {
makerAddress = accounts[0];
[tokenOwner, takerAddress, feeRecipientAddress] = accounts;
const owner = tokenOwner;
- const [repInstance, dgdInstance, zrxInstance, ckInstance] = await Promise.all([
+ const [repInstance, dgdInstance, zrxInstance, erc721TokenInstance] = await Promise.all([
deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS),
deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS),
deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS),
@@ -85,7 +95,7 @@ describe('Exchange', () => {
rep = new DummyTokenContract(repInstance.abi, repInstance.address, provider);
dgd = new DummyTokenContract(dgdInstance.abi, dgdInstance.address, provider);
zrx = new DummyTokenContract(zrxInstance.abi, zrxInstance.address, provider);
- ck = new DummyERC721TokenContract(ckInstance.abi, ckInstance.address, provider);
+ erc721Token = new DummyERC721TokenContract(erc721TokenInstance.abi, erc721TokenInstance.address, provider);
// Deploy Asset Proxy Dispatcher
const assetProxyDispatcherInstance = await deployer.deployAsync(ContractName.AssetProxyDispatcher);
assetProxyDispatcher = new AssetProxyDispatcherContract(
@@ -226,28 +236,16 @@ describe('Exchange', () => {
}),
zrx.setBalance.sendTransactionAsync(makerAddress, INITIAL_BALANCE, { from: tokenOwner }),
zrx.setBalance.sendTransactionAsync(takerAddress, INITIAL_BALANCE, { from: tokenOwner }),
- ck.setApprovalForAll.sendTransactionAsync(erc721TransferProxy.address, true, { from: makerAddress }),
- ck.setApprovalForAll.sendTransactionAsync(erc721TransferProxy.address, true, { from: takerAddress }),
- ck.mint.sendTransactionAsync(
- makerAddress,
- new BigNumber('0x1010101010101010101010101010101010101010101010101010101010101010'),
- { from: tokenOwner },
- ),
- ck.mint.sendTransactionAsync(
- makerAddress,
- new BigNumber('0x2020202020202020202020202020202020202020202020202020202020202020'),
- { from: tokenOwner },
- ),
- ck.mint.sendTransactionAsync(
- takerAddress,
- new BigNumber('0x3030303030303030303030303030303030303030303030303030303030303030'),
- { from: tokenOwner },
- ),
- ck.mint.sendTransactionAsync(
- takerAddress,
- new BigNumber('0x4040404040404040404040404040404040404040404040404040404040404040'),
- { from: tokenOwner },
- ),
+ erc721Token.setApprovalForAll.sendTransactionAsync(erc721TransferProxy.address, true, {
+ from: makerAddress,
+ }),
+ erc721Token.setApprovalForAll.sendTransactionAsync(erc721TransferProxy.address, true, {
+ from: takerAddress,
+ }),
+ erc721Token.mint.sendTransactionAsync(makerAddress, erc721MakerTokenIds[0], { from: tokenOwner }),
+ erc721Token.mint.sendTransactionAsync(makerAddress, erc721MakerTokenIds[1], { from: tokenOwner }),
+ erc721Token.mint.sendTransactionAsync(takerAddress, erc721TakerTokenIds[0], { from: tokenOwner }),
+ erc721Token.mint.sendTransactionAsync(takerAddress, erc721TakerTokenIds[1], { from: tokenOwner }),
]);
});
beforeEach(async () => {
@@ -880,74 +878,74 @@ describe('Exchange', () => {
describe('Testing Exchange of ERC721 Tokens', () => {
it('should successfully exchange a single token between the maker and taker (via fillOrder)', async () => {
// Construct Exchange parameters
- const makerTokenId = new BigNumber('0x1010101010101010101010101010101010101010101010101010101010101010');
- const takerTokenId = new BigNumber('0x4040404040404040404040404040404040404040404040404040404040404040');
+ const makerTokenId = erc721MakerTokenIds[0];
+ const takerTokenId = erc721TakerTokenIds[1];
signedOrder = orderFactory.newSignedOrder({
- makerTokenAddress: ck.address,
- takerTokenAddress: ck.address,
+ makerTokenAddress: erc721Token.address,
+ takerTokenAddress: erc721Token.address,
makerTokenAmount: new BigNumber(1),
takerTokenAmount: new BigNumber(1),
- makerAssetData: encodeERC721ProxyData(ck.address, makerTokenId),
- takerAssetData: encodeERC721ProxyData(ck.address, takerTokenId),
+ makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
+ takerAssetData: encodeERC721ProxyData(erc721Token.address, takerTokenId),
});
// Verify pre-conditions
- const initialOwnerMakerToken = await ck.ownerOf.callAsync(makerTokenId);
+ const initialOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
expect(initialOwnerMakerToken).to.be.bignumber.equal(makerAddress);
- const initialOwnerTakerToken = await ck.ownerOf.callAsync(takerTokenId);
+ const initialOwnerTakerToken = await erc721Token.ownerOf.callAsync(takerTokenId);
expect(initialOwnerTakerToken).to.be.bignumber.equal(takerAddress);
// Call Exchange
const takerTokenFillAmount = signedOrder.takerTokenAmount;
const res = await exWrapper.fillOrderAsync(signedOrder, takerAddress, { takerTokenFillAmount });
// Verify post-conditions
- const newOwnerMakerToken = await ck.ownerOf.callAsync(makerTokenId);
+ const newOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
expect(newOwnerMakerToken).to.be.bignumber.equal(takerAddress);
- const newOwnerTakerToken = await ck.ownerOf.callAsync(takerTokenId);
+ const newOwnerTakerToken = await erc721Token.ownerOf.callAsync(takerTokenId);
expect(newOwnerTakerToken).to.be.bignumber.equal(makerAddress);
});
it('should successfully exchange a single token between the maker and taker (via filleOrderNoThrow)', async () => {
// Construct Exchange parameters
- const makerTokenId = new BigNumber('0x1010101010101010101010101010101010101010101010101010101010101010');
- const takerTokenId = new BigNumber('0x4040404040404040404040404040404040404040404040404040404040404040');
+ const makerTokenId = erc721MakerTokenIds[0];
+ const takerTokenId = erc721TakerTokenIds[1];
signedOrder = orderFactory.newSignedOrder({
- makerTokenAddress: ck.address,
- takerTokenAddress: ck.address,
+ makerTokenAddress: erc721Token.address,
+ takerTokenAddress: erc721Token.address,
makerTokenAmount: new BigNumber(1),
takerTokenAmount: new BigNumber(1),
- makerAssetData: encodeERC721ProxyData(ck.address, makerTokenId),
- takerAssetData: encodeERC721ProxyData(ck.address, takerTokenId),
+ makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
+ takerAssetData: encodeERC721ProxyData(erc721Token.address, takerTokenId),
});
// Verify pre-conditions
- const initialOwnerMakerToken = await ck.ownerOf.callAsync(makerTokenId);
+ const initialOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
expect(initialOwnerMakerToken).to.be.bignumber.equal(makerAddress);
- const initialOwnerTakerToken = await ck.ownerOf.callAsync(takerTokenId);
+ const initialOwnerTakerToken = await erc721Token.ownerOf.callAsync(takerTokenId);
expect(initialOwnerTakerToken).to.be.bignumber.equal(takerAddress);
// Call Exchange
const takerTokenFillAmount = signedOrder.takerTokenAmount;
await exWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress, { takerTokenFillAmount });
// Verify post-conditions
- const newOwnerMakerToken = await ck.ownerOf.callAsync(makerTokenId);
+ const newOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
expect(newOwnerMakerToken).to.be.bignumber.equal(takerAddress);
- const newOwnerTakerToken = await ck.ownerOf.callAsync(takerTokenId);
+ const newOwnerTakerToken = await erc721Token.ownerOf.callAsync(takerTokenId);
expect(newOwnerTakerToken).to.be.bignumber.equal(makerAddress);
});
it('should throw when maker does not own the token with id makerTokenId', async () => {
// Construct Exchange parameters
- const makerTokenId = new BigNumber('0x3030303030303030303030303030303030303030303030303030303030303030');
- const takerTokenId = new BigNumber('0x4040404040404040404040404040404040404040404040404040404040404040');
+ const makerTokenId = erc721TakerTokenIds[0];
+ const takerTokenId = erc721TakerTokenIds[1];
signedOrder = orderFactory.newSignedOrder({
- makerTokenAddress: ck.address,
- takerTokenAddress: ck.address,
+ makerTokenAddress: erc721Token.address,
+ takerTokenAddress: erc721Token.address,
makerTokenAmount: new BigNumber(1),
takerTokenAmount: new BigNumber(1),
- makerAssetData: encodeERC721ProxyData(ck.address, makerTokenId),
- takerAssetData: encodeERC721ProxyData(ck.address, takerTokenId),
+ makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
+ takerAssetData: encodeERC721ProxyData(erc721Token.address, takerTokenId),
});
// Verify pre-conditions
- const initialOwnerMakerToken = await ck.ownerOf.callAsync(makerTokenId);
+ const initialOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
expect(initialOwnerMakerToken).to.be.bignumber.not.equal(makerAddress);
- const initialOwnerTakerToken = await ck.ownerOf.callAsync(takerTokenId);
+ const initialOwnerTakerToken = await erc721Token.ownerOf.callAsync(takerTokenId);
expect(initialOwnerTakerToken).to.be.bignumber.equal(takerAddress);
// Call Exchange
const takerTokenFillAmount = signedOrder.takerTokenAmount;
@@ -958,20 +956,20 @@ describe('Exchange', () => {
it('should throw when taker does not own the token with id takerTokenId', async () => {
// Construct Exchange parameters
- const makerTokenId = new BigNumber('0x1010101010101010101010101010101010101010101010101010101010101010');
- const takerTokenId = new BigNumber('0x2020202020202020202020202020202020202020202020202020202020202020');
+ const makerTokenId = erc721MakerTokenIds[0];
+ const takerTokenId = erc721MakerTokenIds[1];
signedOrder = orderFactory.newSignedOrder({
- makerTokenAddress: ck.address,
- takerTokenAddress: ck.address,
+ makerTokenAddress: erc721Token.address,
+ takerTokenAddress: erc721Token.address,
makerTokenAmount: new BigNumber(1),
takerTokenAmount: new BigNumber(1),
- makerAssetData: encodeERC721ProxyData(ck.address, makerTokenId),
- takerAssetData: encodeERC721ProxyData(ck.address, takerTokenId),
+ makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
+ takerAssetData: encodeERC721ProxyData(erc721Token.address, takerTokenId),
});
// Verify pre-conditions
- const initialOwnerMakerToken = await ck.ownerOf.callAsync(makerTokenId);
+ const initialOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
expect(initialOwnerMakerToken).to.be.bignumber.equal(makerAddress);
- const initialOwnerTakerToken = await ck.ownerOf.callAsync(takerTokenId);
+ const initialOwnerTakerToken = await erc721Token.ownerOf.callAsync(takerTokenId);
expect(initialOwnerTakerToken).to.be.bignumber.not.equal(takerAddress);
// Call Exchange
const takerTokenFillAmount = signedOrder.takerTokenAmount;
@@ -982,20 +980,20 @@ describe('Exchange', () => {
it('should throw when makerTokenAmount is greater than 1', async () => {
// Construct Exchange parameters
- const makerTokenId = new BigNumber('0x1010101010101010101010101010101010101010101010101010101010101010');
- const takerTokenId = new BigNumber('0x4040404040404040404040404040404040404040404040404040404040404040');
+ const makerTokenId = erc721MakerTokenIds[0];
+ const takerTokenId = erc721TakerTokenIds[0];
signedOrder = orderFactory.newSignedOrder({
- makerTokenAddress: ck.address,
- takerTokenAddress: ck.address,
+ makerTokenAddress: erc721Token.address,
+ takerTokenAddress: erc721Token.address,
makerTokenAmount: new BigNumber(2),
takerTokenAmount: new BigNumber(1),
- makerAssetData: encodeERC721ProxyData(ck.address, makerTokenId),
- takerAssetData: encodeERC721ProxyData(ck.address, takerTokenId),
+ makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
+ takerAssetData: encodeERC721ProxyData(erc721Token.address, takerTokenId),
});
// Verify pre-conditions
- const initialOwnerMakerToken = await ck.ownerOf.callAsync(makerTokenId);
+ const initialOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
expect(initialOwnerMakerToken).to.be.bignumber.equal(makerAddress);
- const initialOwnerTakerToken = await ck.ownerOf.callAsync(takerTokenId);
+ const initialOwnerTakerToken = await erc721Token.ownerOf.callAsync(takerTokenId);
expect(initialOwnerTakerToken).to.be.bignumber.equal(takerAddress);
// Call Exchange
const takerTokenFillAmount = signedOrder.takerTokenAmount;
@@ -1006,20 +1004,20 @@ describe('Exchange', () => {
it('should throw when takerTokenAmount is greater than 1', async () => {
// Construct Exchange parameters
- const makerTokenId = new BigNumber('0x1010101010101010101010101010101010101010101010101010101010101010');
- const takerTokenId = new BigNumber('0x4040404040404040404040404040404040404040404040404040404040404040');
+ const makerTokenId = erc721MakerTokenIds[0];
+ const takerTokenId = erc721TakerTokenIds[0];
signedOrder = orderFactory.newSignedOrder({
- makerTokenAddress: ck.address,
- takerTokenAddress: ck.address,
+ makerTokenAddress: erc721Token.address,
+ takerTokenAddress: erc721Token.address,
makerTokenAmount: new BigNumber(1),
takerTokenAmount: new BigNumber(500),
- makerAssetData: encodeERC721ProxyData(ck.address, makerTokenId),
- takerAssetData: encodeERC721ProxyData(ck.address, takerTokenId),
+ makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
+ takerAssetData: encodeERC721ProxyData(erc721Token.address, takerTokenId),
});
// Verify pre-conditions
- const initialOwnerMakerToken = await ck.ownerOf.callAsync(makerTokenId);
+ const initialOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
expect(initialOwnerMakerToken).to.be.bignumber.equal(makerAddress);
- const initialOwnerTakerToken = await ck.ownerOf.callAsync(takerTokenId);
+ const initialOwnerTakerToken = await erc721Token.ownerOf.callAsync(takerTokenId);
expect(initialOwnerTakerToken).to.be.bignumber.equal(takerAddress);
// Call Exchange
const takerTokenFillAmount = signedOrder.takerTokenAmount;
@@ -1030,20 +1028,20 @@ describe('Exchange', () => {
it('should throw on partial fill', async () => {
// Construct Exchange parameters
- const makerTokenId = new BigNumber('0x1010101010101010101010101010101010101010101010101010101010101010');
- const takerTokenId = new BigNumber('0x4040404040404040404040404040404040404040404040404040404040404040');
+ const makerTokenId = erc721MakerTokenIds[0];
+ const takerTokenId = erc721TakerTokenIds[0];
signedOrder = orderFactory.newSignedOrder({
- makerTokenAddress: ck.address,
- takerTokenAddress: ck.address,
+ makerTokenAddress: erc721Token.address,
+ takerTokenAddress: erc721Token.address,
makerTokenAmount: new BigNumber(1),
takerTokenAmount: new BigNumber(0),
- makerAssetData: encodeERC721ProxyData(ck.address, makerTokenId),
- takerAssetData: encodeERC721ProxyData(ck.address, takerTokenId),
+ makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
+ takerAssetData: encodeERC721ProxyData(erc721Token.address, takerTokenId),
});
// Verify pre-conditions
- const initialOwnerMakerToken = await ck.ownerOf.callAsync(makerTokenId);
+ const initialOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
expect(initialOwnerMakerToken).to.be.bignumber.equal(makerAddress);
- const initialOwnerTakerToken = await ck.ownerOf.callAsync(takerTokenId);
+ const initialOwnerTakerToken = await erc721Token.ownerOf.callAsync(takerTokenId);
expect(initialOwnerTakerToken).to.be.bignumber.equal(takerAddress);
// Call Exchange
const takerTokenFillAmount = signedOrder.takerTokenAmount;
@@ -1054,24 +1052,24 @@ describe('Exchange', () => {
it('should successfully fill order when makerToken is ERC721 and takerToken is ERC20', async () => {
// Construct Exchange parameters
- const makerTokenId = new BigNumber('0x1010101010101010101010101010101010101010101010101010101010101010');
+ const makerTokenId = erc721MakerTokenIds[0];
signedOrder = orderFactory.newSignedOrder({
- makerTokenAddress: ck.address,
+ makerTokenAddress: erc721Token.address,
takerTokenAddress: dgd.address,
makerTokenAmount: new BigNumber(1),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- makerAssetData: encodeERC721ProxyData(ck.address, makerTokenId),
+ makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
takerAssetData: encodeERC20ProxyData(dgd.address),
});
// Verify pre-conditions
- const initialOwnerMakerToken = await ck.ownerOf.callAsync(makerTokenId);
+ const initialOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
expect(initialOwnerMakerToken).to.be.bignumber.equal(makerAddress);
// Call Exchange
balances = await dmyBalances.getAsync();
const takerTokenFillAmount = signedOrder.takerTokenAmount;
await exWrapper.fillOrderAsync(signedOrder, takerAddress, { takerTokenFillAmount });
// Verify ERC721 token was transferred from Maker to Taker
- const newOwnerMakerToken = await ck.ownerOf.callAsync(makerTokenId);
+ const newOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
expect(newOwnerMakerToken).to.be.bignumber.equal(takerAddress);
// Verify ERC20 tokens were transferred from Taker to Maker & fees were paid correctly
const newBalances = await dmyBalances.getAsync();
@@ -1094,24 +1092,24 @@ describe('Exchange', () => {
it('should successfully fill order when makerToken is ERC20 and takerToken is ERC721', async () => {
// Construct Exchange parameters
- const takerTokenId = new BigNumber('0x4040404040404040404040404040404040404040404040404040404040404040');
+ const takerTokenId = erc721TakerTokenIds[0];
signedOrder = orderFactory.newSignedOrder({
- takerTokenAddress: ck.address,
+ takerTokenAddress: erc721Token.address,
makerTokenAddress: dgd.address,
takerTokenAmount: new BigNumber(1),
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- takerAssetData: encodeERC721ProxyData(ck.address, takerTokenId),
+ takerAssetData: encodeERC721ProxyData(erc721Token.address, takerTokenId),
makerAssetData: encodeERC20ProxyData(dgd.address),
});
// Verify pre-conditions
- const initialOwnerTakerToken = await ck.ownerOf.callAsync(takerTokenId);
+ const initialOwnerTakerToken = await erc721Token.ownerOf.callAsync(takerTokenId);
expect(initialOwnerTakerToken).to.be.bignumber.equal(takerAddress);
// Call Exchange
balances = await dmyBalances.getAsync();
const takerTokenFillAmount = signedOrder.takerTokenAmount;
await exWrapper.fillOrderAsync(signedOrder, takerAddress, { takerTokenFillAmount });
// Verify ERC721 token was transferred from Taker to Maker
- const newOwnerTakerToken = await ck.ownerOf.callAsync(takerTokenId);
+ const newOwnerTakerToken = await erc721Token.ownerOf.callAsync(takerTokenId);
expect(newOwnerTakerToken).to.be.bignumber.equal(makerAddress);
// Verify ERC20 tokens were transferred from Maker to Taker & fees were paid correctly
const newBalances = await dmyBalances.getAsync();