Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/network-tests/.env
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ SLASH_AMOUNT = 2
# Stake decrement amount for manage working group lead testing scenario
STAKE_DECREMENT = 3
# Mint capacity increment value for working gorup mint capacity test
MINT_CAPACITY_INCREMENT = 11
MINT_CAPACITY_INCREMENT = 1000
2 changes: 1 addition & 1 deletion tests/network-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "tap --files src/iznik/tests/unknown.unknown src/iznik/tests/councilSetup.ts src/iznik/tests/proposals/*Test.ts src/iznik/tests/leaderSetup.ts src/iznik/tests/workingGroup/*Test.ts src/iznik/tests/proposals/updateRuntime.ts -T",
"test-migration-constantinople": "tap --files src/rome/tests/romeRuntimeUpgradeTest.ts --files src/constantinople/tests/electingCouncilTest.ts -T",
"test-migration-nicaea": "tap --files src/constantinople/tests/proposals/updateRuntimeTest.ts --files src/nicaea/tests/electingCouncilTest.ts -T",
"debug": "tap --files src/iznik/tests/proposals/manageLeaderRoleTest.ts -T",
"debug": "tap --files src/iznik/tests/workingGroup/workerPayoutTest.ts -T",
"lint": "eslint . --quiet --ext .ts",
"checks": "yarn lint && tsc --noEmit --pretty && prettier ./ --check",
"format": "prettier ./ --write "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { v4 as uuid } from 'uuid'
import BN from 'bn.js'
import { ProposalId } from '@alexandria/types/proposals'
import { Fixture } from './interfaces/fixture'
import { Bytes } from '@polkadot/types'
import { assert } from 'chai'
import { ApplicationId, OpeningId } from '@alexandria/types/hiring'
import { WorkerId } from '@alexandria/types/working-group'
import { Utils } from '../../utils/utils'

