aboutsummaryrefslogtreecommitdiffstats
path: root/packages/dev-utils
diff options
context:
space:
mode:
Diffstat (limited to 'packages/dev-utils')
-rw-r--r--packages/dev-utils/CHANGELOG.json18
-rw-r--r--packages/dev-utils/CHANGELOG.md4
-rw-r--r--packages/dev-utils/package.json20
-rw-r--r--packages/dev-utils/src/blockchain_lifecycle.ts43
4 files changed, 59 insertions, 26 deletions
diff --git a/packages/dev-utils/CHANGELOG.json b/packages/dev-utils/CHANGELOG.json
index 56ecd023e..f94fd5f30 100644
--- a/packages/dev-utils/CHANGELOG.json
+++ b/packages/dev-utils/CHANGELOG.json
@@ -1,5 +1,23 @@
[
{
+ "timestamp": 1532043000,
+ "version": "1.0.0",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
+ "timestamp": 1531919263,
+ "version": "0.4.6",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1531149657,
"version": "0.4.5",
"changes": [
diff --git a/packages/dev-utils/CHANGELOG.md b/packages/dev-utils/CHANGELOG.md
index 55e12b2dd..de9287478 100644
--- a/packages/dev-utils/CHANGELOG.md
+++ b/packages/dev-utils/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v0.4.6 - _July 18, 2018_
+
+ * Dependencies updated
+
## v0.4.5 - _July 9, 2018_
* Dependencies updated
diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json
index f0ef24684..7a1f3c4ff 100644
--- a/packages/dev-utils/package.json
+++ b/packages/dev-utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/dev-utils",
- "version": "0.4.5",
+ "version": "1.0.0",
"engines": {
"node": ">=6.12"
},
@@ -30,8 +30,8 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/dev-utils/README.md",
"devDependencies": {
- "@0xproject/monorepo-scripts": "^0.2.2",
- "@0xproject/tslint-config": "^0.4.21",
+ "@0xproject/monorepo-scripts": "^1.0.0",
+ "@0xproject/tslint-config": "^1.0.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
"chai": "^4.0.1",
@@ -41,16 +41,16 @@
"npm-run-all": "^4.1.2",
"nyc": "^11.0.1",
"shx": "^0.2.2",
- "tslint": "5.8.0",
+ "tslint": "5.11.0",
"typescript": "2.7.1"
},
"dependencies": {
- "@0xproject/subproviders": "^0.10.5",
- "@0xproject/types": "^0.8.2",
- "@0xproject/utils": "^0.7.2",
- "ethereum-types": "^0.0.2",
- "@0xproject/typescript-typings": "^0.4.2",
- "@0xproject/web3-wrapper": "^0.7.2",
+ "@0xproject/subproviders": "^1.0.0",
+ "@0xproject/types": "^1.0.0-rc.1",
+ "@0xproject/utils": "^1.0.0",
+ "ethereum-types": "^1.0.0",
+ "@0xproject/typescript-typings": "^1.0.0",
+ "@0xproject/web3-wrapper": "^1.0.0",
"lodash": "^4.17.4"
},
"publishConfig": {
diff --git a/packages/dev-utils/src/blockchain_lifecycle.ts b/packages/dev-utils/src/blockchain_lifecycle.ts
index 9bd65ee5d..a48cb0856 100644
--- a/packages/dev-utils/src/blockchain_lifecycle.ts
+++ b/packages/dev-utils/src/blockchain_lifecycle.ts
@@ -10,8 +10,8 @@ import * as _ from 'lodash';
const MINIMUM_BLOCKS = 3;
export class BlockchainLifecycle {
- private _web3Wrapper: Web3Wrapper;
- private _snapshotIdsStack: number[];
+ private readonly _web3Wrapper: Web3Wrapper;
+ private readonly _snapshotIdsStack: number[];
private _addresses: string[] = [];
private _nodeType: NodeType | undefined;
constructor(web3Wrapper: Web3Wrapper) {
@@ -34,6 +34,12 @@ export class BlockchainLifecycle {
blockNumber = await this._web3Wrapper.getBlockNumberAsync();
}
this._snapshotIdsStack.push(blockNumber);
+ // HACK(albrow) It's possible that we applied a time offset but
+ // the transaction we mined to put that time offset into the
+ // blockchain was reverted. As a workaround, we mine a new dummy
+ // block so that the latest block timestamp accounts for any
+ // possible time offsets.
+ await this._mineDummyBlockAsync();
break;
default:
throw new Error(`Unknown node type: ${nodeType}`);
@@ -59,22 +65,9 @@ export class BlockchainLifecycle {
}
private async _mineMinimumBlocksAsync(): Promise<void> {
logUtils.warn('WARNING: minimum block number for tests not met. Mining additional blocks...');
- if (this._addresses.length === 0) {
- this._addresses = await this._web3Wrapper.getAvailableAddressesAsync();
- if (this._addresses.length === 0) {
- throw new Error('No accounts found');
- }
- }
while ((await this._web3Wrapper.getBlockNumberAsync()) < MINIMUM_BLOCKS) {
logUtils.warn('Mining block...');
- await this._web3Wrapper.awaitTransactionMinedAsync(
- await this._web3Wrapper.sendTransactionAsync({
- from: this._addresses[0],
- to: this._addresses[0],
- value: '0',
- }),
- 0,
- );
+ await this._mineDummyBlockAsync();
}
logUtils.warn('Done mining the minimum number of blocks.');
}
@@ -84,4 +77,22 @@ export class BlockchainLifecycle {
}
return this._nodeType;
}
+ // Sends a transaction that has no real effect on the state and waits for it
+ // to be mined.
+ private async _mineDummyBlockAsync(): Promise<void> {
+ if (this._addresses.length === 0) {
+ this._addresses = await this._web3Wrapper.getAvailableAddressesAsync();
+ if (this._addresses.length === 0) {
+ throw new Error('No accounts found');
+ }
+ }
+ await this._web3Wrapper.awaitTransactionMinedAsync(
+ await this._web3Wrapper.sendTransactionAsync({
+ from: this._addresses[0],
+ to: this._addresses[0],
+ value: '0',
+ }),
+ 0,
+ );
+ }
}