rename Result -> FunctionResult

This commit is contained in:
Michael Zhu
2019-11-04 10:48:13 -08:00
parent afcfe58add
commit 91c26fc046
2 changed files with 11 additions and 11 deletions

View File

@@ -12,7 +12,7 @@ export interface ContractWrapperFunction extends ContractGetterFunction {
awaitTransactionSuccessAsync?: (...args: any[]) => PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>;
}
export interface Result {
export interface FunctionResult {
data?: any;
success: boolean;
receipt?: TransactionReceiptWithDecodedLogs;
@@ -30,7 +30,7 @@ export interface Result {
*/
export interface Condition<TBefore> {
before: (...args: any[]) => Promise<TBefore>;
after: (beforeInfo: TBefore, result: Result, ...args: any[]) => Promise<any>;
after: (beforeInfo: TBefore, result: FunctionResult, ...args: any[]) => Promise<any>;
}
/**
@@ -44,7 +44,7 @@ export interface Assertion {
executeAsync: (...args: any[]) => Promise<any>;
}
export interface RunResult {
export interface AssertionResult {
beforeInfo: any;
afterInfo: any;
}
@@ -73,12 +73,12 @@ export class FunctionAssertion<TBefore> implements Assertion {
* Runs the wrapped function and fails if the before or after assertions fail.
* @param ...args The args to the contract wrapper function.
*/
public async executeAsync(...args: any[]): Promise<RunResult> {
public async executeAsync(...args: any[]): Promise<AssertionResult> {
// Call the before condition.
const beforeInfo = await this.condition.before(...args);
// Initialize the callResult so that the default success value is true.
const callResult: Result = { success: true };
const callResult: FunctionResult = { success: true };
// Try to make the call to the function. If it is successful, pass the
// result and receipt to the after condition.

View File

@@ -2,7 +2,7 @@ import { blockchainTests, constants, expect, filterLogsToArguments, getRandomInt
import { BigNumber, StringRevertError } from '@0x/utils';
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import { FunctionAssertion, Result } from '../../src/function_assertions';
import { FunctionAssertion, FunctionResult } from '../../src/function_assertions';
import { artifacts } from '../artifacts';
import { TestFrameworkContract, TestFrameworkEventEventArgs, TestFrameworkEvents } from '../wrappers';
@@ -37,7 +37,7 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => {
it('should call the after function with the provided arguments', async () => {
let sideEffectTarget = ZERO_AMOUNT;
const assertion = new FunctionAssertion(exampleContract.returnInteger, {
after: async (_beforeInfo: any, _result: Result, input: BigNumber) => {
after: async (_beforeInfo: any, _result: FunctionResult, input: BigNumber) => {
sideEffectTarget = input;
},
});
@@ -58,7 +58,7 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => {
before: async (_input: BigNumber) => {
return randomInput;
},
after: async (beforeInfo: any, _result: Result, _input: BigNumber) => {
after: async (beforeInfo: any, _result: FunctionResult, _input: BigNumber) => {
sideEffectTarget = beforeInfo;
},
});
@@ -69,7 +69,7 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => {
it('should pass the result from the function call to "after"', async () => {
let sideEffectTarget = ZERO_AMOUNT;
const assertion = new FunctionAssertion(exampleContract.returnInteger, {
after: async (_beforeInfo: any, result: Result, _input: BigNumber) => {
after: async (_beforeInfo: any, result: FunctionResult, _input: BigNumber) => {
sideEffectTarget = result.data;
},
});
@@ -81,7 +81,7 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => {
it('should pass the receipt from the function call to "after"', async () => {
let sideEffectTarget: TransactionReceiptWithDecodedLogs;
const assertion = new FunctionAssertion(exampleContract.emitEvent, {
after: async (_beforeInfo: any, result: Result, _input: string) => {
after: async (_beforeInfo: any, result: FunctionResult, _input: string) => {
if (result.receipt) {
sideEffectTarget = result.receipt;
}
@@ -102,7 +102,7 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => {
it('should pass the error to "after" if the function call fails', async () => {
let sideEffectTarget: Error;
const assertion = new FunctionAssertion(exampleContract.stringRevert, {
after: async (_beforeInfo: any, result: Result, _input: string) => {
after: async (_beforeInfo: any, result: FunctionResult, _input: string) => {
sideEffectTarget = result.data;
},
});