rename BlockClean to BlockchainLifecycle and setupAsync to startAsync, restoreAsync to revertAsync
This commit is contained in:
parent
badd4a98e9
commit
d5feb5fc79
@ -4,12 +4,12 @@ import chaiAsPromised = require('chai-as-promised');
|
|||||||
import * as Web3 from 'web3';
|
import * as Web3 from 'web3';
|
||||||
import {web3Factory} from './utils/web3_factory';
|
import {web3Factory} from './utils/web3_factory';
|
||||||
import {ExchangeWrapper} from '../src/ts/contract_wrappers/exchange_wrapper';
|
import {ExchangeWrapper} from '../src/ts/contract_wrappers/exchange_wrapper';
|
||||||
import {BlockchainClean} from './utils/blockchain_clean';
|
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
|
||||||
import {Web3Wrapper} from './../src/ts/web3_wrapper';
|
import {Web3Wrapper} from './../src/ts/web3_wrapper';
|
||||||
|
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
chai.use(chaiAsPromised);
|
chai.use(chaiAsPromised);
|
||||||
const blockchainClean = new BlockchainClean();
|
const blockchainLifecycle = new BlockchainLifecycle();
|
||||||
|
|
||||||
describe('ExchangeWrapper', () => {
|
describe('ExchangeWrapper', () => {
|
||||||
let web3Wrapper: Web3Wrapper;
|
let web3Wrapper: Web3Wrapper;
|
||||||
@ -20,10 +20,10 @@ describe('ExchangeWrapper', () => {
|
|||||||
exchangeWrapper = new ExchangeWrapper(web3Wrapper);
|
exchangeWrapper = new ExchangeWrapper(web3Wrapper);
|
||||||
});
|
});
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await blockchainClean.setupAsync();
|
await blockchainLifecycle.startAsync();
|
||||||
});
|
});
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await blockchainClean.restoreAsync();
|
await blockchainLifecycle.revertAsync();
|
||||||
});
|
});
|
||||||
describe('#isValidSignatureAsync', () => {
|
describe('#isValidSignatureAsync', () => {
|
||||||
// The Exchange smart contract `isValidSignature` method only validates orderHashes and assumes
|
// The Exchange smart contract `isValidSignature` method only validates orderHashes and assumes
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
import {RPC} from './rpc';
|
import {RPC} from './rpc';
|
||||||
|
|
||||||
export class BlockchainClean {
|
export class BlockchainLifecycle {
|
||||||
private rpc: RPC;
|
private rpc: RPC;
|
||||||
private snapshotId: number;
|
private snapshotId: number;
|
||||||
constructor() {
|
constructor() {
|
||||||
this.rpc = new RPC();
|
this.rpc = new RPC();
|
||||||
}
|
}
|
||||||
// TODO: Check if running on TestRPC or on actual node, if actual node, re-deploy contracts instead
|
// TODO: Check if running on TestRPC or on actual node, if actual node, re-deploy contracts instead
|
||||||
public async setupAsync(): Promise<void> {
|
public async startAsync(): Promise<void> {
|
||||||
this.snapshotId = await this.rpc.takeSnapshotAsync();
|
this.snapshotId = await this.rpc.takeSnapshotAsync();
|
||||||
}
|
}
|
||||||
public async restoreAsync(): Promise<void> {
|
public async revertAsync(): Promise<void> {
|
||||||
const didRevert = await this.rpc.revertSnapshotAsync(this.snapshotId);
|
const didRevert = await this.rpc.revertSnapshotAsync(this.snapshotId);
|
||||||
if (!didRevert) {
|
if (!didRevert) {
|
||||||
throw new Error(`Snapshot with id #${this.snapshotId} failed to revert`);
|
throw new Error(`Snapshot with id #${this.snapshotId} failed to revert`);
|
Loading…
x
Reference in New Issue
Block a user