rename Result -> FunctionResult
This commit is contained in:
		@@ -12,7 +12,7 @@ export interface ContractWrapperFunction extends ContractGetterFunction {
 | 
				
			|||||||
    awaitTransactionSuccessAsync?: (...args: any[]) => PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>;
 | 
					    awaitTransactionSuccessAsync?: (...args: any[]) => PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface Result {
 | 
					export interface FunctionResult {
 | 
				
			||||||
    data?: any;
 | 
					    data?: any;
 | 
				
			||||||
    success: boolean;
 | 
					    success: boolean;
 | 
				
			||||||
    receipt?: TransactionReceiptWithDecodedLogs;
 | 
					    receipt?: TransactionReceiptWithDecodedLogs;
 | 
				
			||||||
@@ -30,7 +30,7 @@ export interface Result {
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
export interface Condition<TBefore> {
 | 
					export interface Condition<TBefore> {
 | 
				
			||||||
    before: (...args: any[]) => Promise<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>;
 | 
					    executeAsync: (...args: any[]) => Promise<any>;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface RunResult {
 | 
					export interface AssertionResult {
 | 
				
			||||||
    beforeInfo: any;
 | 
					    beforeInfo: any;
 | 
				
			||||||
    afterInfo: 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.
 | 
					     * Runs the wrapped function and fails if the before or after assertions fail.
 | 
				
			||||||
     * @param ...args The args to the contract wrapper function.
 | 
					     * @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.
 | 
					        // Call the before condition.
 | 
				
			||||||
        const beforeInfo = await this.condition.before(...args);
 | 
					        const beforeInfo = await this.condition.before(...args);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Initialize the callResult so that the default success value is true.
 | 
					        // 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
 | 
					        // Try to make the call to the function. If it is successful, pass the
 | 
				
			||||||
        // result and receipt to the after condition.
 | 
					        // result and receipt to the after condition.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@ import { blockchainTests, constants, expect, filterLogsToArguments, getRandomInt
 | 
				
			|||||||
import { BigNumber, StringRevertError } from '@0x/utils';
 | 
					import { BigNumber, StringRevertError } from '@0x/utils';
 | 
				
			||||||
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
 | 
					import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { FunctionAssertion, Result } from '../../src/function_assertions';
 | 
					import { FunctionAssertion, FunctionResult } from '../../src/function_assertions';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { artifacts } from '../artifacts';
 | 
					import { artifacts } from '../artifacts';
 | 
				
			||||||
import { TestFrameworkContract, TestFrameworkEventEventArgs, TestFrameworkEvents } from '../wrappers';
 | 
					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 () => {
 | 
					        it('should call the after function with the provided arguments', async () => {
 | 
				
			||||||
            let sideEffectTarget = ZERO_AMOUNT;
 | 
					            let sideEffectTarget = ZERO_AMOUNT;
 | 
				
			||||||
            const assertion = new FunctionAssertion(exampleContract.returnInteger, {
 | 
					            const assertion = new FunctionAssertion(exampleContract.returnInteger, {
 | 
				
			||||||
                after: async (_beforeInfo: any, _result: Result, input: BigNumber) => {
 | 
					                after: async (_beforeInfo: any, _result: FunctionResult, input: BigNumber) => {
 | 
				
			||||||
                    sideEffectTarget = input;
 | 
					                    sideEffectTarget = input;
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
@@ -58,7 +58,7 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => {
 | 
				
			|||||||
                before: async (_input: BigNumber) => {
 | 
					                before: async (_input: BigNumber) => {
 | 
				
			||||||
                    return randomInput;
 | 
					                    return randomInput;
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                after: async (beforeInfo: any, _result: Result, _input: BigNumber) => {
 | 
					                after: async (beforeInfo: any, _result: FunctionResult, _input: BigNumber) => {
 | 
				
			||||||
                    sideEffectTarget = beforeInfo;
 | 
					                    sideEffectTarget = beforeInfo;
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
@@ -69,7 +69,7 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => {
 | 
				
			|||||||
        it('should pass the result from the function call to "after"', async () => {
 | 
					        it('should pass the result from the function call to "after"', async () => {
 | 
				
			||||||
            let sideEffectTarget = ZERO_AMOUNT;
 | 
					            let sideEffectTarget = ZERO_AMOUNT;
 | 
				
			||||||
            const assertion = new FunctionAssertion(exampleContract.returnInteger, {
 | 
					            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;
 | 
					                    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 () => {
 | 
					        it('should pass the receipt from the function call to "after"', async () => {
 | 
				
			||||||
            let sideEffectTarget: TransactionReceiptWithDecodedLogs;
 | 
					            let sideEffectTarget: TransactionReceiptWithDecodedLogs;
 | 
				
			||||||
            const assertion = new FunctionAssertion(exampleContract.emitEvent, {
 | 
					            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) {
 | 
					                    if (result.receipt) {
 | 
				
			||||||
                        sideEffectTarget = 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 () => {
 | 
					        it('should pass the error to "after" if the function call fails', async () => {
 | 
				
			||||||
            let sideEffectTarget: Error;
 | 
					            let sideEffectTarget: Error;
 | 
				
			||||||
            const assertion = new FunctionAssertion(exampleContract.stringRevert, {
 | 
					            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;
 | 
					                    sideEffectTarget = result.data;
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user