Skip to content

Commit c0ab841

Browse files
committed
test: more flexibility on OLAS testing
1 parent cf4bd0e commit c0ab841

File tree

1 file changed

+28
-19
lines changed

1 file changed

+28
-19
lines changed

integration/external/Olas.e2e.test.ts

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ describe('OLAS e2e tests', () => {
2626
const OLAS_MARKETPLACE_ADDRESS: string = process.env.OLAS_MARKETPLACE_ADDRESS || ZeroAddress
2727
const TOKEN_ADDRESS: string = process.env.TOKEN_ADDRESS || ZeroAddress
2828

29+
const PLAN_DID = process.env.PLAN_DID || undefined
30+
const USE_EXISTING_PLAN = PLAN_DID && PLAN_DID.startsWith('did:nv')
31+
2932
let IS_NATIVE_TOKEN = false
3033

3134
// 10000
@@ -144,28 +147,33 @@ describe('OLAS e2e tests', () => {
144147
subscriptionNFT = await nevermined.contracts.loadNft1155(SUBSCRIPTION_NFT_ADDRESS)
145148

146149
console.debug(`Using Subscription NFT address: ${subscriptionNFT.address}`)
147-
148150
assert.equal(nevermined.nfts1155.getContract.address, subscriptionNFT.address)
149151

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+
166174
assert.isDefined(subscriptionDDO)
167175
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}`)
169177
})
170178

171179
it('should grant Nevermined the operator role', async () => {
@@ -181,7 +189,8 @@ describe('OLAS e2e tests', () => {
181189
describe('As a subscriber I want to buy the OLAS plan', () => {
182190
it('I check the details of the subscription NFT', async () => {
183191
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())
185194
})
186195

187196
it('I am ordering the subscription NFT', async () => {

0 commit comments

Comments
 (0)