-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
so far services payment tests working
- Loading branch information
Showing
8 changed files
with
101 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
test/suites/dev-tanssi-relay/services-payment/test_services_payment_collator_tip.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import "@tanssi/api-augment"; | ||
import { describeSuite, expect, beforeAll } from "@moonwall/cli"; | ||
import { ApiPromise } from "@polkadot/api"; | ||
import { KeyringPair } from "@moonwall/util"; | ||
import { fetchCollatorAssignmentTip, jumpSessions } from "util/block"; | ||
|
||
describeSuite({ | ||
id: "CT0608", | ||
title: "Services payment collator assignment tip test suite", | ||
foundationMethods: "dev", | ||
testCases: ({ it, context }) => { | ||
let polkadotJs: ApiPromise; | ||
let alice: KeyringPair; | ||
|
||
beforeAll(async () => { | ||
polkadotJs = context.polkadotJs(); | ||
alice = context.keyring.alice; | ||
}); | ||
it({ | ||
id: "E01", | ||
title: "Tip should prioritize collator assignment", | ||
test: async function () { | ||
await context.createBlock(); | ||
|
||
const paraId = 2001n; | ||
|
||
const tip = 123; | ||
|
||
const tx = polkadotJs.tx.servicesPayment.purchaseCredits(paraId, 1_000_000_000_000_000); | ||
await context.createBlock([await tx.signAsync(alice)]); | ||
|
||
const txMaxTip = polkadotJs.tx.servicesPayment.setMaxTip(paraId, tip); | ||
// In genesis we have 4 collators, hence if we make 4 collators per para, we make sure the one | ||
// with priority gets them | ||
const changeCollatorsPerChain = polkadotJs.tx.collatorConfiguration.setCollatorsPerContainer(4); | ||
await context.createBlock([await polkadotJs.tx.sudo.sudo(polkadotJs.tx.utility.batchAll([txMaxTip, changeCollatorsPerChain])).signAsync(alice)]); | ||
await jumpSessions(context, 2); | ||
|
||
const collators = await polkadotJs.query.tanssiCollatorAssignment.collatorContainerChain(); | ||
expect( | ||
collators.toJSON().containerChains[paraId].length, | ||
`Container chain ${paraId} should have 4 collators` | ||
).toBe(4); | ||
|
||
const events = await polkadotJs.query.system.events(); | ||
const tipEvent = fetchCollatorAssignmentTip(events); | ||
expect(tipEvent.tip.toNumber()).to.be.equal(tip); | ||
}, | ||
}); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters