Refactor integrations directory structure; move core.ts, balance stores, and FillOrderWrapper to integrations
This commit is contained in:
38
contracts/integrations/test/framework/simulation.ts
Normal file
38
contracts/integrations/test/framework/simulation.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { GlobalStakeByStatus, StakeStatus, StakingPoolById, StoredBalance } from '@0x/contracts-staking';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { AssertionResult } from './assertions/function_assertion';
|
||||
import { BlockchainBalanceStore } from './balances/blockchain_balance_store';
|
||||
import { DeploymentManager } from './deployment_manager';
|
||||
|
||||
// tslint:disable:max-classes-per-file
|
||||
|
||||
export class SimulationEnvironment {
|
||||
public globalStake: GlobalStakeByStatus = {
|
||||
[StakeStatus.Undelegated]: new StoredBalance(),
|
||||
[StakeStatus.Delegated]: new StoredBalance(),
|
||||
};
|
||||
public stakingPools: StakingPoolById = {};
|
||||
|
||||
public constructor(public readonly deployment: DeploymentManager, public balanceStore: BlockchainBalanceStore) {}
|
||||
}
|
||||
|
||||
export abstract class Simulation {
|
||||
public readonly generator = this._assertionGenerator();
|
||||
|
||||
constructor(public environment: SimulationEnvironment) {}
|
||||
|
||||
public async fuzzAsync(steps?: number): Promise<void> {
|
||||
if (steps !== undefined) {
|
||||
for (let i = 0; i < steps; i++) {
|
||||
await this.generator.next();
|
||||
}
|
||||
} else {
|
||||
while (true) {
|
||||
await this.generator.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract _assertionGenerator(): AsyncIterableIterator<AssertionResult | void>;
|
||||
}
|
Reference in New Issue
Block a user