Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into tomasz-starlight-st…
Browse files Browse the repository at this point in the history
…aking-tests
  • Loading branch information
tmpolaczyk committed Dec 19, 2024
2 parents 8887011 + 49bcaf6 commit 5466276
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ parameter_types! {
}

// Holesky: https://github.com/eth-clients/holesky
// Fork versions: https://github.com/eth-clients/holesky/blob/main/metadata/config.yaml
#[cfg(not(any(
feature = "std",
feature = "fast-runtime",
Expand All @@ -117,19 +118,19 @@ parameter_types! {
epoch: 0,
},
altair: Fork {
version: hex_literal::hex!("01017000"), // 0x01017000
version: hex_literal::hex!("02017000"), // 0x02017000
epoch: 0,
},
bellatrix: Fork {
version: hex_literal::hex!("01017000"), // 0x01017000
version: hex_literal::hex!("03017000"), // 0x03017000
epoch: 0,
},
capella: Fork {
version: hex_literal::hex!("01017001"), // 0x01017001
version: hex_literal::hex!("04017000"), // 0x04017000
epoch: 256,
},
deneb: Fork {
version: hex_literal::hex!("01017002"), // 0x01017002
version: hex_literal::hex!("05017000"), // 0x05017000
epoch: 29696,
},
};
Expand Down
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();
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

0 comments on commit 5466276

Please sign in to comment.