fixing bugs

This commit is contained in:
Michael Zhu
2019-12-04 16:14:46 -08:00
parent be0e6c8925
commit ccb477687a
19 changed files with 238 additions and 201 deletions

View File

@@ -100,9 +100,9 @@ export function KeeperMixin<TBase extends Constructor>(Base: TBase): TBase & Con
private async *_validEndEpoch(): AsyncIterableIterator<AssertionResult | void> {
const assertion = validEndEpochAssertion(this.actor.deployment, this.actor.simulationEnvironment!);
const { currentEpoch } = this.actor.simulationEnvironment!;
const { stakingWrapper } = this.actor.deployment.staking;
while (true) {
const { currentEpoch } = this.actor.simulationEnvironment!;
const aggregatedStats = AggregatedStats.fromArray(
await stakingWrapper.aggregatedStatsByEpoch(currentEpoch.minus(1)).callAsync(),
);

View File

@@ -71,8 +71,8 @@ export function StakerMixin<TBase extends Constructor>(Base: TBase): TBase & Con
private async *_validStake(): AsyncIterableIterator<AssertionResult> {
const { zrx } = this.actor.deployment.tokens;
const { deployment, balanceStore, globalStake } = this.actor.simulationEnvironment!;
const assertion = validStakeAssertion(deployment, balanceStore, globalStake, this.stake);
const { deployment, balanceStore } = this.actor.simulationEnvironment!;
const assertion = validStakeAssertion(deployment, this.actor.simulationEnvironment!, this.stake);
while (true) {
await balanceStore.updateErc20BalancesAsync();
@@ -84,8 +84,8 @@ export function StakerMixin<TBase extends Constructor>(Base: TBase): TBase & Con
private async *_validUnstake(): AsyncIterableIterator<AssertionResult> {
const { stakingWrapper } = this.actor.deployment.staking;
const { deployment, balanceStore, globalStake } = this.actor.simulationEnvironment!;
const assertion = validUnstakeAssertion(deployment, balanceStore, globalStake, this.stake);
const { deployment, balanceStore } = this.actor.simulationEnvironment!;
const assertion = validUnstakeAssertion(deployment, this.actor.simulationEnvironment!, this.stake);
while (true) {
await balanceStore.updateErc20BalancesAsync();
@@ -102,22 +102,23 @@ export function StakerMixin<TBase extends Constructor>(Base: TBase): TBase & Con
}
private async *_validMoveStake(): AsyncIterableIterator<AssertionResult> {
const { deployment, globalStake, stakingPools } = this.actor.simulationEnvironment!;
const assertion = validMoveStakeAssertion(deployment, globalStake, this.stake, stakingPools);
const { deployment, stakingPools } = this.actor.simulationEnvironment!;
const assertion = validMoveStakeAssertion(deployment, this.actor.simulationEnvironment!, this.stake);
while (true) {
const { currentEpoch } = this.actor.simulationEnvironment!;
const fromPoolId = Pseudorandom.sample(
Object.keys(_.omit(this.stake[StakeStatus.Delegated], ['total'])),
);
const fromStatus =
fromPoolId === undefined
fromPoolId === undefined || stakingPools[fromPoolId].lastFinalized.isLessThan(currentEpoch.minus(1))
? StakeStatus.Undelegated
: (Pseudorandom.sample([StakeStatus.Undelegated, StakeStatus.Delegated]) as StakeStatus);
const from = new StakeInfo(fromStatus, fromPoolId);
const toPoolId = Pseudorandom.sample(Object.keys(stakingPools));
const toStatus =
toPoolId === undefined
toPoolId === undefined || stakingPools[toPoolId].lastFinalized.isLessThan(currentEpoch.minus(1))
? StakeStatus.Undelegated
: (Pseudorandom.sample([StakeStatus.Undelegated, StakeStatus.Delegated]) as StakeStatus);
const to = new StakeInfo(toStatus, toPoolId);
@@ -134,9 +135,17 @@ export function StakerMixin<TBase extends Constructor>(Base: TBase): TBase & Con
private async *_validWithdrawDelegatorRewards(): AsyncIterableIterator<AssertionResult | void> {
const { stakingPools } = this.actor.simulationEnvironment!;
const assertion = validWithdrawDelegatorRewardsAssertion(this.actor.deployment, this.actor.simulationEnvironment!);
const assertion = validWithdrawDelegatorRewardsAssertion(
this.actor.deployment,
this.actor.simulationEnvironment!,
);
while (true) {
const poolId = Pseudorandom.sample(Object.keys(stakingPools));
const prevEpoch = this.actor.simulationEnvironment!.currentEpoch.minus(1);
const poolId = Pseudorandom.sample(
Object.keys(stakingPools).filter(poolId =>
stakingPools[poolId].lastFinalized.isGreaterThanOrEqualTo(prevEpoch),
),
);
if (poolId === undefined) {
yield;
} else {

View File

@@ -83,11 +83,9 @@ export function TakerMixin<TBase extends Constructor>(Base: TBase): TBase & Cons
token: DummyERC20TokenContract,
): Promise<BigNumber> => {
let balance = balanceStore.balances.erc20[owner.address][token.address];
if (balance === undefined || balance.isZero()) {
await owner.configureERC20TokenAsync(token);
balance = balanceStore.balances.erc20[owner.address][token.address] =
constants.INITIAL_ERC20_BALANCE;
}
await owner.configureERC20TokenAsync(token);
balance = balanceStore.balances.erc20[owner.address][token.address] =
constants.INITIAL_ERC20_BALANCE;
return Pseudorandom.integer(balance.dividedToIntegerBy(2));
};