Skip to content

Commit

Permalink
WIP tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpolaczyk committed Dec 18, 2024
1 parent 099b65d commit dda5a29
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ pub fn start_dev_node(

if mock_additional_randomness {
let mut mock_randomness: [u8; 32] = [0u8; 32];
mock_randomness[..8].copy_from_slice(&current_para_block.to_be_bytes());
mock_randomness[..4].copy_from_slice(&current_para_block.to_be_bytes());
additional_keys.extend([(RelayWellKnownKeys::CURRENT_BLOCK_RANDOMNESS.to_vec(), mock_randomness.encode())]);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "@tanssi/api-augment";
import { describeSuite, expect, beforeAll } from "@moonwall/cli";
import {describeSuite, expect, beforeAll, customDevRpcRequest} from "@moonwall/cli";
import { ApiPromise } from "@polkadot/api";
import { jumpBlocks, jumpSessions, jumpToSession } from "util/block";
import { filterAndApply, generateKeyringPair } from "@moonwall/util";
Expand All @@ -24,6 +24,9 @@ describeSuite({
bob = context.keyring.bob;
charlie = context.keyring.charlie;
dave = context.keyring.dave;

// Enable randomness for this test
await customDevRpcRequest("mock_activateRandomness", []);
});

it({
Expand All @@ -32,7 +35,7 @@ describeSuite({
test: async function () {

const orchestrator = null;
const parachain = { KeepCollators: { keep: 2 } };
const parachain = { KeepCollators: { keep: 1 } };
const parathread = { KeepPerbill: { percentage: 500_000_000n } }; // 50%
const tx = context.polkadotJs().tx.configuration.setFullRotationMode(orchestrator, parachain, parathread);
await context.createBlock(polkadotJs.tx.sudo.sudo(tx).signAsync(alice));
Expand Down Expand Up @@ -127,9 +130,13 @@ describeSuite({
const sessionDuration = 10;
await jumpBlocks(context, sessionDuration - 1);
const assignmentRandomness = await polkadotJs.query.collatorAssignment.randomness();
// TODO: in dancelight isEmpty == false because we have randomness there
// In dancebox dev tests there is no rotation because there is no randomness
expect(assignmentRandomness.isEmpty).toBe(true);
expect(assignmentRandomness.isEmpty).toBe(false);

await jumpSessions(context, 1);
const rotationRotateAssignment = (
await polkadotJs.query.collatorAssignment.collatorContainerChain()
).toJSON();
console.log("rotationRotateAssignment: ", rotationRotateAssignment);
},
});
},
Expand Down

0 comments on commit dda5a29

Please sign in to comment.