aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-07-07 05:12:53 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-07-11 02:24:22 +0800
commit092ca6bcf5de2d94ff503f11233c87d428eedcb8 (patch)
tree892cc61220dd4bbc769ef0e43c034b9a780103b0 /packages/contracts/test
parent2625cbbfed087dae55c62950a9260145cf5ca8e6 (diff)
downloaddexon-sol-tools-092ca6bcf5de2d94ff503f11233c87d428eedcb8.tar
dexon-sol-tools-092ca6bcf5de2d94ff503f11233c87d428eedcb8.tar.gz
dexon-sol-tools-092ca6bcf5de2d94ff503f11233c87d428eedcb8.tar.bz2
dexon-sol-tools-092ca6bcf5de2d94ff503f11233c87d428eedcb8.tar.lz
dexon-sol-tools-092ca6bcf5de2d94ff503f11233c87d428eedcb8.tar.xz
dexon-sol-tools-092ca6bcf5de2d94ff503f11233c87d428eedcb8.tar.zst
dexon-sol-tools-092ca6bcf5de2d94ff503f11233c87d428eedcb8.zip
Use 0.4.10 in AssetProxyOwner, add readBytes4 to contract and remove LibBytes
Diffstat (limited to 'packages/contracts/test')
-rw-r--r--packages/contracts/test/asset_proxy/proxies.ts6
-rw-r--r--packages/contracts/test/multisig/asset_proxy_owner.ts24
-rw-r--r--packages/contracts/test/utils/constants.ts3
-rw-r--r--packages/contracts/test/utils/multi_sig_wrapper.ts7
4 files changed, 33 insertions, 7 deletions
diff --git a/packages/contracts/test/asset_proxy/proxies.ts b/packages/contracts/test/asset_proxy/proxies.ts
index e1167b156..36e0800d6 100644
--- a/packages/contracts/test/asset_proxy/proxies.ts
+++ b/packages/contracts/test/asset_proxy/proxies.ts
@@ -272,7 +272,7 @@ describe('Asset Transfer Proxies', () => {
to: erc721Proxy.address,
data,
from: exchangeAddress,
- gas: constants.TRANSFER_FROM_GAS,
+ gas: constants.MAX_TRANSFER_FROM_GAS,
}),
);
// Verify that no log was emitted by erc721 receiver
@@ -311,7 +311,7 @@ describe('Asset Transfer Proxies', () => {
to: erc721Proxy.address,
data,
from: exchangeAddress,
- gas: constants.TRANSFER_FROM_GAS,
+ gas: constants.MAX_TRANSFER_FROM_GAS,
}),
);
// Validate log emitted by erc721 receiver
@@ -349,7 +349,7 @@ describe('Asset Transfer Proxies', () => {
to: erc721Proxy.address,
data,
from: exchangeAddress,
- gas: constants.TRANSFER_FROM_GAS,
+ gas: constants.MAX_TRANSFER_FROM_GAS,
}),
RevertReason.TransferFailed,
);
diff --git a/packages/contracts/test/multisig/asset_proxy_owner.ts b/packages/contracts/test/multisig/asset_proxy_owner.ts
index 10fed6815..6a9843153 100644
--- a/packages/contracts/test/multisig/asset_proxy_owner.ts
+++ b/packages/contracts/test/multisig/asset_proxy_owner.ts
@@ -148,6 +148,25 @@ describe('AssetProxyOwner', () => {
});
});
+ describe('readBytes4', () => {
+ it('should revert if byte array has a length < 4', async () => {
+ const byteArrayLessThan4Bytes = '0x010101';
+ return expectContractCallFailedWithoutReasonAsync(
+ testAssetProxyOwner.publicReadBytes4.callAsync(byteArrayLessThan4Bytes, new BigNumber(0)),
+ );
+ });
+ it('should return the first 4 bytes of a byte array of arbitrary length', async () => {
+ const byteArrayLongerThan32Bytes =
+ '0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
+ const first4Bytes = await testAssetProxyOwner.publicReadBytes4.callAsync(
+ byteArrayLongerThan32Bytes,
+ new BigNumber(0),
+ );
+ const expectedFirst4Bytes = byteArrayLongerThan32Bytes.slice(0, 10);
+ expect(first4Bytes).to.equal(expectedFirst4Bytes);
+ });
+ });
+
describe('registerAssetProxy', () => {
it('should throw if not called by multisig', async () => {
const isRegistered = true;
@@ -238,8 +257,6 @@ describe('AssetProxyOwner', () => {
const registerAssetProxySubmitLog = registerAssetProxySubmitRes.logs[0] as LogWithDecodedArgs<
AssetProxyOwnerSubmissionEventArgs
>;
- const registerAssetProxyTxId = registerAssetProxySubmitLog.args.transactionId;
- await multiSigWrapper.confirmTransactionAsync(registerAssetProxyTxId, owners[1]);
const addAuthorizedAddressData = erc20Proxy.addAuthorizedAddress.getABIEncodedTransactionData(authorized);
const erc20AddAuthorizedAddressSubmitRes = await multiSigWrapper.submitTransactionAsync(
@@ -257,9 +274,12 @@ describe('AssetProxyOwner', () => {
>;
const erc721AddAuthorizedAddressSubmitLog = erc721AddAuthorizedAddressSubmitRes
.logs[0] as LogWithDecodedArgs<AssetProxyOwnerSubmissionEventArgs>;
+
+ const registerAssetProxyTxId = registerAssetProxySubmitLog.args.transactionId;
const erc20AddAuthorizedAddressTxId = erc20AddAuthorizedAddressSubmitLog.args.transactionId;
const erc721AddAuthorizedAddressTxId = erc721AddAuthorizedAddressSubmitLog.args.transactionId;
+ await multiSigWrapper.confirmTransactionAsync(registerAssetProxyTxId, owners[1]);
await multiSigWrapper.confirmTransactionAsync(erc20AddAuthorizedAddressTxId, owners[1]);
await multiSigWrapper.confirmTransactionAsync(erc721AddAuthorizedAddressTxId, owners[1]);
await increaseTimeAndMineBlockAsync(SECONDS_TIME_LOCKED.toNumber());
diff --git a/packages/contracts/test/utils/constants.ts b/packages/contracts/test/utils/constants.ts
index 7f3ad62e1..e8995f9d6 100644
--- a/packages/contracts/test/utils/constants.ts
+++ b/packages/contracts/test/utils/constants.ts
@@ -24,9 +24,10 @@ export const constants = {
// ensure we always use the minimum interval.
AWAIT_TRANSACTION_MINED_MS: 0,
MAX_ETHERTOKEN_WITHDRAW_GAS: 43000,
+ MAX_EXECUTE_TRANSACTION_GAS: 1000000,
MAX_TOKEN_TRANSFERFROM_GAS: 80000,
MAX_TOKEN_APPROVE_GAS: 60000,
- TRANSFER_FROM_GAS: 150000,
+ MAX_TRANSFER_FROM_GAS: 150000,
DUMMY_TOKEN_NAME: '',
DUMMY_TOKEN_SYMBOL: '',
DUMMY_TOKEN_DECIMALS: new BigNumber(18),
diff --git a/packages/contracts/test/utils/multi_sig_wrapper.ts b/packages/contracts/test/utils/multi_sig_wrapper.ts
index 6e7746dfc..2024c177d 100644
--- a/packages/contracts/test/utils/multi_sig_wrapper.ts
+++ b/packages/contracts/test/utils/multi_sig_wrapper.ts
@@ -6,6 +6,7 @@ import * as _ from 'lodash';
import { AssetProxyOwnerContract } from '../../generated_contract_wrappers/asset_proxy_owner';
import { MultiSigWalletContract } from '../../generated_contract_wrappers/multi_sig_wallet';
+import { constants } from './constants';
import { LogDecoder } from './log_decoder';
export class MultiSigWrapper {
@@ -36,7 +37,10 @@ export class MultiSigWrapper {
return tx;
}
public async executeTransactionAsync(txId: BigNumber, from: string): Promise<TransactionReceiptWithDecodedLogs> {
- const txHash = await this._multiSig.executeTransaction.sendTransactionAsync(txId, { from });
+ const txHash = await this._multiSig.executeTransaction.sendTransactionAsync(txId, {
+ from,
+ gas: constants.MAX_EXECUTE_TRANSACTION_GAS,
+ });
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
@@ -48,6 +52,7 @@ export class MultiSigWrapper {
const txHash = await (this
._multiSig as AssetProxyOwnerContract).executeRemoveAuthorizedAddressAtIndex.sendTransactionAsync(txId, {
from,
+ gas: constants.MAX_EXECUTE_TRANSACTION_GAS,
});
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;