Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test operator from Ethereum bridge produces blocks #785

Merged
merged 6 commits into from
Dec 18, 2024
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
5 changes: 5 additions & 0 deletions test/configs/zombie_tanssi_relay_eth_bridge.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
{
"name": "bob",
"validator": true
},
{
"name": "charlie",
"ws_port": "9948",
"validator": true
}
]
},
Expand Down
5 changes: 5 additions & 0 deletions test/moonwall.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,11 @@
"name": "Tanssi-relay",
"type": "polkadotJs",
"endpoints": ["ws://127.0.0.1:9947"]
},
{
"name": "Tanssi-charlie",
"type": "polkadotJs",
"endpoints": ["ws://127.0.0.1:9948"]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describeSuite({
foundationMethods: "zombie",
testCases: function ({ it, context }) {
let relayApi: ApiPromise;
let relayCharlieApi: ApiPromise;
let ethereumNodeChildProcess;
let relayerChildProcess;
let alice;
Expand All @@ -44,17 +45,20 @@ describeSuite({
const relayNetwork = relayApi.consts.system.version.specName.toString();
expect(relayNetwork, "Relay API incorrect").to.contain("dancelight");

relayCharlieApi = context.polkadotJs("Tanssi-charlie");

// //BeaconRelay
const keyring = new Keyring({ type: "sr25519" });
alice = keyring.addFromUri("//Alice", { name: "Alice default" });
const beaconRelay = keyring.addFromUri("//BeaconRelay", { name: "Beacon relay default" });
const executionRelay = keyring.addFromUri("//ExecutionRelay", { name: "Execution relay default" });

// Operator keys
operatorAccount = keyring.addFromUri("//" + "Bob", { name: "COLLATOR" + " ACCOUNT" });
operatorNimbusKey = keyring.addFromUri("//" + "COLLATOR_NIMBUS", { name: "COLLATOR" + " NIMBUS" });

await relayApi.tx.session.setKeys(u8aToHex(operatorNimbusKey), []).signAndSend(operatorAccount);
operatorAccount = keyring.addFromUri("//Charlie", { name: "Charlie default" });
// We rotate the keys for charlie so that we have access to them from this test as well as the node
operatorNimbusKey = await relayCharlieApi.rpc.author.rotateKeys();
nanocryk marked this conversation as resolved.
Show resolved Hide resolved
console.log(`operatorNimbusKey: ${operatorNimbusKey}`);
await relayApi.tx.session.setKeys(operatorNimbusKey, []).signAndSend(operatorAccount);

const fundingTxHash = await relayApi.tx.utility
.batch([
Expand Down Expand Up @@ -182,6 +186,9 @@ describeSuite({

const externalValidatorsBefore = await relayApi.query.externalValidators.externalValidators();

const sessionValidatorsBefore = await relayApi.query.session.validators();
expect(!sessionValidatorsBefore.includes(operatorNimbusKey));

const rawValidators = [
u8aToHex(operatorAccount.addressRaw),
"0x7894567890123456789012345678901234567890123456789012345678901234",
Expand Down Expand Up @@ -226,6 +233,24 @@ describeSuite({
},
});

it({
id: "T04",
title: "Operator produces blocks",
test: async function () {
for (let i = 0; i < 20; ++i) {
const latestBlockHash = await relayApi.rpc.chain.getBlockHash();
const author = (await relayApi.derive.chain.getHeader(latestBlockHash)).author;
if (author == operatorAccount.address) {
return;
}

await context.waitBlock(1, "Tanssi-relay");
}

expect.fail("operator didn't produce a block");
},
});

afterAll(async () => {
console.log("Cleaning up");
if (ethereumNodeChildProcess) {
Expand Down
Loading