Browse Source

tests: fix skipIfAlreadySet in leaders flow

Mokhtar Naamani 3 years ago
parent
commit
71f4d615e4
1 changed files with 7 additions and 3 deletions
  1. 7 3
      tests/network-tests/src/flows/workingGroup/leaderSetup.ts

+ 7 - 3
tests/network-tests/src/flows/workingGroup/leaderSetup.ts

@@ -57,11 +57,15 @@ async function leaderSetup(
   const debug = extendDebug(`flow:leaderSetup:${group}`)
   debug('Started')
 
-  if (!skipIfAlreadySet) {
-    const existingLead = await api.getGroupLead(group)
-    assert.equal(existingLead, undefined, 'Lead is already set')
+  const existingLead = await api.getGroupLead(group)
+
+  if (skipIfAlreadySet && existingLead !== undefined) {
+    debug('Skipping create lead, already exists.')
+    return
   }
 
+  assert.equal(existingLead, undefined, 'Lead is already set')
+
   const leadKeyPair = api.createKeyPairs(1)[0].key
   const paidTerms: PaidTermId = api.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
   const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)