| 48 | |
| 49 | |
| 50 | export class TestEnvironment { |
| 51 | public elementaryValuesGetter: ElementaryValuesGetter; |
| 52 | protected getCallWithAssignment?( |
| 53 | contactName: string, |
| 54 | fn: string, |
| 55 | inputs: string[], |
| 56 | outputs: string[], |
| 57 | forceDestructuring?: boolean |
| 58 | ): ArrayJoinInput<string>; |
| 59 | |
| 60 | constructor( |
| 61 | elementaryValuesGetter: ElementaryValuesGetter, |
| 62 | // getCallWithAssignment: ( |
| 63 | // contactName: string, |
| 64 | // fn: string, |
| 65 | // inputs: string[], |
| 66 | // outputs: string[] |
| 67 | // ) => ArrayJoinInput<string> |
| 68 | ) { |
| 69 | this.elementaryValuesGetter = elementaryValuesGetter |
| 70 | // this.getCallWithAssignment = getCallWithAssignment.bind(this) |
| 71 | } |
| 72 | |
| 73 | getFieldValue = (field: ProcessedField, kind: TestValueKind) => { |
| 74 | if (field.type.meta === 'elementary') { |
| 75 | if (field.type.type === 'byte' || field.type.type === 'bytes') { |
| 76 | throw Error('bytes not supported for automatic testing yet') |
| 77 | } |
| 78 | return this.elementaryValuesGetter[field.type.type][kind](field.type.size); |
| 79 | } |
| 80 | if (field.type.meta === 'enum') { |
| 81 | return this.elementaryValuesGetter.uint[kind](field.type.size); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | findGetterOrSetterForFields( |
| 86 | struct: ProcessedStruct, |
| 87 | fields: ProcessedField[], |
| 88 | fn: CodeGenFunction, |
| 89 | contractName: string, |
| 90 | type: getter |
| 91 | ): GetterFn; |
| 92 | findGetterOrSetterForFields( |
| 93 | struct: ProcessedStruct, |
| 94 | fields: ProcessedField[], |
| 95 | fn: CodeGenFunction, |
| 96 | contractName: string, |
| 97 | type: setter |
| 98 | ): SetterFn; |
| 99 | findGetterOrSetterForFields( |
| 100 | struct: ProcessedStruct, |
| 101 | fields: ProcessedField[], |
| 102 | fn: CodeGenFunction, |
| 103 | contractName: string, |
| 104 | type: GetterOrSetter |
| 105 | ): GetterFn | SetterFn { |
| 106 | const group = struct.groups.find(g => `${type === 'getter' ? 'get' : 'set'}${g.name.toPascalCase()}` === fn.name); |
| 107 | const generateParamName = `generate${type.toPascalCase()}` |
nothing calls this directly
no outgoing calls
no test coverage detected