Skip to content

Commit

Permalink
Merge remote-tracking branch 'bitcoin/master' into btc-master
Browse files Browse the repository at this point in the history
  • Loading branch information
mxaddict committed Jan 19, 2024
2 parents ca17d66 + 5f3a057 commit e7a1e33
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 71 deletions.
5 changes: 2 additions & 3 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2785,12 +2785,11 @@ static RPCHelpMan loadtxoutset()
if (!chainman.ActivateSnapshot(afile, metadata, false)) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to load UTXO snapshot " + fs::PathToString(path));
}
CBlockIndex* new_tip{WITH_LOCK(::cs_main, return chainman.ActiveTip())};

UniValue result(UniValue::VOBJ);
result.pushKV("coins_loaded", metadata.m_coins_count);
result.pushKV("tip_hash", new_tip->GetBlockHash().ToString());
result.pushKV("base_height", new_tip->nHeight);
result.pushKV("tip_hash", snapshot_start_block->GetBlockHash().ToString());
result.pushKV("base_height", snapshot_start_block->nHeight);
result.pushKV("path", fs::PathToString(path));
return result;
},
Expand Down
30 changes: 1 addition & 29 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,35 +326,7 @@ Use the `-v` option for verbose output.

### Lint tests

#### Dependencies

| Lint test | Dependency |
|-----------|:----------:|
| [`lint-python.py`](lint/lint-python.py) | [flake8](https://gitlab.com/pycqa/flake8)
| [`lint-python.py`](lint/lint-python.py) | [lief](https://github.com/lief-project/LIEF)
| [`lint-python.py`](lint/lint-python.py) | [mypy](https://github.com/python/mypy)
| [`lint-python.py`](lint/lint-python.py) | [pyzmq](https://github.com/zeromq/pyzmq)
| [`lint-python-dead-code.py`](lint/lint-python-dead-code.py) | [vulture](https://github.com/jendrikseipp/vulture)
| [`lint-shell.py`](lint/lint-shell.py) | [ShellCheck](https://github.com/koalaman/shellcheck)
| [`lint-spelling.py`](lint/lint-spelling.py) | [codespell](https://github.com/codespell-project/codespell)

In use versions and install instructions are available in the [CI setup](../ci/lint/04_install.sh).

Please be aware that on Linux distributions all dependencies are usually available as packages, but could be outdated.

#### Running the tests

Individual tests can be run by directly calling the test script, e.g.:

```
test/lint/lint-files.py
```

You can run all the shell-based lint tests by running:

```
test/lint/all-lint.py
```
See the README in [test/lint](/test/lint).

# Writing functional tests

Expand Down
3 changes: 1 addition & 2 deletions test/functional/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,5 +1021,4 @@ def is_bdb_compiled(self):
return self.config["components"].getboolean("USE_BDB")

def has_blockfile(self, node, filenum: str):
blocksdir = node.datadir_path / self.chain / 'blocks'
return (blocksdir / f"blk{filenum}.dat").is_file()
return (node.blocks_path/ f"blk{filenum}.dat").is_file()
30 changes: 25 additions & 5 deletions test/lint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,36 @@ result is cached and it prevents issues when the image changes.
test runner
===========

To run the checks in the test runner outside the docker, use:
To run all the lint checks in the test runner outside the docker, use:

```sh
( cd ./test/lint/test_runner/ && cargo fmt && cargo clippy && cargo run )
```

#### Dependencies

| Lint test | Dependency |
|-----------|:----------:|
| [`lint-python.py`](lint/lint-python.py) | [flake8](https://gitlab.com/pycqa/flake8)
| [`lint-python.py`](lint/lint-python.py) | [lief](https://github.com/lief-project/LIEF)
| [`lint-python.py`](lint/lint-python.py) | [mypy](https://github.com/python/mypy)
| [`lint-python.py`](lint/lint-python.py) | [pyzmq](https://github.com/zeromq/pyzmq)
| [`lint-python-dead-code.py`](lint/lint-python-dead-code.py) | [vulture](https://github.com/jendrikseipp/vulture)
| [`lint-shell.py`](lint/lint-shell.py) | [ShellCheck](https://github.com/koalaman/shellcheck)
| [`lint-spelling.py`](lint/lint-spelling.py) | [codespell](https://github.com/codespell-project/codespell)

In use versions and install instructions are available in the [CI setup](../ci/lint/04_install.sh).

Please be aware that on Linux distributions all dependencies are usually available as packages, but could be outdated.

#### Running the tests

Individual tests can be run by directly calling the test script, e.g.:

```
test/lint/lint-files.py
```

check-doc.py
============
Check for missing documentation of command line options.
Expand Down Expand Up @@ -59,7 +83,3 @@ To do so, add the upstream repository as remote:
```
git remote add --fetch secp256k1 https://github.com/bitcoin-core/secp256k1.git
```

all-lint.py
===========
Calls other scripts with the `lint-` prefix.
23 changes: 0 additions & 23 deletions test/lint/all-lint.py

This file was deleted.

32 changes: 23 additions & 9 deletions test/lint/test_runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// file COPYING or https://opensource.org/license/mit/.

use std::env;
use std::fs;
use std::path::PathBuf;
use std::process::Command;
use std::process::ExitCode;
Expand All @@ -29,8 +30,8 @@ fn check_output(cmd: &mut std::process::Command) -> Result<String, LintError> {
}

/// Return the git root as utf8, or panic
fn get_git_root() -> String {
check_output(git().args(["rev-parse", "--show-toplevel"])).unwrap()
fn get_git_root() -> PathBuf {
PathBuf::from(check_output(git().args(["rev-parse", "--show-toplevel"])).unwrap())
}

fn lint_subtree() -> LintResult {
Expand Down Expand Up @@ -94,11 +95,24 @@ fn lint_doc() -> LintResult {
}

fn lint_all() -> LintResult {
if Command::new("test/lint/all-lint.py")
.status()
.expect("command error")
.success()
{
let mut good = true;
let lint_dir = get_git_root().join("test/lint");
for entry in fs::read_dir(lint_dir).unwrap() {
let entry = entry.unwrap();
let entry_fn = entry.file_name().into_string().unwrap();
if entry_fn.starts_with("lint-")
&& entry_fn.ends_with(".py")
&& !Command::new("python3")
.arg(entry.path())
.status()
.expect("command error")
.success()
{
good = false;
println!("^---- failure generated from {}", entry_fn);
}
}
if good {
Ok(())
} else {
Err("".to_string())
Expand All @@ -110,10 +124,10 @@ fn main() -> ExitCode {
("subtree check", lint_subtree),
("std::filesystem check", lint_std_filesystem),
("-help=1 documentation check", lint_doc),
("all-lint.py script", lint_all),
("lint-*.py scripts", lint_all),
];

let git_root = PathBuf::from(get_git_root());
let git_root = get_git_root();

let mut test_failed = false;
for (lint_name, lint_fn) in test_list {
Expand Down

0 comments on commit e7a1e33

Please sign in to comment.