@0x:contracts-integrations Put final cleaning touches on the function assertion set

This commit is contained in:
Alex Towle 2019-10-30 13:26:29 -07:00
parent 0b3e3ab990
commit dde570706a

View File

@ -28,7 +28,7 @@ export interface Result {
* @param after A function that will be run after a call to the contract wrapper * @param after A function that will be run after a call to the contract wrapper
* function. * function.
*/ */
export interface Condition<TBefore extends any> { 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: Result, ...args: any[]) => Promise<any>;
} }
@ -53,10 +53,8 @@ export interface RunResult {
* This class implements `Assertion` and represents a "Hoare Triple" that can be * This class implements `Assertion` and represents a "Hoare Triple" that can be
* executed. * executed.
*/ */
export class FunctionAssertion<TBefore extends any> implements Assertion { export class FunctionAssertion<TBefore> implements Assertion {
// A condition that will be applied to `wrapperFunction`. // A condition that will be applied to `wrapperFunction`.
// Note: `TBefore | undefined` is used because the `before` and `after` functions
// are optional in `Condition`.
public condition: Condition<TBefore>; public condition: Condition<TBefore>;
// The wrapper function that will be wrapped in assertions. // The wrapper function that will be wrapped in assertions.