@@ -83,3 +83,139 @@ func TestListOutputsParamsExecutedIsOptional(t *testing.T) {
8383 require .NotNil (t , pending .Executed )
8484 require .False (t , * pending .Executed )
8585}
86+
87+ func TestPositionalParamsDeclarationOrder (t * testing.T ) {
88+ tests := map [string ]struct {
89+ newTarget func () any
90+ positional string
91+ named string
92+ }{
93+ "ListApplicationsParams" : {
94+ func () any { return & ListApplicationsParams {} },
95+ `[25,3,true]` ,
96+ `{"limit":25,"offset":3,"descending":true}` ,
97+ },
98+ "GetApplicationParams" : {
99+ func () any { return & GetApplicationParams {} },
100+ `["app"]` ,
101+ `{"application":"app"}` ,
102+ },
103+ "ListEpochsParams" : {
104+ func () any { return & ListEpochsParams {} },
105+ `["app",["OPEN","CLOSED"],25,3,true,"0x2","0x9"]` ,
106+ `{"application":"app","status":["OPEN","CLOSED"],"limit":25,"offset":3,"descending":true,"from":"0x2","to":"0x9"}` ,
107+ },
108+ "GetEpochParams" : {
109+ func () any { return & GetEpochParams {} },
110+ `["app","0x4"]` ,
111+ `{"application":"app","epoch_index":"0x4"}` ,
112+ },
113+ "GetEpochByVirtualIndexParams" : {
114+ func () any { return & GetEpochByVirtualIndexParams {} },
115+ `["app","0x7"]` ,
116+ `{"application":"app","virtual_index":"0x7"}` ,
117+ },
118+ "GetLastAcceptedEpochIndexParams" : {
119+ func () any { return & GetLastAcceptedEpochIndexParams {} },
120+ `["app"]` ,
121+ `{"application":"app"}` ,
122+ },
123+ "ListInputsParams" : {
124+ func () any { return & ListInputsParams {} },
125+ `["app","0x4","sender","transaction-hash",25,3,true,"0x2","0x9"]` ,
126+ `{"application":"app","epoch_index":"0x4","sender":"sender","transaction_hash":"transaction-hash","limit":25,"offset":3,"descending":true,"from":"0x2","to":"0x9"}` ,
127+ },
128+ "GetInputParams" : {
129+ func () any { return & GetInputParams {} },
130+ `["app","0x5"]` ,
131+ `{"application":"app","input_index":"0x5"}` ,
132+ },
133+ "GetProcessedInputCountParams" : {
134+ func () any { return & GetProcessedInputCountParams {} },
135+ `["app"]` ,
136+ `{"application":"app"}` ,
137+ },
138+ "ListOutputsParams" : {
139+ func () any { return & ListOutputsParams {} },
140+ `["app","0x4","0x5",["0x237a816f","0x10321e8b"],"voucher",25,3,true,"0x2","0x9",true]` ,
141+ `{"application":"app","epoch_index":"0x4","input_index":"0x5","output_type":["0x237a816f","0x10321e8b"],"voucher_address":"voucher","limit":25,"offset":3,"descending":true,"from":"0x2","to":"0x9","executed":true}` ,
142+ },
143+ "GetOutputParams" : {
144+ func () any { return & GetOutputParams {} },
145+ `["app","0x6"]` ,
146+ `{"application":"app","output_index":"0x6"}` ,
147+ },
148+ "ListReportsParams" : {
149+ func () any { return & ListReportsParams {} },
150+ `["app","0x4","0x5",25,3,true,"0x2","0x9"]` ,
151+ `{"application":"app","epoch_index":"0x4","input_index":"0x5","limit":25,"offset":3,"descending":true,"from":"0x2","to":"0x9"}` ,
152+ },
153+ "GetReportParams" : {
154+ func () any { return & GetReportParams {} },
155+ `["app","0x7"]` ,
156+ `{"application":"app","report_index":"0x7"}` ,
157+ },
158+ "ListTournamentsParams" : {
159+ func () any { return & ListTournamentsParams {} },
160+ `["app","0x4","0x2","parent-tournament","parent-match",25,3,true]` ,
161+ `{"application":"app","epoch_index":"0x4","level":"0x2","parent_tournament_address":"parent-tournament","parent_match_id_hash":"parent-match","limit":25,"offset":3,"descending":true}` ,
162+ },
163+ "GetTournamentParams" : {
164+ func () any { return & GetTournamentParams {} },
165+ `["app","tournament"]` ,
166+ `{"application":"app","address":"tournament"}` ,
167+ },
168+ "ListCommitmentsParams" : {
169+ func () any { return & ListCommitmentsParams {} },
170+ `["app","0x4","tournament",25,3,true]` ,
171+ `{"application":"app","epoch_index":"0x4","tournament_address":"tournament","limit":25,"offset":3,"descending":true}` ,
172+ },
173+ "GetCommitmentParams" : {
174+ func () any { return & GetCommitmentParams {} },
175+ `["app","0x4","tournament","commitment"]` ,
176+ `{"application":"app","epoch_index":"0x4","tournament_address":"tournament","commitment":"commitment"}` ,
177+ },
178+ "ListMatchesParams" : {
179+ func () any { return & ListMatchesParams {} },
180+ `["app","0x4","tournament",25,3,true]` ,
181+ `{"application":"app","epoch_index":"0x4","tournament_address":"tournament","limit":25,"offset":3,"descending":true}` ,
182+ },
183+ "GetMatchParams" : {
184+ func () any { return & GetMatchParams {} },
185+ `["app","0x4","tournament","id-hash"]` ,
186+ `{"application":"app","epoch_index":"0x4","tournament_address":"tournament","id_hash":"id-hash"}` ,
187+ },
188+ "ListMatchAdvancesParams" : {
189+ func () any { return & ListMatchAdvancesParams {} },
190+ `["app","0x4","tournament","id-hash",25,3,true]` ,
191+ `{"application":"app","epoch_index":"0x4","tournament_address":"tournament","id_hash":"id-hash","limit":25,"offset":3,"descending":true}` ,
192+ },
193+ "GetMatchAdvanceParams" : {
194+ func () any { return & GetMatchAdvanceParams {} },
195+ `["app","0x4","tournament","id-hash","parent"]` ,
196+ `{"application":"app","epoch_index":"0x4","tournament_address":"tournament","id_hash":"id-hash","parent":"parent"}` ,
197+ },
198+ "ListWithdrawalsParams" : {
199+ func () any { return & ListWithdrawalsParams {} },
200+ `["app","0x8",25,3,true]` ,
201+ `{"application":"app","account_index":"0x8","limit":25,"offset":3,"descending":true}` ,
202+ },
203+ "GetWithdrawalParams" : {
204+ func () any { return & GetWithdrawalParams {} },
205+ `["app","0x8"]` ,
206+ `{"application":"app","account_index":"0x8"}` ,
207+ },
208+ }
209+
210+ for name , test := range tests {
211+ t .Run (name , func (t * testing.T ) {
212+ expected := test .newTarget ()
213+ require .NoError (t , json .Unmarshal ([]byte (test .named ), expected ))
214+
215+ actual := test .newTarget ()
216+ require .NoError (t , UnmarshalParams (json .RawMessage (test .positional ), actual ))
217+
218+ require .Equal (t , expected , actual )
219+ })
220+ }
221+ }
0 commit comments