git.delta.rocks / unique-network / refs/commits / 2fcc0ad3d6a7

difftreelog

test forbid creating ApiPromise without set endpoint

Yaroslav Bolyukin2023-09-11parent: #348c8c0.patch.diff
in: master

4 files changed

modifiedtests/src/.outdated/substrate/substrate-api.tsdiffbeforeafterboth
--- a/tests/src/.outdated/substrate/substrate-api.ts
+++ b/tests/src/.outdated/substrate/substrate-api.ts
@@ -71,6 +71,7 @@
 
 export async function getApiConnection(settings: ApiOptions | undefined = undefined): Promise<ApiPromise> {
   settings = settings || defaultApiOptions();
+  if(!settings.provider) throw new Error('provider was not set');
   const api = new ApiPromise(settings);
 
   if (api) {
modifiedtests/src/eth/createCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createCollection.test.ts
+++ b/tests/src/eth/createCollection.test.ts
@@ -217,7 +217,8 @@
       const collection = helper.nft.getCollectionObject(collectionId);
       const data = (await collection.getData())!;
 
-      expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);
+      // Parallel test safety
+      expect(collectionCountAfter - collectionCountBefore).to.be.gte(1);
       expect(collectionId).to.be.eq(collectionCountAfter);
       expect(data.name).to.be.eq(name);
       expect(data.description).to.be.eq(description);
modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.dev.ts
+++ b/tests/src/util/playgrounds/unique.dev.ts
@@ -278,6 +278,7 @@
   }
 
   async connect(wsEndpoint: string, _listeners?: any): Promise<void> {
+    if(!wsEndpoint) throw new Error('wsEndpoint was not set');
     const wsProvider = new WsProvider(wsEndpoint);
     this.api = new ApiPromise({
       provider: wsProvider,
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
492 }492 }
493493
494 static async detectNetworkByWsEndpoint(wsEndpoint: string): Promise<TNetworks> {494 static async detectNetworkByWsEndpoint(wsEndpoint: string): Promise<TNetworks> {
495 if(!wsEndpoint) throw new Error('wsEndpoint was not set');
495 const api = new ApiPromise({provider: new WsProvider(wsEndpoint)});496 const api = new ApiPromise({provider: new WsProvider(wsEndpoint)});
496 await api.isReady;497 await api.isReady;
497498
507 network: TNetworks;508 network: TNetworks;
508 }> {509 }> {
509 if(typeof network === 'undefined' || network === null) network = 'opal';510 if(typeof network === 'undefined' || network === null) network = 'opal';
511 if(!wsEndpoint) throw new Error('wsEndpoint was not set');
510 const supportedRPC = {512 const supportedRPC = {
511 opal: {513 opal: {
512 unique: require('@unique-nft/opal-testnet-types/definitions').unique.rpc,514 unique: require('@unique-nft/opal-testnet-types/definitions').unique.rpc,