* move orderParsingUtils from order-utils to connect * Remove many functions from signatureUtils Removed from the exported object, that is. All of them are used in other existing code, so they were all moved to be as local to their usage as possible. * remove orderHashUtils.isValidOrderHash() * Move all *RevertErrors from order-utils... ...into their respective @0x/contracts- packages. * Refactor @0x/order-utils' orderHashUtils away - Move existing routines into @0x/contracts-test-utils - Migrate non-contract-test callers to a newly-exposed getOrderHash() method in DevUtils. * Move all *RevertErrors from @0x/utils... ...into their respective @0x/contracts- packages. * rm transactionHashUtils.isValidTransactionHash() * DevUtils.sol: Fail yarn test if too big to deploy * Refactor @0x/order-utils transactionHashUtils away - Move existing routines into @0x/contracts-test-utils - Migrate non-contract-test callers to a newly-exposed getTransactionHash() method in DevUtils. * Consolidate `Removed export...` CHANGELOG entries * Rm EthBalanceChecker from devutils wrapper exports * Stop importing from '.' or '.../src' * fix builds * fix prettier; dangling promise * increase max bundle size
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { chaiSetup, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
|
|
import { BlockchainLifecycle } from '@0x/dev-utils';
|
|
import * as chai from 'chai';
|
|
import * as _ from 'lodash';
|
|
|
|
import ReentrancyGuardRevertErrors = require('../src/reentrancy_guard_revert_errors');
|
|
|
|
import { artifacts } from './artifacts';
|
|
import { TestReentrancyGuardContract } from './wrappers';
|
|
|
|
chaiSetup.configure();
|
|
const expect = chai.expect;
|
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
|
|
|
describe('ReentrancyGuard', () => {
|
|
let guard: TestReentrancyGuardContract;
|
|
|
|
before(async () => {
|
|
await blockchainLifecycle.startAsync();
|
|
// Deploy TestReentrancyGuard
|
|
guard = await TestReentrancyGuardContract.deployFrom0xArtifactAsync(
|
|
artifacts.TestReentrancyGuard,
|
|
provider,
|
|
txDefaults,
|
|
{},
|
|
);
|
|
});
|
|
|
|
after(async () => {
|
|
await blockchainLifecycle.revertAsync();
|
|
});
|
|
|
|
describe('nonReentrant', () => {
|
|
it('should revert if reentrancy occurs', async () => {
|
|
const expectedError = new ReentrancyGuardRevertErrors.IllegalReentrancyError();
|
|
return expect(guard.guarded(true).sendTransactionAsync()).to.revertWith(expectedError);
|
|
});
|
|
|
|
it('should succeed if reentrancy does not occur', async () => {
|
|
const isSuccessful = await guard.guarded(false).callAsync();
|
|
expect(isSuccessful).to.be.true();
|
|
});
|
|
});
|
|
});
|