@@ -4,17 +4,10 @@ import (
44 "fmt"
55 "testing"
66
7- dapp "github.com/ovrclk/akash/app/deployment"
8- fapp "github.com/ovrclk/akash/app/fulfillment"
97 app_ "github.com/ovrclk/akash/app/lease"
10- oapp "github.com/ovrclk/akash/app/order"
11- papp "github.com/ovrclk/akash/app/provider"
128 apptypes "github.com/ovrclk/akash/app/types"
13- "github.com/ovrclk/akash/query"
149 state_ "github.com/ovrclk/akash/state"
1510 "github.com/ovrclk/akash/testutil"
16- "github.com/ovrclk/akash/types"
17- "github.com/ovrclk/akash/types/base"
1811 "github.com/stretchr/testify/assert"
1912 "github.com/stretchr/testify/require"
2013 tmtypes "github.com/tendermint/tendermint/abci/types"
@@ -40,71 +33,6 @@ func TestAcceptQuery(t *testing.T) {
4033 }
4134}
4235
43- func TestValidTx (t * testing.T ) {
44-
45- _ , cacheState := testutil .NewState (t , nil )
46- app , err := app_ .NewApp (testutil .Logger ())
47-
48- // create provider
49- papp , err := papp .NewApp (testutil .Logger ())
50- require .NoError (t , err )
51- paccount , pkey := testutil .CreateAccount (t , cacheState )
52- pnonce := uint64 (1 )
53- provider := testutil .CreateProvider (t , cacheState , papp , paccount , pkey , pnonce )
54-
55- // create tenant
56- taccount , tkey := testutil .CreateAccount (t , cacheState )
57-
58- // create deployment
59- dapp , err := dapp .NewApp (testutil .Logger ())
60- require .NoError (t , err )
61- tnonce := uint64 (1 )
62- testutil .CreateDeployment (t , cacheState , dapp , taccount , tkey , tnonce )
63- groupSeq := uint64 (1 )
64- daddress := state_ .DeploymentAddress (taccount .Address , tnonce )
65-
66- // create order
67- oapp , err := oapp .NewApp (testutil .Logger ())
68- require .NoError (t , err )
69- oSeq := uint64 (0 )
70- testutil .CreateOrder (t , cacheState , oapp , taccount , tkey , daddress , groupSeq , oSeq )
71- price := uint64 (1 )
72-
73- // create fulfillment
74- fapp , err := fapp .NewApp (testutil .Logger ())
75- testutil .CreateFulfillment (t , cacheState , fapp , provider .Address , pkey , daddress , groupSeq , oSeq , price )
76-
77- // create lease
78- lease := testutil .CreateLease (t , cacheState , app , provider .Address , pkey , daddress , groupSeq , oSeq , price )
79-
80- {
81- path := query .LeasePath (lease .LeaseID )
82- resp := app .Query (cacheState , tmtypes.RequestQuery {Path : path })
83- assert .Empty (t , resp .Log )
84- require .True (t , resp .IsOK ())
85- lea := new (types.Lease )
86- require .NoError (t , lea .Unmarshal (resp .Value ))
87- assert .Equal (t , lease .Deployment , lea .Deployment )
88- assert .Equal (t , lease .Group , lea .Group )
89- assert .Equal (t , lease .Order , lea .Order )
90- assert .Equal (t , lease .Provider , lea .Provider )
91- assert .Equal (t , lease .Price , lea .Price )
92- assert .Equal (t , types .Lease_ACTIVE , lea .State )
93- }
94-
95- // close lease
96- testutil .CloseLease (t , cacheState , app , lease .LeaseID , pkey )
97- {
98- path := query .LeasePath (lease .LeaseID )
99- resp := app .Query (cacheState , tmtypes.RequestQuery {Path : path })
100- assert .Empty (t , resp .Log )
101- require .True (t , resp .IsOK ())
102- lea := new (types.Lease )
103- require .NoError (t , lea .Unmarshal (resp .Value ))
104- assert .Equal (t , types .Lease_CLOSED , lea .State )
105- }
106- }
107-
10836func TestTx_BadTxType (t * testing.T ) {
10937 _ , cacheState := testutil .NewState (t , nil )
11038 app , err := app_ .NewApp (testutil .Logger ())
@@ -118,61 +46,3 @@ func TestTx_BadTxType(t *testing.T) {
11846 dresp := app .DeliverTx (cacheState , ctx , tx .Payload .Payload )
11947 assert .False (t , dresp .IsOK ())
12048}
121-
122- func TestBilling (t * testing.T ) {
123-
124- _ , cacheState := testutil .NewState (t , nil )
125- app , err := app_ .NewApp (testutil .Logger ())
126-
127- // create provider
128- papp , err := papp .NewApp (testutil .Logger ())
129- require .NoError (t , err )
130- paccount , pkey := testutil .CreateAccount (t , cacheState )
131- pnonce := uint64 (1 )
132- provider := testutil .CreateProvider (t , cacheState , papp , paccount , pkey , pnonce )
133-
134- // create tenant
135- tenant , tkey := testutil .CreateAccount (t , cacheState )
136-
137- // create deployment
138- dapp , err := dapp .NewApp (testutil .Logger ())
139- require .NoError (t , err )
140- tnonce := uint64 (1 )
141- testutil .CreateDeployment (t , cacheState , dapp , tenant , tkey , tnonce )
142- groupSeq := uint64 (1 )
143- daddress := state_ .DeploymentAddress (tenant .Address , tnonce )
144-
145- // create order
146- oapp , err := oapp .NewApp (testutil .Logger ())
147- require .NoError (t , err )
148- oSeq := uint64 (0 )
149- testutil .CreateOrder (t , cacheState , oapp , tenant , tkey , daddress , groupSeq , oSeq )
150- price := uint64 (1 )
151- p := uint64 (price )
152-
153- // create fulfillment
154- fapp , err := fapp .NewApp (testutil .Logger ())
155- testutil .CreateFulfillment (t , cacheState , fapp , provider .Address , pkey , daddress , groupSeq , oSeq , price )
156-
157- // create lease
158- testutil .CreateLease (t , cacheState , app , provider .Address , pkey , daddress , groupSeq , oSeq , price )
159-
160- iTenBal := getBalance (t , cacheState , tenant .Address )
161- iProBal := getBalance (t , cacheState , provider .Owner )
162- require .NotZero (t , iTenBal )
163- require .NotZero (t , iProBal )
164-
165- err = app_ .ProcessLeases (cacheState )
166- require .NoError (t , err )
167-
168- fTenBal := getBalance (t , cacheState , tenant .Address )
169- fProBal := getBalance (t , cacheState , provider .Owner )
170- require .Equal (t , iTenBal - p , fTenBal )
171- require .Equal (t , iProBal + p , fProBal )
172- }
173-
174- func getBalance (t * testing.T , state state_.State , address base.Bytes ) uint64 {
175- acc , err := state .Account ().Get (address )
176- require .NoError (t , err )
177- return acc .GetBalance ()
178- }
0 commit comments