Skip to content
Closed
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
9 changes: 0 additions & 9 deletions ci/lint/06_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,7 @@ else
fi
export COMMIT_RANGE

# This only checks that the trees are pure subtrees, it is not doing a full
# check with -r to not have to fetch all the remotes.
test/lint/git-subtree-check.sh src/crypto/ctaes
test/lint/git-subtree-check.sh src/secp256k1
test/lint/git-subtree-check.sh src/minisketch
test/lint/git-subtree-check.sh src/leveldb
test/lint/git-subtree-check.sh src/crc32c
RUST_BACKTRACE=1 "${LINT_RUNNER_PATH}/test_runner"
test/lint/check-doc.py
test/lint/all-lint.py

if [ "$CIRRUS_REPO_FULL_NAME" = "bitcoin/bitcoin" ] && [ "$CIRRUS_PR" = "" ] ; then
# Sanity check only the last few commits to get notified of missing sigs,
Expand Down
1 change: 1 addition & 0 deletions ci/lint_imagefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ENV LC_ALL=C.UTF-8
COPY ./.python-version /.python-version
COPY ./ci/lint/container-entrypoint.sh /entrypoint.sh
COPY ./ci/lint/04_install.sh /install.sh
COPY ./test/lint/test_runner /test/lint/test_runner

RUN /install.sh && \
echo 'alias lint="./ci/lint/06_script.sh"' >> ~/.bashrc && \
Expand Down
2 changes: 1 addition & 1 deletion src/hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ unsigned int MurmurHash3(unsigned int nHashSeed, Span<const unsigned char> vData
void BIP32Hash(const ChainCode &chainCode, unsigned int nChild, unsigned char header, const unsigned char data[32], unsigned char output[64])
{
unsigned char num[4];
WriteBE32(num, nChild);
WriteBE32(num, nChild);
CHMAC_SHA512(chainCode.begin(), chainCode.size()).Write(&header, 1).Write(data, 32).Write(num, 4).Finalize(output);
}

Expand Down
3 changes: 2 additions & 1 deletion src/outputtype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CTxDestination GetDestinationForKey(const CPubKey& key, OutputType type)
{
switch (type) {
case OutputType::LEGACY: return PKHash(key);
case OutputType::P2SH_SEGWIT:
case OutputType::P2SH_SEGWIT:
case OutputType::BECH32: {
if (!key.IsCompressed()) return PKHash(key);
CTxDestination witdest = WitnessV0KeyHash(key);
Expand Down Expand Up @@ -102,6 +102,7 @@ CTxDestination AddAndGetDestinationForScript(FillableSigningProvider& keystore,
}
}
case OutputType::BECH32M:

case OutputType::UNKNOWN: {} // This function should not be used for BECH32M or UNKNOWN, so let it assert
} // no default case, so the compiler can warn about missing cases
assert(false);
Expand Down
4 changes: 2 additions & 2 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ std::optional<std::vector<int>> CalculatePrevHeights(
} // namespace

std::optional<LockPoints> CalculateLockPointsAtTip(
CBlockIndex* tip,
CBlockIndex* tip,
const CCoinsView& coins_view,
const CTransaction& tx)
{
Expand All @@ -202,7 +202,7 @@ std::optional<LockPoints> CalculateLockPointsAtTip(
if (!prev_heights.has_value()) return std::nullopt;

CBlockIndex next_tip;
next_tip.pprev = tip;
next_tip.pprev = tip;
// When SequenceLocks() is called within ConnectBlock(), the height
// of the block *being* evaluated is what is used.
// Thus if we want to know if a transaction can be part of the
Expand Down
61 changes: 58 additions & 3 deletions test/lint/test_runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use std::path::PathBuf;
use std::process::Command;
use std::process::ExitCode;

use String as LintError;
type LintError = String;
type LintResult = Result<(), LintError>;
type LintFn = fn() -> LintResult;

/// Return the git command
fn git() -> Command {
Expand All @@ -31,7 +33,31 @@ fn get_git_root() -> String {
check_output(git().args(["rev-parse", "--show-toplevel"])).unwrap()
}

fn lint_std_filesystem() -> Result<(), LintError> {
fn lint_subtree() -> LintResult {
// This only checks that the trees are pure subtrees, it is not doing a full
// check with -r to not have to fetch all the remotes.
let mut good = true;
for subtree in [
"src/crypto/ctaes",
"src/secp256k1",
"src/minisketch",
"src/leveldb",
"src/crc32c",
] {
good &= Command::new("test/lint/git-subtree-check.sh")
.arg(subtree)
.status()
.expect("command_error")
.success();
}
if good {
Ok(())
} else {
Err("".to_string())
}
}

fn lint_std_filesystem() -> LintResult {
let found = git()
.args([
"grep",
Expand All @@ -55,8 +81,37 @@ fs:: namespace, which has unsafe filesystem functions marked as deleted.
}
}

fn lint_doc() -> LintResult {
if Command::new("test/lint/check-doc.py")
.status()
.expect("command error")
.success()
{
Ok(())
} else {
Err("".to_string())
}
}

fn lint_all() -> LintResult {
if Command::new("test/lint/all-lint.py")
.status()
.expect("command error")
.success()
{
Ok(())
} else {
Err("".to_string())
}
}

fn main() -> ExitCode {
let test_list = [("std::filesystem check", lint_std_filesystem)];
let test_list: Vec<(&str, LintFn)> = vec![
("subtree check", lint_subtree),
("std::filesystem check", lint_std_filesystem),
("-help=1 documentation check", lint_doc),
("all-lint.py script", lint_all),
];

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

Expand Down