Move LibAssetDataTransfer and MixinWeth(Utils) to contracts-extensions

This commit is contained in:
Michael Zhu
2020-01-31 14:57:32 -08:00
parent a2fcab47d4
commit 329719472a
65 changed files with 565 additions and 4826 deletions

View File

@@ -1,5 +1,4 @@
import { blockchainTests, constants, expect, getRandomInteger, randomAddress } from '@0x/contracts-test-utils';
import { assetDataUtils } from '@0x/order-utils';
import { blockchainTests, constants, expect, getRandomInteger } from '@0x/contracts-test-utils';
import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
@@ -39,28 +38,18 @@ blockchainTests.resets('GodsUnchainedValidator unit tests', env => {
it('succeeds if assetData proto and quality match propertyData', async () => {
const tokenId = getRandomInteger(0, constants.MAX_UINT256);
await godsUnchained.setTokenProperties(tokenId, proto, quality).awaitTransactionSuccessAsync();
const assetData = assetDataUtils.encodeERC721AssetData(godsUnchained.address, tokenId);
await validator.checkBrokerAsset(assetData, propertyData).callAsync();
});
it('reverts if assetData tokenAddress is not the GU contract address', async () => {
const tokenId = getRandomInteger(0, constants.MAX_UINT256);
await godsUnchained.setTokenProperties(tokenId, proto, quality).awaitTransactionSuccessAsync();
const assetData = assetDataUtils.encodeERC721AssetData(randomAddress(), tokenId);
const tx = validator.checkBrokerAsset(assetData, propertyData).callAsync();
expect(tx).to.revertWith('TOKEN_ADDRESS_MISMATCH');
await validator.checkBrokerAsset(tokenId, propertyData).callAsync();
});
it("reverts if assetData proto doesn't match propertyData", async () => {
const tokenId = getRandomInteger(0, constants.MAX_UINT256);
await godsUnchained.setTokenProperties(tokenId, proto.plus(1), quality).awaitTransactionSuccessAsync();
const assetData = assetDataUtils.encodeERC721AssetData(godsUnchained.address, tokenId);
const tx = validator.checkBrokerAsset(assetData, propertyData).callAsync();
const tx = validator.checkBrokerAsset(tokenId, propertyData).callAsync();
expect(tx).to.revertWith('PROTO_MISMATCH');
});
it("reverts if assetData quality doesn't match proeprtyData", async () => {
const tokenId = getRandomInteger(0, constants.MAX_UINT256);
await godsUnchained.setTokenProperties(tokenId, proto, quality.plus(1)).awaitTransactionSuccessAsync();
const assetData = assetDataUtils.encodeERC721AssetData(godsUnchained.address, tokenId);
const tx = validator.checkBrokerAsset(assetData, propertyData).callAsync();
const tx = validator.checkBrokerAsset(tokenId, propertyData).callAsync();
expect(tx).to.revertWith('QUALITY_MISMATCH');
});
});