Skip to content

Gp/failed tx #41

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

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
34c0cbe
Update download.py
gpBlockchain Mar 21, 2024
8139663
issue-4363
gpBlockchain Mar 21, 2024
a97e8af
rich-indexer support indexer api
15168316096 Mar 21, 2024
88d9db8
debug workflows run when case run error
15168316096 Mar 21, 2024
21b5686
debug workflows only run fail case when case run error
15168316096 Mar 21, 2024
025fa41
debug workflows exit signal when case run error
15168316096 Mar 21, 2024
0464dc9
debug workflows exit signal when case run error
15168316096 Mar 21, 2024
21c63b5
recover all cases run
15168316096 Mar 21, 2024
a887800
makefile loop testcases
15168316096 Mar 21, 2024
2ef082f
makefile loop sats
15168316096 Mar 21, 2024
30c6e34
makefile loop sats fixed
15168316096 Mar 21, 2024
725672e
makefile loop sats fixed
15168316096 Mar 21, 2024
0d019bc
fix v112 node ckb toml and open html report
15168316096 Mar 29, 2024
1b1c0f4
fix ci failed
gpBlockchain Mar 29, 2024
98c7f1a
fix ci
15168316096 Mar 29, 2024
9002be4
Merge remote-tracking branch 'origin/v115' into v115
15168316096 Mar 29, 2024
f20a295
fix ci
15168316096 Mar 29, 2024
c01a393
fix ci
15168316096 Mar 29, 2024
6e16fda
fix ci
15168316096 Mar 29, 2024
f1d11da
fix ci
15168316096 Mar 29, 2024
508c17e
fix ci add debug
15168316096 Mar 29, 2024
ed04a13
test
15168316096 Apr 1, 2024
552e6cf
test
15168316096 Apr 1, 2024
861eeb3
test 2
15168316096 Apr 1, 2024
95fcaf7
test 3
15168316096 Apr 1, 2024
073b916
test 4
15168316096 Apr 1, 2024
52c467d
test 5
15168316096 Apr 1, 2024
709230c
test 6
15168316096 Apr 1, 2024
33bc112
test 7
15168316096 Apr 1, 2024
82f6af9
test 8
15168316096 Apr 1, 2024
7b0477c
test again
15168316096 Apr 1, 2024
cd97448
test again 2
15168316096 Apr 1, 2024
d3cdabc
test again 3
15168316096 Apr 1, 2024
21a5028
test output
15168316096 Apr 1, 2024
3d9905d
ckb v115.0 cycle test
15168316096 Apr 1, 2024
e3be219
add sync failed test
gpBlockchain Apr 11, 2024
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
52 changes: 30 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.PHONY: prepare test clean docs

prepare:
python3 -m venv venv
. venv/bin/activate
Expand All @@ -10,31 +12,37 @@ prepare:
echo "install ckb cli"
sh prepare.sh

check_failed_html:
@if test -n "$$(ls report/*failed.html 2>/dev/null)"; then \
echo "Error: Failed HTML files found in the 'report' directory"; \
exit 1; \
fi
test_cases := \
test_cases/replace_rpc \
test_cases/ckb_cli \
test_cases/ckb2023 \
test_cases/contracts \
test_cases/example \
test_cases/framework \
test_cases/light_client \
test_cases/mocking \
test_cases/node_compatible \
test_cases/rpc \
test_cases/soft_fork \
test_cases/issue \
test_cases/tx_pool_refactor \
test_cases/feature

test:
bash test.sh test_cases/replace_rpc
bash test.sh test_cases/ckb2023
bash test.sh test_cases/ckb_cli
bash test.sh test_cases/contracts
bash test.sh test_cases/example
bash test.sh test_cases/framework
bash test.sh test_cases/light_client
bash test.sh test_cases/mocking
bash test.sh test_cases/node_compatible
bash test.sh test_cases/rpc
bash test.sh test_cases/soft_fork
bash test.sh test_cases/issue
bash test.sh test_cases/tx_pool_refactor
bash test.sh test_cases/feature
@if test -n "$$(ls report/*failed.html 2>/dev/null)"; then \
echo "Error: Failed HTML files found in the 'report' directory"; \
@failed_cases=; \
for test_case in $(test_cases); do \
echo "Running tests for $$test_case"; \
if ! bash test.sh "$$test_case"; then \
echo "$$test_case" >> failed_test_cases.txt; \
fi \
done; \
if [ -s failed_test_cases.txt ]; then \
echo "Some test cases failed: $$(cat failed_test_cases.txt)"; \
rm -f failed_test_cases.txt; \
exit 1; \
fi


clean:
pkill ckb
rm -rf tmp
Expand All @@ -44,4 +52,4 @@ clean:
rm -rf ckb-*

docs:
python -m pytest --docs=docs/soft.md --doc-type=md test_cases/soft_fork
python -m pytest --docs=docs/soft.md --doc-type=md test_cases/soft_fork
2 changes: 1 addition & 1 deletion download.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import requests
from tqdm import tqdm