export class CreateWorkingGroupLeaderOpeningFixture implements Fixture {
private apiWrapper: ApiWrapper
Expand Down Expand Up @@ -1004,22 +1004,25 @@ export class UpdateRuntimeFixture implements Fixture {
private membersKeyPairs: KeyringPair[]
private councilKeyPairs: KeyringPair[]
private treasury: KeyringPair
private runtimePath: string

constructor(
apiWrapper: ApiWrapper,
membersKeyPairs: KeyringPair[],
councilKeyPairs: KeyringPair[],
treasury: KeyringPair
treasury: KeyringPair,
runtimePath: string
) {
this.apiWrapper = apiWrapper
this.membersKeyPairs = membersKeyPairs
this.councilKeyPairs = councilKeyPairs
this.treasury = treasury
this.runtimePath = runtimePath
}

public async runner(expectFailure: boolean): Promise<void> {
// Setup
const runtime: Bytes = await this.apiWrapper.getRuntime()
const runtime: string = Utils.readRuntimeFromFile(this.runtimePath)
const description = 'runtime upgrade proposal which is used for API network testing'
const runtimeVoteFee: BN = this.apiWrapper.estimateVoteForProposalFee()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,8 @@ export class ExpectLeaderRewardAmountUpdatedFixture implements Fixture {
this.events.push(event)
const leadWorkerId: WorkerId = (await this.apiWrapper.getLeadWorkerId(this.module))!
const leadWorker: Worker = await this.apiWrapper.getWorkerById(leadWorkerId, this.module)
const receivedReward: BN = (await this.apiWrapper.getRewardRelationship(leadWorker.reward_relationship.unwrap())).amount_per_payout
const receivedReward: BN = (await this.apiWrapper.getRewardRelationship(leadWorker.reward_relationship.unwrap()))
.amount_per_payout
assert(
receivedReward.eq(this.expectedReward),
`Unexpected reward amount for worker with id ${leadWorkerId}: ${receivedReward}, expected ${this.expectedReward}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ tap.mocha.describe('Validator count proposal scenario', async () => {
greaterStake,
lesserStake
)
councilElectionHappyCaseFixture.runner(false)
await councilElectionHappyCaseFixture.runner(false)
}

const contentWorkingGroupMintCapacityProposalFixture: ContentWorkingGroupMintCapacityProposalFixture = new ContentWorkingGroupMintCapacityProposalFixture(
Expand All @@ -61,8 +61,9 @@ tap.mocha.describe('Validator count proposal scenario', async () => {
sudo,
mintingCapacityIncrement
)
tap.test('Content working group mint capacity test', async () =>
contentWorkingGroupMintCapacityProposalFixture.runner(false)
tap.test(
'Content working group mint capacity test',
async () => await contentWorkingGroupMintCapacityProposalFixture.runner(false)
)

closeApi(apiWrapper)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ tap.mocha.describe('Election parameters proposal scenario', async () => {
greaterStake,
lesserStake
)
councilElectionHappyCaseFixture.runner(false)
await councilElectionHappyCaseFixture.runner(false)
}

const electionParametersProposalFixture: ElectionParametersProposalFixture = new ElectionParametersProposalFixture(
Expand All @@ -59,7 +59,7 @@ tap.mocha.describe('Election parameters proposal scenario', async () => {
m2KeyPairs,
sudo
)
tap.test('Election parameters proposal test', async () => electionParametersProposalFixture.runner(false))
tap.test('Election parameters proposal test', async () => await electionParametersProposalFixture.runner(false))

closeApi(apiWrapper)
})
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
greaterStake,
lesserStake
)
councilElectionHappyCaseFixture.runner(false)
await councilElectionHappyCaseFixture.runner(false)
}

const leaderMembershipFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
Expand All @@ -90,7 +90,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
leadKeyPair,
paidTerms
)
tap.test('Buy membership for lead', async () => leaderMembershipFixture.runner(false))
tap.test('Buy membership for lead', async () => await leaderMembershipFixture.runner(false))

const createWorkingGroupLeaderOpeningFixture: CreateWorkingGroupLeaderOpeningFixture = new CreateWorkingGroupLeaderOpeningFixture(
apiWrapper,
Expand All @@ -100,7 +100,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
roleStake,
'Storage'
)
tap.test('Propose create leader opening', async () => createWorkingGroupLeaderOpeningFixture.runner(false))
tap.test('Propose create leader opening', async () => await createWorkingGroupLeaderOpeningFixture.runner(false))

let voteForCreateOpeningProposalFixture: VoteForProposalFixture
const expectLeadOpeningAddedFixture: ExpectLeadOpeningAddedFixture = new ExpectLeadOpeningAddedFixture(apiWrapper)
Expand Down Expand Up @@ -251,7 +251,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
slashAmount,
WorkingGroups.StorageWorkingGroup
)
tap.test('Propose leader slash', async () => slashLeaderProposalFixture.runner(false))
tap.test('Propose leader slash', async () => await slashLeaderProposalFixture.runner(false))

let voteForSlashProposalFixture: VoteForProposalFixture
let expectLeaderSlashedFixture: ExpectLeaderSlashedFixture
Expand All @@ -276,7 +276,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
false,
WorkingGroups.StorageWorkingGroup
)
tap.test('Propose terminate leader role', async () => terminateLeaderRoleProposalFixture.runner(false))
tap.test('Propose terminate leader role', async () => await terminateLeaderRoleProposalFixture.runner(false))

let voteForLeaderRoleTerminationFixture: VoteForProposalFixture
const expectLeaderRoleTerminatedFixture: ExpectLeaderRoleTerminatedFixture = new ExpectLeaderRoleTerminatedFixture(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
greaterStake,
lesserStake
)
councilElectionHappyCaseFixture.runner(false)
await councilElectionHappyCaseFixture.runner(false)
}

const setLeadProposalFixture: SetLeadProposalFixture = new SetLeadProposalFixture(
Expand All @@ -59,7 +59,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
m2KeyPairs,
sudo
)
tap.test('Set lead proposal test', async () => setLeadProposalFixture.runner(false))
tap.test('Set lead proposal test', async () => await setLeadProposalFixture.runner(false))

closeApi(apiWrapper)
})
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ tap.mocha.describe('Spending proposal scenario', async () => {
greaterStake,
lesserStake
)
councilElectionHappyCaseFixture.runner(false)
await councilElectionHappyCaseFixture.runner(false)
}

const spendingProposalFixture: SpendingProposalFixture = new SpendingProposalFixture(
Expand All @@ -62,7 +62,7 @@ tap.mocha.describe('Spending proposal scenario', async () => {
spendingBalance,
mintCapacity
)
tap.test('Spending proposal test', async () => spendingProposalFixture.runner(false))
tap.test('Spending proposal test', async () => await spendingProposalFixture.runner(false))

closeApi(apiWrapper)
})
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ tap.mocha.describe('Text proposal scenario', async () => {
greaterStake,
lesserStake
)
councilElectionHappyCaseFixture.runner(false)
await councilElectionHappyCaseFixture.runner(false)
}

const textProposalFixture: TextProposalFixture = new TextProposalFixture(apiWrapper, m1KeyPairs, m2KeyPairs, sudo)
tap.test('Text proposal test', async () => textProposalFixture.runner(false))
tap.test('Text proposal test', async () => await textProposalFixture.runner(false))

closeApi(apiWrapper)
})
15 changes: 11 additions & 4 deletions tests/network-tests/src/iznik/tests/proposals/updateRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ tap.mocha.describe('Update runtime scenario', async () => {
const K: number = +process.env.COUNCIL_ELECTION_K!
const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
const runtimePath: string = process.env.RUNTIME_WASM_PATH!
const durationInBlocks = 54

setTestTimeout(apiWrapper, durationInBlocks)
Expand All @@ -50,19 +51,25 @@ tap.mocha.describe('Update runtime scenario', async () => {
greaterStake,
lesserStake
)
councilElectionHappyCaseFixture.runner(false)
await councilElectionHappyCaseFixture.runner(false)
}

const updateRuntimeFixture: UpdateRuntimeFixture = new UpdateRuntimeFixture(apiWrapper, m1KeyPairs, m2KeyPairs, sudo)
tap.test('Upgrade runtime', async () => updateRuntimeFixture.runner(false))
const updateRuntimeFixture: UpdateRuntimeFixture = new UpdateRuntimeFixture(
apiWrapper,
m1KeyPairs,
m2KeyPairs,
sudo,
runtimePath
)
tap.test('Upgrade runtime', async () => await updateRuntimeFixture.runner(false))

const thirdMemberSetFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
apiWrapper,
sudo,
Utils.createKeyPairs(keyring, N),
paidTerms
)
tap.test('Creating third set of members', async () => thirdMemberSetFixture.runner(false))
tap.test('Creating third set of members', async () => await thirdMemberSetFixture.runner(false))

closeApi(apiWrapper)
})
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ tap.mocha.describe('Validator count proposal scenario', async () => {
greaterStake,
lesserStake
)
councilElectionHappyCaseFixture.runner(false)
await councilElectionHappyCaseFixture.runner(false)
}

const validatorCountProposalFixture: ValidatorCountProposalFixture = new ValidatorCountProposalFixture(
Expand All @@ -60,7 +60,7 @@ tap.mocha.describe('Validator count proposal scenario', async () => {
sudo,
validatorCountIncrement
)
tap.test('Validator count proposal', async () => validatorCountProposalFixture.runner(false))
tap.test('Validator count proposal', async () => await validatorCountProposalFixture.runner(false))

closeApi(apiWrapper)
})
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ tap.mocha.describe('Set storage working group mint capacity scenario', async ()
greaterStake,
lesserStake
)
councilElectionHappyCaseFixture.runner(false)
await councilElectionHappyCaseFixture.runner(false)
}

const newMintCapacity: BN = (await apiWrapper.getWorkingGroupMintCapacity(WorkingGroups.StorageWorkingGroup)).add(
Expand All @@ -65,7 +65,7 @@ tap.mocha.describe('Set storage working group mint capacity scenario', async ()
newMintCapacity,
WorkingGroups.StorageWorkingGroup
)
tap.test('Propose mint capacity', async () => workingGroupMintCapacityProposalFixture.runner(false))
tap.test('Propose mint capacity', async () => await workingGroupMintCapacityProposalFixture.runner(false))

let voteForProposalFixture: VoteForProposalFixture
const expectMintCapacityChanged: ExpectMintCapacityChangedFixture = new ExpectMintCapacityChangedFixture(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { PaidTermId } from '@alexandria/types/members'
import { DbService } from '../../services/dbService'
import { LeaderHiringHappyCaseFixture } from '../fixtures/leaderHiringHappyCase'

tap.mocha.describe('Worker application happy case scenario', async () => {
tap.mocha.describe('Zero at least value bug scenario', async () => {
initConfig()

const nodeUrl: string = process.env.NODE_URL!
Expand Down Expand Up @@ -72,8 +72,9 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
unstakingPeriod,
WorkingGroups.StorageWorkingGroup
)
tap.test('Add worker opening with 0 stake, expect failure', async () =>
addWorkerOpeningWithoutStakeFixture.runner(true)
tap.test(
'Add worker opening with 0 stake, expect failure',
async () => await addWorkerOpeningWithoutStakeFixture.runner(true)
)

const addWorkerOpeningWithoutUnstakingPeriodFixture: AddWorkerOpeningFixture = new AddWorkerOpeningFixture(
Expand All @@ -87,8 +88,9 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
new BN(0),
WorkingGroups.StorageWorkingGroup
)
tap.test('Add worker opening with 0 unstaking period, expect failure', async () =>
addWorkerOpeningWithoutUnstakingPeriodFixture.runner(true)
tap.test(
'Add worker opening with 0 unstaking period, expect failure',
async () => await addWorkerOpeningWithoutUnstakingPeriodFixture.runner(true)
)

if (!db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
Expand All @@ -98,7 +100,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
sudo,
WorkingGroups.StorageWorkingGroup
)
tap.test('Leaving lead role', async () => leaveRoleFixture.runner(false))
tap.test('Leaving lead role', async () => await leaveRoleFixture.runner(false))
}

closeApi(apiWrapper)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
unstakingPeriod,
WorkingGroups.StorageWorkingGroup
)
tap.test('Add worker opening', async () => addWorkerOpeningFixture.runner(false))
tap.test('Add worker opening', async () => await addWorkerOpeningFixture.runner(false))

let applyForWorkerOpeningFixture: ApplyForOpeningFixture
tap.test('First apply for worker opening', async () => {
Expand Down Expand Up @@ -135,7 +135,7 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
sudo,
WorkingGroups.StorageWorkingGroup
)
tap.test('Leaving lead role', async () => leaveRoleFixture.runner(false))
tap.test('Leaving lead role', async () => await leaveRoleFixture.runner(false))

const decreaseStakeFailureFixture: DecreaseStakeFixture = new DecreaseStakeFixture(
apiWrapper,
Expand All @@ -144,7 +144,7 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
sudo,
WorkingGroups.StorageWorkingGroup
)
tap.test('Decrease worker stake, expect failure', async () => decreaseStakeFailureFixture.runner(true))
tap.test('Decrease worker stake, expect failure', async () => await decreaseStakeFailureFixture.runner(true))

const addNewLeaderOpeningFixture: AddLeaderOpeningFixture = new AddLeaderOpeningFixture(
apiWrapper,
Expand Down Expand Up @@ -204,7 +204,7 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
sudo,
WorkingGroups.StorageWorkingGroup
)
tap.test('Decrease worker stake', async () => decreaseStakeFixture.runner(false))
tap.test('Decrease worker stake', async () => await decreaseStakeFixture.runner(false))

const slashFixture: SlashFixture = new SlashFixture(
apiWrapper,
Expand All @@ -213,7 +213,7 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
sudo,
WorkingGroups.StorageWorkingGroup
)
tap.test('Slash worker', async () => slashFixture.runner(false))
tap.test('Slash worker', async () => await slashFixture.runner(false))

const terminateRoleFixture: TerminateRoleFixture = new TerminateRoleFixture(
apiWrapper,
Expand All @@ -222,7 +222,7 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
sudo,
WorkingGroups.StorageWorkingGroup
)
tap.test('Terminate worker role', async () => terminateRoleFixture.runner(false))
tap.test('Terminate worker role', async () => await terminateRoleFixture.runner(false))

if (!db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(
Expand All @@ -231,7 +231,7 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
sudo,
WorkingGroups.StorageWorkingGroup
)
tap.test('Leaving lead role', async () => leaveRoleFixture.runner(false))
tap.test('Leaving lead role', async () => await leaveRoleFixture.runner(false))
}

closeApi(apiWrapper)
Expand Down
Loading