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

fix(test): check genesis before it completed #1466

Merged
merged 1 commit into from
Oct 10, 2023

Conversation

yangby-cryptape
Copy link
Collaborator

@yangby-cryptape yangby-cryptape commented Oct 10, 2023

What this PR does / why we need it?

The test for genesis block initialization was broken since #1454.

It moved some updates of header behind the check of the genesis hash.

  • The genesis hash is checked in line 132.

    axon/core/run/src/tests.rs

    Lines 132 to 137 in 5b2310c

    check_hashes(
    case.chain_name,
    "input genesis hash",
    case.input_genesis_hash,
    genesis.block.header.hash(),
    );

  • But correct receipts root is computed later in line 170, and it is never set back to the genesis.

    axon/core/run/src/tests.rs

    Lines 176 to 179 in 5b2310c

    let resp = execute_genesis_transactions(&genesis, &db_group, &chain_spec.accounts, &[
    metadata_0, metadata_1,
    ])
    .expect("execute transactions");

    axon/core/run/src/tests.rs

    Lines 181 to 183 in 5b2310c

    let mut header = genesis.block.header.clone();
    header.state_root = resp.state_root;
    header.receipts_root = resp.receipt_root;

  • Also, it copied some code into tests, so the real code won't be tested.

    • The real code which requires tests:

      axon/core/run/src/lib.rs

      Lines 450 to 461 in 5b2310c

      let metadata_0 = spec.params.clone();
      let metadata_1 = {
      let mut tmp = metadata_0.clone();
      tmp.epoch = metadata_0.epoch + 1;
      tmp.version.start = metadata_0.version.end + 1;
      tmp.version.end = tmp.version.start + metadata_0.version.end - 1;
      tmp
      };
      let resp = execute_genesis_transactions(&partial_genesis, db_group, &spec.accounts, &[
      metadata_0, metadata_1,
      ])?;

    • The code copied into tests.

      axon/core/run/src/tests.rs

      Lines 168 to 175 in 5b2310c

      let metadata_0 = chain_spec.params.clone();
      let metadata_1 = {
      let mut tmp = metadata_0.clone();
      tmp.epoch = metadata_0.epoch + 1;
      tmp.version.start = metadata_0.version.end + 1;
      tmp.version.end = tmp.version.start + metadata_0.version.end - 1;
      tmp
      };

What is the impact of this PR?

No Breaking Change

CI Settings

CI Usage

Tip: Check the CI you want to run below, and then comment /run-ci.

CI Switch

  • Web3 Compatible Tests
  • OCT 1-5 And 12-15
  • OCT 6-10
  • OCT 11
  • OCT 16-19
  • v3 Core Tests

CI Description

CI Name Description
Web3 Compatible Test Test the Web3 compatibility of Axon
v3 Core Test Run the compatibility tests provided by Uniswap V3
OCT 1-5 | 6-10 | 11 | 12-15 | 16-19 Run the compatibility tests provided by OpenZeppelin

@yangby-cryptape yangby-cryptape requested a review from a team as a code owner October 10, 2023 06:36
@yangby-cryptape yangby-cryptape requested review from Flouse, driftluo and KaoImin and removed request for jjyr and wenyuanhust October 10, 2023 06:40
@yangby-cryptape

This comment was marked as off-topic.

@github-actions
Copy link

CI tests run on commit:

CI test list:

  • OCT 1-5 And 12-15
  • OCT 6-10
  • OCT 11
  • OCT 16-19
  • v3 Core Tests
  • Web3 Compatible Tests

Please check ci test results later.

@Flouse Flouse added this pull request to the merge queue Oct 10, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 10, 2023
@yangby-cryptape yangby-cryptape added this pull request to the merge queue Oct 10, 2023
Merged via the queue into main with commit 412e52a Oct 10, 2023
29 of 32 checks passed
@yangby-cryptape yangby-cryptape deleted the yangby/bugfix/incorrect-unit-test branch October 10, 2023 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants