@@ -10,6 +10,7 @@ import (
10
10
"github.com/ovrclk/akash/app/order"
11
11
"github.com/ovrclk/akash/app/provider"
12
12
apptypes "github.com/ovrclk/akash/app/types"
13
+ "github.com/ovrclk/akash/keys"
13
14
"github.com/ovrclk/akash/query"
14
15
pstate "github.com/ovrclk/akash/state"
15
16
"github.com/ovrclk/akash/testutil"
@@ -62,7 +63,7 @@ func TestCreateTx(t *testing.T) {
62
63
}
63
64
64
65
{
65
- path := query .DeploymentGroupPath (depl . Address , groupseq )
66
+ path := query .DeploymentGroupPath (groups . Items [ 0 ]. DeploymentGroupID )
66
67
resp := app .Query (tmtypes.RequestQuery {Path : path })
67
68
assert .Empty (t , resp .Log )
68
69
require .True (t , resp .IsOK ())
@@ -81,24 +82,31 @@ func TestCreateTx(t *testing.T) {
81
82
require .True (t , resp .IsOK ())
82
83
}
83
84
85
+ badgroup := types.DeploymentGroupID {
86
+ Deployment : depl .Address ,
87
+ Seq : 2 ,
88
+ }
89
+
90
+ goodgroup := groups .GetItems ()[0 ].DeploymentGroupID
91
+
84
92
{
85
- path := fmt .Sprintf ("%v%x " ,
93
+ path := fmt .Sprintf ("%v%v " ,
86
94
pstate .DeploymentPath ,
87
- pstate .DeploymentGroupID (depl . Address , 1 ))
95
+ keys .DeploymentGroupID (badgroup ). Path ( ))
88
96
resp := app .Query (tmtypes.RequestQuery {Path : path })
89
97
assert .NotEmpty (t , resp .Log )
90
98
require .False (t , resp .IsOK ())
91
99
}
92
100
93
101
{
94
- path := query .DeploymentGroupPath (depl . Address , 1 )
102
+ path := query .DeploymentGroupPath (goodgroup )
95
103
resp := app .Query (tmtypes.RequestQuery {Path : path })
96
104
assert .Empty (t , resp .Log )
97
105
require .True (t , resp .IsOK ())
98
106
}
99
107
100
108
{
101
- path := query .DeploymentGroupPath (depl . Address , 0 )
109
+ path := query .DeploymentGroupPath (badgroup )
102
110
resp := app .Query (tmtypes.RequestQuery {Path : path })
103
111
assert .NotEmpty (t , resp .Log )
104
112
require .False (t , resp .IsOK ())
@@ -129,20 +137,21 @@ func TestTx_BadTxType(t *testing.T) {
129
137
}
130
138
131
139
func TestCloseTx_1 (t * testing.T ) {
132
- const gseq = 1
133
140
state := testutil .NewState (t , nil )
134
141
app , err := deployment .NewApp (state , testutil .Logger ())
135
142
require .NoError (t , err )
136
143
account , key := testutil .CreateAccount (t , state )
137
144
nonce := uint64 (1 )
138
145
139
- depl , _ := testutil .CreateDeployment (t , app , account , key , nonce )
146
+ depl , groups := testutil .CreateDeployment (t , app , account , key , nonce )
147
+
148
+ group := groups .Items [0 ]
140
149
141
150
check := func (
142
151
dstate types.Deployment_DeploymentState ,
143
152
gstate types.DeploymentGroup_DeploymentGroupState ) {
144
153
assertDeploymentState (t , app , depl .Address , dstate )
145
- assertDeploymentGroupState (t , app , depl . Address , gseq , gstate )
154
+ assertDeploymentGroupState (t , app , group . DeploymentGroupID , gstate )
146
155
}
147
156
148
157
check (types .Deployment_ACTIVE , types .DeploymentGroup_OPEN )
@@ -155,7 +164,6 @@ func TestCloseTx_1(t *testing.T) {
155
164
func TestCloseTx_2 (t * testing.T ) {
156
165
157
166
const (
158
- gseq = 1
159
167
oseq = 3
160
168
)
161
169
@@ -165,20 +173,21 @@ func TestCloseTx_2(t *testing.T) {
165
173
account , key := testutil .CreateAccount (t , state )
166
174
nonce := uint64 (1 )
167
175
168
- depl , _ := testutil .CreateDeployment (t , app , account , key , nonce )
176
+ depl , groups := testutil .CreateDeployment (t , app , account , key , nonce )
177
+ group := groups .Items [0 ]
169
178
170
179
oapp , err := order .NewApp (state , testutil .Logger ())
171
180
require .NoError (t , err )
172
181
173
- testutil .CreateOrder (t , oapp , account , key , depl .Address , gseq , oseq )
182
+ order := testutil .CreateOrder (t , oapp , account , key , depl .Address , group . Seq , oseq )
174
183
175
184
check := func (
176
185
dstate types.Deployment_DeploymentState ,
177
186
gstate types.DeploymentGroup_DeploymentGroupState ,
178
187
ostate types.Order_OrderState ) {
179
188
assertDeploymentState (t , app , depl .Address , dstate )
180
- assertDeploymentGroupState (t , app , depl . Address , gseq , gstate )
181
- assertOrderState (t , oapp , depl . Address , gseq , oseq , ostate )
189
+ assertDeploymentGroupState (t , app , order . GroupID () , gstate )
190
+ assertOrderState (t , oapp , order . OrderID , ostate )
182
191
}
183
192
184
193
check (types .Deployment_ACTIVE , types .DeploymentGroup_OPEN , types .Order_OPEN )
@@ -191,7 +200,6 @@ func TestCloseTx_2(t *testing.T) {
191
200
func TestCloseTx_3 (t * testing.T ) {
192
201
193
202
const (
194
- gseq = 1
195
203
oseq = 3
196
204
price = 0
197
205
)
@@ -201,27 +209,28 @@ func TestCloseTx_3(t *testing.T) {
201
209
require .NoError (t , err )
202
210
account , key := testutil .CreateAccount (t , state )
203
211
nonce := uint64 (1 )
204
- depl , _ := testutil .CreateDeployment (t , app , account , key , nonce )
212
+ depl , groups := testutil .CreateDeployment (t , app , account , key , nonce )
213
+ group := groups .Items [0 ]
205
214
206
215
orderapp , err := order .NewApp (state , testutil .Logger ())
207
216
require .NoError (t , err )
208
- testutil .CreateOrder (t , orderapp , account , key , depl .Address , gseq , oseq )
217
+ order := testutil .CreateOrder (t , orderapp , account , key , depl .Address , group . Seq , oseq )
209
218
210
219
providerapp , err := provider .NewApp (state , testutil .Logger ())
211
220
prov := testutil .CreateProvider (t , providerapp , account , key , nonce )
212
221
213
222
fulfillmentapp , err := fulfillment .NewApp (state , testutil .Logger ())
214
- testutil .CreateFulfillment (t , fulfillmentapp , prov .Address , key , depl .Address , gseq , oseq , price )
223
+ fulfillment := testutil .CreateFulfillment (t , fulfillmentapp , prov .Address , key , depl .Address , group . Seq , order . Seq , price )
215
224
216
225
check := func (
217
226
dstate types.Deployment_DeploymentState ,
218
227
gstate types.DeploymentGroup_DeploymentGroupState ,
219
228
ostate types.Order_OrderState ,
220
229
fstate types.Fulfillment_FulfillmentState ) {
221
230
assertDeploymentState (t , app , depl .Address , dstate )
222
- assertDeploymentGroupState (t , app , depl . Address , gseq , gstate )
223
- assertOrderState (t , orderapp , depl . Address , gseq , oseq , ostate )
224
- assertFulfillmentState (t , fulfillmentapp , depl . Address , gseq , oseq , prov . Address , fstate )
231
+ assertDeploymentGroupState (t , app , group . DeploymentGroupID , gstate )
232
+ assertOrderState (t , orderapp , order . OrderID , ostate )
233
+ assertFulfillmentState (t , fulfillmentapp , fulfillment . FulfillmentID , fstate )
225
234
}
226
235
227
236
check (types .Deployment_ACTIVE , types .DeploymentGroup_OPEN , types .Order_OPEN , types .Fulfillment_OPEN )
@@ -248,16 +257,16 @@ func TestCloseTx_4(t *testing.T) {
248
257
249
258
orderapp , err := order .NewApp (state , testutil .Logger ())
250
259
require .NoError (t , err )
251
- testutil .CreateOrder (t , orderapp , account , key , depl .Address , gseq , oseq )
260
+ order := testutil .CreateOrder (t , orderapp , account , key , depl .Address , gseq , oseq )
252
261
253
262
providerapp , err := provider .NewApp (state , testutil .Logger ())
254
263
prov := testutil .CreateProvider (t , providerapp , account , key , nonce )
255
264
256
265
fulfillmentapp , err := fulfillment .NewApp (state , testutil .Logger ())
257
- testutil .CreateFulfillment (t , fulfillmentapp , prov .Address , key , depl .Address , gseq , oseq , price )
266
+ fulfillment := testutil .CreateFulfillment (t , fulfillmentapp , prov .Address , key , depl .Address , gseq , oseq , price )
258
267
259
268
leaseapp , err := lease .NewApp (state , testutil .Logger ())
260
- testutil .CreateLease (t , leaseapp , prov .Address , key , depl .Address , gseq , oseq , price )
269
+ lease := testutil .CreateLease (t , leaseapp , prov .Address , key , depl .Address , gseq , oseq , price )
261
270
262
271
check := func (
263
272
dstate types.Deployment_DeploymentState ,
@@ -266,10 +275,10 @@ func TestCloseTx_4(t *testing.T) {
266
275
fstate types.Fulfillment_FulfillmentState ,
267
276
lstate types.Lease_LeaseState ) {
268
277
assertDeploymentState (t , app , depl .Address , dstate )
269
- assertDeploymentGroupState (t , app , depl . Address , gseq , gstate )
270
- assertOrderState (t , orderapp , depl . Address , gseq , oseq , ostate )
271
- assertFulfillmentState (t , fulfillmentapp , depl . Address , gseq , oseq , prov . Address , fstate )
272
- assertLeaseState (t , leaseapp , depl . Address , gseq , oseq , prov . Address , lstate )
278
+ assertDeploymentGroupState (t , app , order . GroupID () , gstate )
279
+ assertOrderState (t , orderapp , order . OrderID , ostate )
280
+ assertFulfillmentState (t , fulfillmentapp , fulfillment . FulfillmentID , fstate )
281
+ assertLeaseState (t , leaseapp , lease . LeaseID , lstate )
273
282
}
274
283
275
284
check (types .Deployment_ACTIVE , types .DeploymentGroup_OPEN , types .Order_MATCHED , types .Fulfillment_OPEN , types .Lease_ACTIVE )
@@ -301,11 +310,10 @@ func assertDeploymentState(
301
310
func assertDeploymentGroupState (
302
311
t * testing.T ,
303
312
app apptypes.Application ,
304
- daddr []byte ,
305
- gseq uint64 ,
313
+ id types.DeploymentGroupID ,
306
314
gstate types.DeploymentGroup_DeploymentGroupState ) {
307
315
308
- path := query .DeploymentGroupPath (daddr , gseq )
316
+ path := query .DeploymentGroupPath (id )
309
317
resp := app .Query (tmtypes.RequestQuery {Path : path })
310
318
assert .Empty (t , resp .Log )
311
319
require .True (t , resp .IsOK ())
@@ -319,12 +327,10 @@ func assertDeploymentGroupState(
319
327
func assertOrderState (
320
328
t * testing.T ,
321
329
app apptypes.Application ,
322
- daddr []byte ,
323
- gseq uint64 ,
324
- oseq uint64 ,
330
+ id types.OrderID ,
325
331
ostate types.Order_OrderState ) {
326
332
327
- path := query .OrderPath (daddr , gseq , oseq )
333
+ path := query .OrderPath (id )
328
334
resp := app .Query (tmtypes.RequestQuery {Path : path })
329
335
assert .Empty (t , resp .Log )
330
336
require .True (t , resp .IsOK ())
@@ -337,13 +343,10 @@ func assertOrderState(
337
343
func assertFulfillmentState (
338
344
t * testing.T ,
339
345
app apptypes.Application ,
340
- daddr []byte ,
341
- gseq uint64 ,
342
- oseq uint64 ,
343
- paddr []byte ,
346
+ id types.FulfillmentID ,
344
347
state types.Fulfillment_FulfillmentState ) {
345
348
346
- path := query .FulfillmentPath (daddr , gseq , oseq , paddr )
349
+ path := query .FulfillmentPath (id )
347
350
resp := app .Query (tmtypes.RequestQuery {Path : path })
348
351
assert .Empty (t , resp .Log )
349
352
require .True (t , resp .IsOK ())
@@ -356,14 +359,11 @@ func assertFulfillmentState(
356
359
func assertLeaseState (
357
360
t * testing.T ,
358
361
app apptypes.Application ,
359
- daddr []byte ,
360
- gseq uint64 ,
361
- oseq uint64 ,
362
- paddr []byte ,
362
+ id types.LeaseID ,
363
363
state types.Lease_LeaseState ) {
364
364
365
365
// check fulfillment state
366
- path := query .LeasePath (daddr , gseq , oseq , paddr )
366
+ path := query .LeasePath (id )
367
367
resp := app .Query (tmtypes.RequestQuery {Path : path })
368
368
assert .Empty (t , resp .Log )
369
369
require .True (t , resp .IsOK ())
0 commit comments