|
@@ -22,7 +22,7 @@ import { DbService } from '../../DbService'
|
|
import { LeaderHiringHappyCaseFixture } from '../../fixtures/leaderHiringHappyCase'
|
|
import { LeaderHiringHappyCaseFixture } from '../../fixtures/leaderHiringHappyCase'
|
|
|
|
|
|
// Manage worker as lead scenario
|
|
// Manage worker as lead scenario
|
|
-export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db: DbService) {
|
|
|
|
|
|
+export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db: DbService, group: WorkingGroups) {
|
|
const sudoUri: string = env.SUDO_ACCOUNT_URI!
|
|
const sudoUri: string = env.SUDO_ACCOUNT_URI!
|
|
const keyring = new Keyring({ type: 'sr25519' })
|
|
const keyring = new Keyring({ type: 'sr25519' })
|
|
const sudo: KeyringPair = keyring.addFromUri(sudoUri)
|
|
const sudo: KeyringPair = keyring.addFromUri(sudoUri)
|
|
@@ -43,9 +43,9 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
|
|
// const durationInBlocks = 60
|
|
// const durationInBlocks = 60
|
|
// setTestTimeout(api, durationInBlocks)
|
|
// setTestTimeout(api, durationInBlocks)
|
|
|
|
|
|
- if (db.hasLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
|
|
|
|
|
|
+ if (db.hasLeader(api.getWorkingGroupString(group))) {
|
|
nKeyPairs = db.getMembers()
|
|
nKeyPairs = db.getMembers()
|
|
- leadKeyPair[0] = db.getLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))
|
|
|
|
|
|
+ leadKeyPair[0] = db.getLeader(api.getWorkingGroupString(group))
|
|
} else {
|
|
} else {
|
|
const leaderHiringHappyCaseFixture: LeaderHiringHappyCaseFixture = new LeaderHiringHappyCaseFixture(
|
|
const leaderHiringHappyCaseFixture: LeaderHiringHappyCaseFixture = new LeaderHiringHappyCaseFixture(
|
|
api,
|
|
api,
|
|
@@ -59,7 +59,7 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
|
|
rewardInterval,
|
|
rewardInterval,
|
|
firstRewardInterval,
|
|
firstRewardInterval,
|
|
payoutAmount,
|
|
payoutAmount,
|
|
- WorkingGroups.StorageWorkingGroup
|
|
|
|
|
|
+ group
|
|
)
|
|
)
|
|
await leaderHiringHappyCaseFixture.runner(false)
|
|
await leaderHiringHappyCaseFixture.runner(false)
|
|
}
|
|
}
|
|
@@ -73,7 +73,7 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
|
|
roleStake,
|
|
roleStake,
|
|
openingActivationDelay,
|
|
openingActivationDelay,
|
|
unstakingPeriod,
|
|
unstakingPeriod,
|
|
- WorkingGroups.StorageWorkingGroup
|
|
|
|
|
|
+ group
|
|
)
|
|
)
|
|
// Add worker opening
|
|
// Add worker opening
|
|
await addWorkerOpeningFixture.runner(false)
|
|
await addWorkerOpeningFixture.runner(false)
|
|
@@ -88,7 +88,7 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
|
|
applicationStake,
|
|
applicationStake,
|
|
roleStake,
|
|
roleStake,
|
|
addWorkerOpeningFixture.getCreatedOpeningId() as OpeningId,
|
|
addWorkerOpeningFixture.getCreatedOpeningId() as OpeningId,
|
|
- WorkingGroups.StorageWorkingGroup
|
|
|
|
|
|
+ group
|
|
)
|
|
)
|
|
await applyForWorkerOpeningFixture.runner(false)
|
|
await applyForWorkerOpeningFixture.runner(false)
|
|
})()
|
|
})()
|
|
@@ -101,7 +101,7 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
|
|
leadKeyPair[0],
|
|
leadKeyPair[0],
|
|
sudo,
|
|
sudo,
|
|
addWorkerOpeningFixture.getCreatedOpeningId() as OpeningId,
|
|
addWorkerOpeningFixture.getCreatedOpeningId() as OpeningId,
|
|
- WorkingGroups.StorageWorkingGroup
|
|
|
|
|
|
+ group
|
|
)
|
|
)
|
|
await beginApplicationReviewFixture.runner(false)
|
|
await beginApplicationReviewFixture.runner(false)
|
|
})()
|
|
})()
|
|
@@ -118,17 +118,12 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
|
|
firstRewardInterval,
|
|
firstRewardInterval,
|
|
rewardInterval,
|
|
rewardInterval,
|
|
payoutAmount,
|
|
payoutAmount,
|
|
- WorkingGroups.StorageWorkingGroup
|
|
|
|
|
|
+ group
|
|
)
|
|
)
|
|
await fillOpeningFixture.runner(false)
|
|
await fillOpeningFixture.runner(false)
|
|
})()
|
|
})()
|
|
|
|
|
|
- const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(
|
|
|
|
- api,
|
|
|
|
- leadKeyPair,
|
|
|
|
- sudo,
|
|
|
|
- WorkingGroups.StorageWorkingGroup
|
|
|
|
- )
|
|
|
|
|
|
+ const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(api, leadKeyPair, sudo, group)
|
|
// Leaving lead role
|
|
// Leaving lead role
|
|
await leaveRoleFixture.runner(false)
|
|
await leaveRoleFixture.runner(false)
|
|
|
|
|
|
@@ -137,7 +132,7 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
|
|
nKeyPairs,
|
|
nKeyPairs,
|
|
leadKeyPair[0],
|
|
leadKeyPair[0],
|
|
sudo,
|
|
sudo,
|
|
- WorkingGroups.StorageWorkingGroup
|
|
|
|
|
|
+ group
|
|
)
|
|
)
|
|
// Decrease worker stake, expect failure
|
|
// Decrease worker stake, expect failure
|
|
await decreaseStakeFailureFixture.runner(true)
|
|
await decreaseStakeFailureFixture.runner(true)
|
|
@@ -149,7 +144,7 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
|
|
applicationStake,
|
|
applicationStake,
|
|
roleStake,
|
|
roleStake,
|
|
openingActivationDelay,
|
|
openingActivationDelay,
|
|
- WorkingGroups.StorageWorkingGroup
|
|
|
|
|
|
+ group
|
|
)
|
|
)
|
|
// Add lead opening
|
|
// Add lead opening
|
|
await addNewLeaderOpeningFixture.runner(false)
|
|
await addNewLeaderOpeningFixture.runner(false)
|
|
@@ -164,7 +159,7 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
|
|
applicationStake,
|
|
applicationStake,
|
|
roleStake,
|
|
roleStake,
|
|
addNewLeaderOpeningFixture.getCreatedOpeningId() as OpeningId,
|
|
addNewLeaderOpeningFixture.getCreatedOpeningId() as OpeningId,
|
|
- WorkingGroups.StorageWorkingGroup
|
|
|
|
|
|
+ group
|
|
)
|
|
)
|
|
await applyForNewLeaderOpeningFixture.runner(false)
|
|
await applyForNewLeaderOpeningFixture.runner(false)
|
|
})()
|
|
})()
|
|
@@ -176,7 +171,7 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
|
|
api,
|
|
api,
|
|
sudo,
|
|
sudo,
|
|
addNewLeaderOpeningFixture.getCreatedOpeningId() as OpeningId,
|
|
addNewLeaderOpeningFixture.getCreatedOpeningId() as OpeningId,
|
|
- WorkingGroups.StorageWorkingGroup
|
|
|
|
|
|
+ group
|
|
)
|
|
)
|
|
await beginNewLeaderApplicationReviewFixture.runner(false)
|
|
await beginNewLeaderApplicationReviewFixture.runner(false)
|
|
})()
|
|
})()
|
|
@@ -192,7 +187,7 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
|
|
firstRewardInterval,
|
|
firstRewardInterval,
|
|
rewardInterval,
|
|
rewardInterval,
|
|
payoutAmount,
|
|
payoutAmount,
|
|
- WorkingGroups.StorageWorkingGroup
|
|
|
|
|
|
+ group
|
|
)
|
|
)
|
|
await fillNewLeaderOpeningFixture.runner(false)
|
|
await fillNewLeaderOpeningFixture.runner(false)
|
|
})()
|
|
})()
|
|
@@ -202,18 +197,12 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
|
|
nKeyPairs,
|
|
nKeyPairs,
|
|
leadKeyPair[0],
|
|
leadKeyPair[0],
|
|
sudo,
|
|
sudo,
|
|
- WorkingGroups.StorageWorkingGroup
|
|
|
|
|
|
+ group
|
|
)
|
|
)
|
|
// Decrease worker stake
|
|
// Decrease worker stake
|
|
await decreaseStakeFixture.runner(false)
|
|
await decreaseStakeFixture.runner(false)
|
|
|
|
|
|
- const slashFixture: SlashFixture = new SlashFixture(
|
|
|
|
- api,
|
|
|
|
- nKeyPairs,
|
|
|
|
- leadKeyPair[0],
|
|
|
|
- sudo,
|
|
|
|
- WorkingGroups.StorageWorkingGroup
|
|
|
|
- )
|
|
|
|
|
|
+ const slashFixture: SlashFixture = new SlashFixture(api, nKeyPairs, leadKeyPair[0], sudo, group)
|
|
// Slash worker
|
|
// Slash worker
|
|
await slashFixture.runner(false)
|
|
await slashFixture.runner(false)
|
|
|
|
|
|
@@ -222,18 +211,13 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
|
|
nKeyPairs,
|
|
nKeyPairs,
|
|
leadKeyPair[0],
|
|
leadKeyPair[0],
|
|
sudo,
|
|
sudo,
|
|
- WorkingGroups.StorageWorkingGroup
|
|
|
|
|
|
+ group
|
|
)
|
|
)
|
|
// Terminate worker role
|
|
// Terminate worker role
|
|
await terminateRoleFixture.runner(false)
|
|
await terminateRoleFixture.runner(false)
|
|
|
|
|
|
- if (!db.hasLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
|
|
|
|
- const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(
|
|
|
|
- api,
|
|
|
|
- leadKeyPair,
|
|
|
|
- sudo,
|
|
|
|
- WorkingGroups.StorageWorkingGroup
|
|
|
|
- )
|
|
|
|
|
|
+ if (!db.hasLeader(api.getWorkingGroupString(group))) {
|
|
|
|
+ const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(api, leadKeyPair, sudo, group)
|
|
// Leaving lead role
|
|
// Leaving lead role
|
|
await leaveRoleFixture.runner(false)
|
|
await leaveRoleFixture.runner(false)
|
|
}
|
|
}
|