@@ -136,3 +136,142 @@ describe("Test Interface", function() {
136136 assert . equal ( log . args [ 2 ] , BigInt ( 234 ) ) ;
137137 } ) ;
138138} ) ;
139+
140+ describe ( "Tests Legacy ABI formats" , function ( ) {
141+
142+ // See: #3932
143+ const iface = new Interface ( [
144+ {
145+ name : "implicitView" ,
146+ outputs : [ ] ,
147+ inputs : [
148+ { type : "int128" , name : "arg0" }
149+ ] ,
150+ "constant" : true ,
151+ "payable" : false ,
152+ "type" : "function"
153+ } ,
154+ {
155+ name : "implicitSendNonpay" ,
156+ outputs : [ ] ,
157+ inputs : [
158+ { type : "int128" , name : "arg0" }
159+ ] ,
160+ "constant" : false ,
161+ "payable" : false ,
162+ "type" : "function"
163+ } ,
164+ {
165+ name : "implicitSendPay" ,
166+ outputs : [ ] ,
167+ inputs : [
168+ { type : "int128" , name : "arg0" }
169+ ] ,
170+ "constant" : false ,
171+ "payable" : true ,
172+ "type" : "function"
173+ } ,
174+ {
175+ name : "implicitSendImplicitPay" ,
176+ outputs : [ ] ,
177+ inputs : [
178+ { type : "int128" , name : "arg0" }
179+ ] ,
180+ "constant" : false ,
181+ "type" : "function"
182+ } ,
183+ {
184+ name : "implicitSendExplicitPay" ,
185+ outputs : [ ] ,
186+ inputs : [
187+ { type : "int128" , name : "arg0" }
188+ ] ,
189+ payable : true ,
190+ type : "function"
191+ } ,
192+ {
193+ name : "implicitSendExplicitNonpay" ,
194+ outputs : [ ] ,
195+ inputs : [
196+ { type : "int128" , name : "arg0" }
197+ ] ,
198+ payable : false ,
199+ type : "function"
200+ } ,
201+ {
202+ name : "implicitAll" ,
203+ outputs : [ ] ,
204+ inputs : [
205+ { type : "int128" , name : "arg0" }
206+ ] ,
207+ "type" : "function"
208+ } ,
209+ {
210+ name : "explicitView" ,
211+ outputs : [ ] ,
212+ inputs : [
213+ { type : "int128" , name : "arg0" }
214+ ] ,
215+ "stateMutability" : "view" ,
216+ "constant" : true ,
217+ "payable" : false ,
218+ "type" : "function"
219+ } ,
220+ {
221+ name : "explicitPure" ,
222+ outputs : [ ] ,
223+ inputs : [
224+ { type : "int128" , name : "arg0" }
225+ ] ,
226+ "stateMutability" : "pure" ,
227+ "constant" : true ,
228+ "payable" : false ,
229+ "type" : "function"
230+ } ,
231+ {
232+ name : "explicitPay" ,
233+ outputs : [ ] ,
234+ inputs : [
235+ { type : "int128" , name : "arg0" }
236+ ] ,
237+ "stateMutability" : "payable" ,
238+ "constant" : true ,
239+ "payable" : true ,
240+ "type" : "function"
241+ } ,
242+ {
243+ name : "explicitNonpay" ,
244+ outputs : [ ] ,
245+ inputs : [
246+ { type : "int128" , name : "arg0" }
247+ ] ,
248+ "stateMutability" : "nonpayable" ,
249+ "constant" : true ,
250+ "payable" : false ,
251+ "type" : "function"
252+ } ,
253+ ] ) ;
254+
255+ function test ( name : string , isConst : boolean , payable : boolean , stateMutability : string ) : void {
256+ it ( `tests ABI configuration: ${ name } ` , function ( ) {
257+ const f = iface . getFunction ( name ) ;
258+ assert . ok ( ! ! f , `missing ${ name } ` ) ;
259+ assert . equal ( f . constant , isConst , `${ name } .constant` ) ;
260+ assert . equal ( f . stateMutability , stateMutability , `${ name } .stateMutability` ) ;
261+ assert . equal ( f . payable , payable , `${ name } .payable` ) ;
262+ } ) ;
263+ }
264+
265+ test ( "explicitView" , true , false , "view" ) ;
266+ test ( "explicitPure" , true , false , "pure" ) ;
267+ test ( "explicitPay" , false , true , "payable" ) ;
268+ test ( "explicitNonpay" , false , false , "nonpayable" ) ;
269+
270+ test ( "implicitView" , true , false , "view" ) ;
271+ test ( "implicitSendNonpay" , false , false , "nonpayable" ) ;
272+ test ( "implicitSendPay" , false , true , "payable" ) ;
273+ test ( "implicitSendImplicitPay" , false , true , "payable" ) ;
274+ test ( "implicitSendExplicitPay" , false , true , "payable" ) ;
275+ test ( "implicitSendExplicitNonpay" , false , false , "nonpayable" ) ;
276+ test ( "implicitAll" , false , true , "payable" ) ;
277+ } ) ;
0 commit comments