versions = ['0.109.0', '0.110.2', '0.111.0', '0.112.1', '0.113.1', "0.114.0", "0.115.0-rc1"] # Replace with your versions
versions = ['0.109.0', '0.110.2', '0.111.0', '0.112.1', '0.113.1', "0.114.0", "0.115.0"] # Replace with your versions


DOWNLOAD_DIR = "download"
Expand Down
2 changes: 1 addition & 1 deletion framework/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CkbNodeConfigPath(Enum):
"source/template/specs/mainnet.toml.j2",
"download/0.115.0")

v115_rc1 = (
v115 = (
"source/template/ckb/v115/ckb.toml.j2",
"source/template/ckb/v115/ckb-miner.toml.j2",
"source/template/ckb/v115/specs/dev.toml",
Expand Down
4 changes: 2 additions & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[pytest]
;ci
;addopts = --html=report/report.html
addopts = --html=report/report.html
;debug
addopts = -s
;addopts = -s
19 changes: 0 additions & 19 deletions source/template/ckb/v112/ckb.toml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -179,25 +179,6 @@ block_uncles_cache_size = {{ ckb_store_block_uncles_cache_size | default("
# [indexer_v2]
# # Indexing the pending txs in the ckb tx-pool
# index_tx_pool = false

# # Customize block filtering rules to index only retained blocks
block_filter = "block.header.number.to_uint() >= \"0x0\".to_uint()"
# # Customize cell filtering rules to index only retained cells
cell_filter = "let script = output.type;script!=() && script.code_hash == \"0x00000000000000000000000000000000000000000000000000545950455f4944\""
# # The initial tip can be set higher than the current indexer tip as the starting height for indexing.
init_tip_hash = "0x8fbd0ec887159d2814cee475911600e3589849670f5ee1ed9798b38fdeef4e44"
#
# # CKB rich-indexer has its unique configuration.
[indexer_v2.rich_indexer]
# # By default, it uses an embedded SQLite database.
# # Alternatively, you can set up a PostgreSQL database service and provide the connection parameters.
# db_type = "postgres"
# db_name = "ckb-rich-indexer"
# db_host = "127.0.0.1"
# db_port = 5432
# db_user = "postgres"
# db_password = "123456"

[block_assembler]
code_hash = "{{ ckb_block_assembler_code_hash }}"
args = "{{ ckb_block_assembler_args }}"
Expand Down
59 changes: 45 additions & 14 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,45 @@
python -m pytest $1
if [ $? == 1 ];then
pkill ckb
sleep 3
rm -rf tmp
echo "run failed "
mv report/report.html report/${1////_}_failed.html
exit 0
fi
pkill ckb
sleep 3
rm -rf tmp
rm -rf report/report.html
echo "run cusscessful"
#!/bin/bash

# Initialize variables to store passed and failed test cases
passed_cases=""
failed_cases="None"

# Function to run pytest and process the output
# Function to run pytest and process the output
run_test() {
# Run pytest with verbose and no capture, redirect stderr to stdout
pytest_output=$(python3 -m pytest -vv "$1" 2>&1)

# Print pytest output
echo "$pytest_output"

# Check if pytest output contains "skipped"
if grep -q "skipped" <<< "$pytest_output"; then
echo "Test case $1 was skipped"
return 0 # Exit with success code
fi

# Check if pytest output contains "failed"
if grep -q "failed" <<< "$pytest_output"; then
# Handle failed test case
echo "Test case $1 failed"
failed_cases+=" $1"
return 1
fi

# Handle successful test case
echo "Test case $1 passed"
passed_cases+=" $1"
return 0
}


# Main loop to run tests for each test case
for test_case in "$@"; do
run_test "$test_case"
done

# Display summary of test results
echo "Summary:"
echo "Passed test cases:${passed_cases}"
echo "Failed test cases:${failed_cases}"
22 changes: 3 additions & 19 deletions test_cases/feature/test_generate_epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class TestGenerateEpochs(CkbTest):
@classmethod
def setup_class(cls):
nodes = [
cls.CkbNode.init_dev_by_port(cls.CkbNodeConfigPath.v114_rc3,
cls.CkbNode.init_dev_by_port(cls.CkbNodeConfigPath.CURRENT_TEST,
"feature/gene_rate_epochs/node{i}".format(i=i), 8114 + i,
8225 + i)
for
Expand All @@ -17,30 +17,16 @@ def setup_class(cls):
cls.ckb_spec_config_dict = read_toml_file(get_project_root() + "/" + cls.cluster.ckb_nodes[0].ckb_config_path.ckb_spec_path)
cls.cluster.ckb_nodes[0].startWithRichIndexer()
cls.cluster.ckb_nodes[1].start()
cls.Miner.make_tip_height_number(nodes[0], 1100)
cls.Miner.make_tip_height_number(nodes[0], 100)
cls.cluster.connected_all_nodes()
cls.Node.wait_cluster_height(cls.cluster, 1100, 100)
cls.Node.wait_cluster_height(cls.cluster, 100, 1000)

@classmethod
def teardown_class(cls):
print("\nTeardown TestClass1")
cls.cluster.stop_all_nodes()
cls.cluster.clean_all_nodes()

def test_demo(self):
"""
test
Returns:

"""
miner_ACCOUNT= self.Ckb_cli.util_key_info_by_private_key(self.Config.MINER_PRIVATE_1)
self.Ckb_cli.wallet_get_capacity(miner_ACCOUNT["address"]["testnet"],self.cluster.ckb_nodes[0].getClient().url)
self.Ckb_cli.wallet_get_live_cells(miner_ACCOUNT["address"]["testnet"],self.cluster.ckb_nodes[0].getClient().url)
self.Ckb_cli.wallet_get_capacity(miner_ACCOUNT["address"]["testnet"], self.cluster.ckb_nodes[1].getClient().url)
self.Ckb_cli.wallet_get_live_cells(miner_ACCOUNT["address"]["testnet"],
self.cluster.ckb_nodes[1].getClient().url)


def test_01_generate_epochs_0x2(self):
"""
调用generate_epochs 生成2个epoch 的number;
Expand Down Expand Up @@ -94,5 +80,3 @@ def parse_hex_string(hex_string):
return None
value = int(hex_string, 16)
return EpochNumberWithFraction(value)


2 changes: 1 addition & 1 deletion test_cases/rpc/node_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_cluster():
@pytest.fixture(scope='module')
def get_cluster_indexer():
nodes = [
CkbNode.init_dev_by_port(CkbNodeConfigPath.v115_rc1, "cluster_indexer/node{i}".format(i=i), 8114 + i,
CkbNode.init_dev_by_port(CkbNodeConfigPath.v115, "cluster_indexer/node{i}".format(i=i), 8114 + i,
8225 + i)
for
i in range(0, 2)
Expand Down
85 changes: 85 additions & 0 deletions test_cases/soft_fork/test_sync_failed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import time

from framework.basic import CkbTest
from framework.util import run_command, get_project_root

# use ckb0.110.1-rc1: generate DaoLockSizeMismatch tx in softfork before and after
DATA_ERROR_TAT = f"{get_project_root()}/source/data/data.err.tar.gz"


class TestSyncFailed(CkbTest):

def teardown_method(self, method):
super().teardown_method(method)
print("\nTearing down method", method.__name__)
self.node1.stop()
self.node1.clean()

self.node2.stop()
self.node2.clean()

self.node3.stop()
self.node3.clean()

def test_sync_other_node_again_after_failed(self):
"""
can't sync DaoLockSizeMismatch tx
- after softFork active
- starting_block_limiting_dao_withdrawing_lock <= dao deposit tx block number
6000 block contains DaoLockSizeMismatch tx
8669 block contains DaoLockSizeMismatch tx
1. can sync 6000 block
tip block num > 6000
2. node2 and node3 can't sync 8669 block
tip block == 8668
3. node2 miner
4. node2 restart and miner
5. node1 stop
6. link node2 and node3
7. node3 sync node2 successful

Returns:
"""
node1 = self.CkbNode.init_dev_by_port(self.CkbNodeConfigPath.V110_MAIN, "tx_pool_test/node1", 8114, 8227)
node2 = self.CkbNode.init_dev_by_port(self.CkbNodeConfigPath.CURRENT_MAIN, "tx_pool_test/node2", 8112, 8228)
node3 = self.CkbNode.init_dev_by_port(self.CkbNodeConfigPath.CURRENT_MAIN, "tx_pool_test/node3", 8113, 8229)
self.node1 = node1
self.node2 = node2
self.node3 = node3
node1.prepare(other_ckb_spec_config={"starting_block_limiting_dao_withdrawing_lock": "5494"})
node2.prepare(other_ckb_spec_config={"starting_block_limiting_dao_withdrawing_lock": "5494"})
node3.prepare(other_ckb_spec_config={"starting_block_limiting_dao_withdrawing_lock": "5494"})
tar_file(DATA_ERROR_TAT, node1.ckb_dir)
node1.start()
node2.start()
node3.start()
self.Miner.make_tip_height_number(node1, 15000)
node1.start_miner()
node1.connected(node2)
node1.connected(node3)
self.Node.wait_node_height(self.node2, 8668, 120)
self.Node.wait_node_height(self.node3, 8668, 120)
block_num = self.node2.getClient().get_tip_block_number()
assert block_num == 8668
time.sleep(10)
block_num = self.node2.getClient().get_tip_block_number()
assert block_num == 8668
node2_banned_result = node2.getClient().get_banned_addresses()
node3_banned_result = node3.getClient().get_banned_addresses()
assert "BlockIsInvalid" in node2_banned_result[0]['ban_reason']
assert "BlockIsInvalid" in node3_banned_result[0]['ban_reason']
node1.stop()
node2.getClient().clear_banned_addresses()
node3.getClient().clear_banned_addresses()
self.Miner.make_tip_height_number(node2, 10000)
node2.restart()
self.node2.start_miner()
node2.connected(node3)
node3.connected(node2)

self.Node.wait_node_height(self.node2, 10001, 120)
self.Node.wait_node_height(self.node3, 10001, 120)


def tar_file(src_tar, dec_data):
run_command(f"tar -xvf {src_tar} -C {dec_data}")
Loading