@@ -26,6 +26,9 @@ describe('OLAS e2e tests', () => {
26
26
const OLAS_MARKETPLACE_ADDRESS : string = process . env . OLAS_MARKETPLACE_ADDRESS || ZeroAddress
27
27
const TOKEN_ADDRESS : string = process . env . TOKEN_ADDRESS || ZeroAddress
28
28
29
+ const PLAN_DID = process . env . PLAN_DID || undefined
30
+ const USE_EXISTING_PLAN = PLAN_DID && PLAN_DID . startsWith ( 'did:nv' )
31
+
29
32
let IS_NATIVE_TOKEN = false
30
33
31
34
// 10000
@@ -144,28 +147,33 @@ describe('OLAS e2e tests', () => {
144
147
subscriptionNFT = await nevermined . contracts . loadNft1155 ( SUBSCRIPTION_NFT_ADDRESS )
145
148
146
149
console . debug ( `Using Subscription NFT address: ${ subscriptionNFT . address } ` )
147
-
148
150
assert . equal ( nevermined . nfts1155 . getContract . address , subscriptionNFT . address )
149
151
150
- const nftAttributes = NFTAttributes . getCreditsSubscriptionInstance ( {
151
- metadata : subscriptionMetadata ,
152
- services : [
153
- {
154
- serviceType : 'nft-sales' ,
155
- price : planPrice ,
156
- nft : { amount : SUBSCRIPTION_CREDITS , nftTransfer } ,
157
- } ,
158
- ] ,
159
- providers : [ neverminedNodeAddress , OLAS_MARKETPLACE_ADDRESS ] ,
160
- nftContractAddress : subscriptionNFT . address ,
161
- preMint,
162
- } )
163
- subscriptionDDO = await nevermined . nfts1155 . create ( nftAttributes , publisher )
164
-
165
- assert . equal ( await subscriptionNFT . balance ( subscriptionDDO . id , publisher . getId ( ) ) , 0n )
152
+ if ( USE_EXISTING_PLAN ) {
153
+ console . log ( `USING PLAN DID PASS BY PARAMETER: ${ PLAN_DID } ` )
154
+ subscriptionDDO = await nevermined . assets . resolve ( PLAN_DID )
155
+ } else {
156
+ console . log ( `PUBLISHING NEW PLAN` )
157
+ const nftAttributes = NFTAttributes . getCreditsSubscriptionInstance ( {
158
+ metadata : subscriptionMetadata ,
159
+ services : [
160
+ {
161
+ serviceType : 'nft-sales' ,
162
+ price : planPrice ,
163
+ nft : { amount : SUBSCRIPTION_CREDITS , nftTransfer } ,
164
+ } ,
165
+ ] ,
166
+ providers : [ neverminedNodeAddress , OLAS_MARKETPLACE_ADDRESS ] ,
167
+ nftContractAddress : subscriptionNFT . address ,
168
+ preMint,
169
+ } )
170
+ subscriptionDDO = await nevermined . nfts1155 . create ( nftAttributes , publisher )
171
+ assert . equal ( await subscriptionNFT . balance ( subscriptionDDO . id , publisher . getId ( ) ) , 0n )
172
+ }
173
+
166
174
assert . isDefined ( subscriptionDDO )
167
175
console . log ( `OLAS Plan DID: ${ subscriptionDDO . id } ` )
168
- console . log ( ` DID Providerss : ${ neverminedNodeAddress } - ${ OLAS_MARKETPLACE_ADDRESS } ` )
176
+ console . log ( ` DID Providers : ${ neverminedNodeAddress } - ${ OLAS_MARKETPLACE_ADDRESS } ` )
169
177
} )
170
178
171
179
it ( 'should grant Nevermined the operator role' , async ( ) => {
@@ -181,7 +189,8 @@ describe('OLAS e2e tests', () => {
181
189
describe ( 'As a subscriber I want to buy the OLAS plan' , ( ) => {
182
190
it ( 'I check the details of the subscription NFT' , async ( ) => {
183
191
const details = await nevermined . nfts1155 . details ( subscriptionDDO . id )
184
- assert . equal ( details . owner , publisher . getId ( ) )
192
+ if ( USE_EXISTING_PLAN ) assert . isDefined ( details . owner )
193
+ else assert . equal ( details . owner , publisher . getId ( ) )
185
194
} )
186
195
187
196
it ( 'I am ordering the subscription NFT' , async ( ) => {
0 commit comments