Updated tests for epochs. More robust and helpful for staking tests.

This commit is contained in:
Greg Hysen
2019-06-05 16:59:54 -07:00
parent 30db88d27b
commit b1d98a4183
8 changed files with 118 additions and 27 deletions

View File

@@ -156,6 +156,11 @@ export class StakingWrapper {
const txReceipt = await this._executeTransactionAsync(calldata, owner);
return txReceipt;
}
public async forceTimelockSyncAsync(owner: string): Promise<TransactionReceiptWithDecodedLogs> {
const calldata = this.getStakingContract().forceTimelockSync.getABIEncodedTransactionData(owner);
const txReceipt = await this._executeTransactionAsync(calldata, this._ownerAddres);
return txReceipt;
}
///// STAKE BALANCES /////
public async getTotalStakeAsync(owner: string): Promise<string> {
const calldata = this.getStakingContract().getTotalStake.getABIEncodedTransactionData(owner);
@@ -172,6 +177,11 @@ export class StakingWrapper {
const deactivatedStake = await this._callAsync(calldata);
return deactivatedStake;
}
public async getActivatableStakeAsync(owner: string): Promise<string> {
const calldata = this.getStakingContract().getActivatableStake.getABIEncodedTransactionData(owner);
const activatableStake = await this._callAsync(calldata);
return activatableStake;
}
public async getWithdrawableStakeAsync(owner: string): Promise<string> {
const calldata = this.getStakingContract().getWithdrawableStake.getABIEncodedTransactionData(owner);
const withdrawableStake = await this._callAsync(calldata);
@@ -183,7 +193,7 @@ export class StakingWrapper {
return timelockedStake;
}
public async getStakeDelegatedByOwnerAsync(owner: string): Promise<string> {
const calldata = this.getStakingContract().getTimelockedStake.getABIEncodedTransactionData(owner);
const calldata = this.getStakingContract().getStakeDelegatedByOwner.getABIEncodedTransactionData(owner);
const stakeDelegatedByOwner = await this._callAsync(calldata);
return stakeDelegatedByOwner;
}
@@ -249,6 +259,15 @@ export class StakingWrapper {
await this._web3Wrapper.mineBlockAsync();
return txReceipt;
}
public async skipToNextTimelockPeriodAsync(): Promise<void> {
const timelockEndEpoch = await this.getCurrentTimelockPeriodEndEpochAsync();
const currentEpoch = await this.getCurrentEpochAsync();
const nEpochsToJump = timelockEndEpoch.minus(currentEpoch);
const nEpochsToJumpAsNumber = nEpochsToJump.toNumber();
for (let i = 0; i < nEpochsToJumpAsNumber; ++i) {
await this.skipToNextEpochAsync();
}
}
public async getEpochPeriodInSecondsAsync(): Promise<BigNumber> {
const calldata = this.getStakingContract().getEpochPeriodInSeconds.getABIEncodedTransactionData();
const returnData = await this._callAsync(calldata);