-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into rq/remove-suicided-contracts-migration
- Loading branch information
Showing
9 changed files
with
1,778 additions
and
2,537 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
63 changes: 63 additions & 0 deletions
63
test/suites/dev/moonbase/test-parameters/test-parameters-randomness.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,63 @@ | ||
import { describeSuite, expect } from "@moonwall/cli"; | ||
import { alith } from "@moonwall/util"; | ||
import { parameterType, UNIT } from "./test-parameters"; | ||
|
||
describeSuite({ | ||
id: "DTemp02", | ||
title: "Parameters - Pallet Randomness", | ||
foundationMethods: "dev", | ||
testCases: ({ it, context, log }) => { | ||
it({ | ||
id: `T01 - PalletRandomness - Deposit - CustomTests`, | ||
title: "Deposit parameter should only be accepted in bounds", | ||
test: async () => { | ||
const MIN = 1n * UNIT; | ||
const MAX = 1000n * UNIT; | ||
|
||
// used as an acceptable value | ||
const AVG = (MIN + MAX) / 2n; | ||
|
||
const param1 = parameterType(context, "PalletRandomness", "Deposit", MIN - 1n); | ||
try { | ||
await context.createBlock( | ||
context | ||
.polkadotJs() | ||
.tx.sudo.sudo(context.polkadotJs().tx.parameters.setParameter(param1.toU8a())) | ||
.signAsync(alith), | ||
{ allowFailures: false } | ||
); | ||
expect.fail("An extrinsic should not be created, since the parameter is invalid"); | ||
} catch (error) { | ||
expect(error.toString().toLowerCase()).to.contain("value out of bounds"); | ||
} | ||
|
||
const param2 = parameterType(context, "PalletRandomness", "Deposit", MAX + 1n); | ||
try { | ||
await context.createBlock( | ||
context | ||
.polkadotJs() | ||
.tx.sudo.sudo(context.polkadotJs().tx.parameters.setParameter(param2.toU8a())) | ||
.signAsync(alith), | ||
{ allowFailures: false } | ||
); | ||
expect.fail("An extrinsic should not be created, since the parameter is invalid"); | ||
} catch (error) { | ||
expect(error.toString().toLowerCase()).to.contain("value out of bounds"); | ||
} | ||
|
||
const param3 = parameterType(context, "PalletRandomness", "Deposit", AVG); | ||
const res3 = await context.createBlock( | ||
context | ||
.polkadotJs() | ||
.tx.sudo.sudo(context.polkadotJs().tx.parameters.setParameter(param3.toU8a())) | ||
.signAsync(alith), | ||
{ allowFailures: false } | ||
); | ||
expect( | ||
res3.result?.successful, | ||
"An extrinsic should be created, since the parameter is valid" | ||
).to.be.true; | ||
}, | ||
}); | ||
}, | ||
}); |
Oops, something went wrong.