invalidDecreaseStakingPoolOperatorShareAssertion

This commit is contained in:
Michael Zhu
2019-12-17 13:38:16 -08:00
parent b80ae5796b
commit 3bf37d6afd
3 changed files with 62 additions and 4 deletions

View File

@@ -5,7 +5,10 @@ import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import * as _ from 'lodash';
import { invalidCreateStakingPoolAssertion, validCreateStakingPoolAssertion } from '../assertions/createStakingPool';
import { validDecreaseStakingPoolOperatorShareAssertion } from '../assertions/decreaseStakingPoolOperatorShare';
import {
invalidDecreaseStakingPoolOperatorShareAssertion,
validDecreaseStakingPoolOperatorShareAssertion,
} from '../assertions/decreaseStakingPoolOperatorShare';
import { AssertionResult } from '../assertions/function_assertion';
import { Distributions, Pseudorandom } from '../utils/pseudorandom';
@@ -44,6 +47,7 @@ export function PoolOperatorMixin<TBase extends Constructor>(Base: TBase): TBase
validCreateStakingPool: this._validCreateStakingPool(),
invalidCreateStakingPool: this._invalidCreateStakingPool(),
validDecreaseStakingPoolOperatorShare: this._validDecreaseStakingPoolOperatorShare(),
invalidDecreaseStakingPoolOperatorShare: this._invalidDecreaseStakingPoolOperatorShare(),
};
}
@@ -123,6 +127,24 @@ export function PoolOperatorMixin<TBase extends Constructor>(Base: TBase): TBase
}
}
}
private async *_invalidDecreaseStakingPoolOperatorShare(): AsyncIterableIterator<AssertionResult | void> {
const { stakingPools } = this.actor.simulationEnvironment!;
const assertion = invalidDecreaseStakingPoolOperatorShareAssertion(this.actor.deployment);
while (true) {
const poolId = Pseudorandom.sample(this._getOperatorPoolIds(stakingPools));
if (poolId === undefined) {
yield undefined;
} else {
const operatorShare = Pseudorandom.integer(
stakingPools[poolId].operatorShare + 1,
constants.MAX_UINT32,
Distributions.Kumaraswamy(0.2, 0.2),
).toNumber();
yield assertion.executeAsync([poolId, operatorShare], { from: this.actor.address });
}
}
}
};
}