Skip to content

V114 async rc0 #31

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 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
890e77b
add tx_pool test
gpBlockchain Dec 6, 2023
a197a14
add replace test
gpBlockchain Dec 6, 2023
62f55c5
support v113
gpBlockchain Dec 20, 2023
93efe46
support v113
gpBlockchain Dec 20, 2023
e907d24
debug rpc
gpBlockchain Dec 20, 2023
0556bee
debug
gpBlockchain Dec 20, 2023
68aecf5
support 113
gpBlockchain Dec 20, 2023
dedd4b9
skip max test
gpBlockchain Dec 20, 2023
754b18e
update 0.113.0-rc2
gpBlockchain Dec 22, 2023
ecc00f0
add test_unsubscribe
gpBlockchain Dec 22, 2023
c7e1302
update ckb-light-client
gpBlockchain Dec 25, 2023
32bf5cb
Update download.py
gpBlockchain Jan 3, 2024
104180d
update ckb-light-client version
gpBlockchain Jan 5, 2024
a53831e
fix light sync failed
gpBlockchain Jan 8, 2024
137bacf
git add download.py test_node.py
15168316096 Feb 4, 2024
aaec54d
update env
15168316096 Feb 5, 2024
812b1eb
Merge branch 'main' into v114
gpBlockchain Feb 5, 2024
57cc8d3
fix ci
gpBlockchain Feb 5, 2024
8d7017d
support light-client 0.3.6
gpBlockchain Feb 9, 2024
5a72f41
update ckb-cli
gpBlockchain Feb 9, 2024
ef2f18d
update 114 ckb-cli
gpBlockchain Feb 18, 2024
b349fdc
update rc3
gpBlockchain Feb 22, 2024
e3f92e4
fix test_03_ckb_light_client_after_hardfork.py
gpBlockchain Feb 23, 2024
717476b
Merge branch 'main' into v114
gpBlockchain Feb 23, 2024
30e8454
revert ckb2023=1
gpBlockchain Feb 26, 2024
524adec
add get_cell test
gpBlockchain Feb 26, 2024
fbcc9e8
skip light tx in after 2023
gpBlockchain Feb 26, 2024
2facdd1
download async ckb
gpBlockchain Feb 28, 2024
060becf
skip test case
gpBlockchain Feb 28, 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
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
prepare:
python -m venv venv
. venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
echo "install ckb"
Expand Down Expand Up @@ -32,14 +34,14 @@ test:
echo "Error: Failed HTML files found in the 'report' directory"; \
exit 1; \
fi

clean:
-pkill ckb
pkill ckb
rm -rf tmp
rm -rf download
rm -rf report
rm -rf source/ckb-cli
rm -rf source/ckb-cli-old

rm -rf source/ckb-cli*
rm -rf ckb-*

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

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

DOWNLOAD_DIR = "download"
SYSTEMS = {
'Windows': {
Expand Down
4 changes: 3 additions & 1 deletion download_ckb_light_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import requests
from tqdm import tqdm

versions = ['0.2.4', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5'] # Replace with your versions

versions = ['0.2.4', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6'] # Replace with your versions

DOWNLOAD_DIR = "download"
SYSTEMS = {
'Windows': {
Expand Down
4 changes: 3 additions & 1 deletion framework/test_light_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ class CkbLightClientConfigPath(Enum):
V0_3_3 = ("source/template/ckb_light_client/0.3.0/testnet.toml.j2", "download/0.3.3/ckb-light-client")
V0_3_4 = ("source/template/ckb_light_client/0.3.0/testnet.toml.j2", "download/0.3.4/ckb-light-client")
V0_3_5 = ("source/template/ckb_light_client/0.3.0/testnet.toml.j2", "download/0.3.5/ckb-light-client")
CURRENT_TEST = ("source/template/ckb_light_client/0.3.0/testnet.toml.j2", "download/0.3.5/ckb-light-client")
V0_3_6 = ("source/template/ckb_light_client/0.3.0/testnet.toml.j2", "download/0.3.6/ckb-light-client")

CURRENT_TEST = ("source/template/ckb_light_client/0.3.0/testnet.toml.j2", "download/0.3.6/ckb-light-client")

def __init__(self, ckb_light_client_config_path, ckb_light_bin_path):
self.ckb_light_client_config_path = ckb_light_client_config_path
Expand Down
16 changes: 12 additions & 4 deletions framework/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,24 @@

class CkbNodeConfigPath(Enum):
CURRENT_TEST = (
"source/template/ckb/v113/ckb.toml.j2",
"source/template/ckb/v112/ckb.toml.j2",
"source/template/ckb/v112/ckb-miner.toml.j2",
"source/template/ckb/v112/specs/dev.toml",
"download/0.113.1"
"download/develop"
)
CURRENT_MAIN = ("source/template/ckb/v112/ckb.toml.j2",
"source/template/ckb/v112/ckb-miner.toml.j2",
"source/template/specs/mainnet.toml.j2",
"download/0.113.1")
"download/develop")

v114 = (
"source/template/ckb/v114/ckb.toml.j2",
"source/template/ckb/v114/ckb-miner.toml.j2",
"source/template/ckb/v114/specs/dev.toml",
"download/0.114.0"
)



V113 = (
"source/template/ckb/v113/ckb.toml.j2",
Expand All @@ -41,7 +50,6 @@ class CkbNodeConfigPath(Enum):
"download/0.112.1"
)


V111 = (
"source/template/ckb/v111/ckb.toml.j2",
"source/template/ckb/v111/ckb-miner.toml.j2",
Expand Down
8 changes: 8 additions & 0 deletions prepare.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
set -e
git clone https://github.com/gpBlockchain/ckb-cli.git
cd ckb-cli
git checkout v114
make prod
cp target/release/ckb-cli ../source/ckb-cli
cd ../
cp download/0.110.2/ckb-cli ./source/ckb-cli-old
git clone https://github.com/nervosnetwork/ckb.git
cd ckb
git checkout pkg/ckb-async-download-rc0
make prod
cd ../
cp -rf download/0.114.0 download/develop
cp ckb/target/prod/ckb download/develop/ckb
#git clone https://github.com/quake/ckb-light-client.git
#cd ckb-light-client
#git checkout quake/fix-set-scripts-partial-bug
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pytest==7.3.2
requests==2.31.0
tqdm==4.65.0
pytest-html==3.2.0
PyYAML==6.0
PyYAML==6.0.1
pytest-docs==0.1.0
parameterized==0.9.0
toml==0.10.2
Expand Down
2 changes: 1 addition & 1 deletion source/template/ckb/v113/specs/dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ genesis_epoch_length = 1000
permanent_difficulty_in_dummy = true

[params.hardfork]
ckb2023 = 1000000
ckb2023 = 1

[pow]
func = "Dummy"
27 changes: 14 additions & 13 deletions test_cases/ckb2023/test_03_ckb_light_client_after_hardfork.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ def get_successful_files():
return [
f"{get_project_root()}/source/contract/test_cases/ckb_get_memory_limit",
f"{get_project_root()}/source/contract/test_cases/atomic_i32",
f"{get_project_root()}/source/contract/test_cases/spawn_current_cycles",
f"{get_project_root()}/source/contract/test_cases/load_block_extension",
f"{get_project_root()}/source/contract/test_cases/spawn_current_cycles"
]


Expand Down Expand Up @@ -71,6 +70,7 @@ def setup_class(cls):
cls.ckb_light_node_current.getClient().set_scripts([{"script": {
"code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type",
"args": account['lock_arg']}, "script_type": "lock", "block_number": "0x0"}])

cls.cluster.ckb_nodes[0].start_miner()
cls.Node.wait_light_sync_height(cls.ckb_light_node_current, 2000, 200)

Expand Down Expand Up @@ -102,6 +102,7 @@ def test_01_ckb_light_client_0_3_1_link_node(self):
ckb_light_node.stop()
ckb_light_node.clean()


def test_02_ckb_light_client_current_link_node(self):
"""
1. setScript miner account
Expand All @@ -117,6 +118,7 @@ def test_02_ckb_light_client_current_link_node(self):
"args": account['lock_arg']}, "script_type": "lock", "block_number": "0x0"}])
self.Node.wait_light_sync_height(self.ckb_light_node_current, 2000, 200)


def test_03_ckb_light_client_current_set_script_data2(self):
"""
1. set data2 account
Expand All @@ -130,6 +132,7 @@ def test_03_ckb_light_client_current_set_script_data2(self):
"args": account['lock_arg']}, "script_type": "lock", "block_number": "0x0"}])
self.Node.wait_light_sync_height(self.ckb_light_node_current, 2000, 200)


def test_04_ckb_light_client_current_transfer_data2_tx(self):
"""
1. send data2 tx on the ckb light client
Expand All @@ -143,6 +146,7 @@ def test_04_ckb_light_client_current_transfer_data2_tx(self):
"args": account['lock_arg']}, "script_type": "lock", "block_number": "0x0"}])
self.Node.wait_light_sync_height(self.ckb_light_node_current, 2000, 200)


tx_hash = self.Ckb_cli.wallet_transfer_by_private_key(self.Config.MINER_PRIVATE_1,
"ckt1qp5usrt2syzfjj7acyetk45vj57kp7hq4jfg4ky8e9k7ss6v52neqpqh7xtq0",
140,
Expand All @@ -155,6 +159,7 @@ def test_04_ckb_light_client_current_transfer_data2_tx(self):

assert tx_hash == light_tx_hash


def test_05_ckb_light_client_current_spawn_contract_use_data2(self):
"""
1. send spawn tx ( hash type : data2), on the ckb light client
Expand Down Expand Up @@ -188,6 +193,7 @@ def test_05_ckb_light_client_current_spawn_contract_use_data2(self):

assert tx_hash == light_tx_hash


def test_05_ckb_light_client_current_spawn_contract_use_type(self):
"""
1. send spawn tx ( hash type : type), on the ckb light client
Expand Down Expand Up @@ -220,17 +226,11 @@ def test_05_ckb_light_client_current_spawn_contract_use_type(self):
assert tx_hash == light_tx_hash

# @pytest.mark.skip
@parameterized.expand(success_files)
def test_06_ckb_light_client_deploy_and_invoke_contract(self, path):
self.cluster.ckb_nodes[0].start_miner()
self.deploy_and_invoke(self.Config.MINER_PRIVATE_1, path, self.cluster.ckb_nodes[0])
self.cluster.ckb_nodes[0].start_miner()

# def test_07_ckb_light_client_deploy_and_invoke_contract(self):
# @parameterized.expand(success_files)
# def test_06_ckb_light_client_deploy_and_invoke_contract(self, path):
# self.cluster.ckb_nodes[0].start_miner()
# self.deploy_and_invoke(self.Config.MINER_PRIVATE_1, path, self.cluster.ckb_nodes[0])
# self.cluster.ckb_nodes[0].start_miner()
# self.deploy_and_invoke(self.Config.MINER_PRIVATE_1,
# f"{get_project_root()}/source/contract/test_cases/spawn_demo", self.cluster.ckb_nodes[0])
# self.cluster.ckb_nodes[0].stop_miner()

def deploy_and_invoke(self, account, path, node, try_count=5):
if try_count < 0:
Expand All @@ -241,6 +241,7 @@ def deploy_and_invoke(self, account, path, node, try_count=5):
enable_type_id=True,
api_url=node.getClient().url)
self.Miner.miner_until_tx_committed(node, deploy_hash)

self.Node.wait_light_sync_height(self.ckb_light_node_current, node.getClient().get_tip_block_number(), 200)
self.Node.wait_fetch_transaction(self.ckb_light_node_current, deploy_hash, "fetched")
tx_msg = self.Contract.build_invoke_ckb_contract(account_private=account,
Expand All @@ -250,8 +251,8 @@ def deploy_and_invoke(self, account, path, node, try_count=5):
hash_type="type",
api_url=node.getClient().url)
self.Node.wait_light_sync_height(self.ckb_light_node_current, node.getClient().get_tip_block_number(), 200)
light_tx_hash = self.ckb_light_node_current.getClient().send_transaction(tx_msg)
for i in range(100):
light_tx_hash = self.ckb_light_node_current.getClient().send_transaction(tx_msg)
light_ret = node.getClient().get_transaction(light_tx_hash)
time.sleep(1)
print("light ret status:", light_ret['tx_status']['status'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def deploy_and_invoke(self, account, path, node, try_count=5):
hash_type="type",
api_url=node.getClient().url)
self.Node.wait_light_sync_height(self.ckb_light_node_current, node.getClient().get_tip_block_number(), 200)
light_tx_hash = self.ckb_light_node_current.getClient().send_transaction(tx_msg)
for i in range(100):
light_tx_hash = self.ckb_light_node_current.getClient().send_transaction(tx_msg)
light_ret = node.getClient().get_transaction(light_tx_hash)
time.sleep(1)
print("light ret status:", light_ret['tx_status']['status'])
Expand Down
1 change: 0 additions & 1 deletion test_cases/issue/test_4111.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def deploy_and_invoke(self, account, path, node, try_count=5):
api_url=node.getClient().url, fee=-100)
return invoke_hash
except Exception as e:
print("!!!e:", e)
if "Resolve failed Dead" in e.args[0]:
try_count -= 1
time.sleep(3)
Expand Down
2 changes: 2 additions & 0 deletions test_cases/replace_rpc/test_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ def test_websocket(self):
# 113 support
with pytest.raises(Exception) as exc_info:
socket = self.node113.subscribe_websocket("new_tip_header", self.node113.rpcUrl.replace("http://", ""))

expected_error_message = "not allowed. POST or OPTIONS is required"

assert expected_error_message in exc_info.value.args[0], \
f"Expected substring '{expected_error_message}' not found in actual string '{exc_info.value.args[0]}'"

Expand Down
2 changes: 1 addition & 1 deletion test_cases/replace_rpc/test_telnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ def test_unsubscribe(self):
unsubscribe topic 1
unsubscribe successful
"""

client = self.node113.getClient()
client.url = f"http://{self.node113.ckb_config['ckb_rpc_listen_address']}"

socket = self.node113.subscribe_telnet("new_tip_header")
self.Miner.miner_with_version(self.node113, "0x0")
ret = socket.read_very_eager()
Expand Down
95 changes: 95 additions & 0 deletions test_cases/rpc/test_get_cells.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
from framework.helper.contract import deploy_ckb_contract, invoke_ckb_contract, get_ckb_contract_codehash
from framework.util import get_project_root
from framework.config import MINER_PRIVATE_1
from framework.helper.miner import miner_until_tx_committed
from test_cases.rpc.node_fixture import get_cluster


class TestGetCells:

def test_get_cells_output_data_filter_mode(self, get_cluster):
cluster = get_cluster
deploy_hash = deploy_ckb_contract(MINER_PRIVATE_1,
f"{get_project_root()}/source/contract/always_success",
enable_type_id=True,
api_url=cluster.ckb_nodes[0].getClient().url)
miner_until_tx_committed(cluster.ckb_nodes[0], deploy_hash)
for i in range(1, 10):
invoke_hash = invoke_ckb_contract(account_private=MINER_PRIVATE_1,
contract_out_point_tx_hash=deploy_hash,
contract_out_point_tx_index=0,
type_script_arg="0x02", data=f"0x{i:02x}{i:02x}",
hash_type="type",
api_url=cluster.ckb_nodes[0].getClient().url)
miner_until_tx_committed(cluster.ckb_nodes[0], invoke_hash)
invoke_hash = invoke_ckb_contract(account_private=MINER_PRIVATE_1,
contract_out_point_tx_hash=deploy_hash,
contract_out_point_tx_index=0,
type_script_arg="0x02", data="0xffff00000000ffff",
hash_type="type",
api_url=cluster.ckb_nodes[0].getClient().url)
miner_until_tx_committed(cluster.ckb_nodes[0], invoke_hash)

codehash = get_ckb_contract_codehash(deploy_hash, 0,
enable_type_id=True,
api_url=cluster.ckb_nodes[0].getClient().url)

# output_data_filter_mode : prefix

ret = cluster.ckb_nodes[0].getClient().get_cells({
"script": {
"code_hash": codehash,
"hash_type": "type",
"args": "0x02"
},
"script_type": "type",
"filter": {
"output_data": "0x01",
"output_data_filter_mode": "prefix"
}
}, "asc", "0xff", None)

assert ret['objects'][0]['output_data'] == '0x0101'
ret = cluster.ckb_nodes[0].getClient().get_cells({
"script": {
"code_hash": codehash,
"hash_type": "type",
"args": "0x02"
},
"script_type": "type",
"filter": {
"output_data": "0x02",
"output_data_filter_mode": "prefix"
}
}, "asc", "0xff", None)
assert ret['objects'][0]['output_data'] == '0x0202'

# output_data_filter_mode : exact
ret = cluster.ckb_nodes[0].getClient().get_cells({
"script": {
"code_hash": codehash,
"hash_type": "type",
"args": "0x02"
},
"script_type": "type",
"filter": {
"output_data": "0x0303",
"output_data_filter_mode": "exact"
}
}, "asc", "0xff", None)
assert ret['objects'][0]['output_data'] == '0x0303'

# output_data_filter_mode : partial
ret = cluster.ckb_nodes[0].getClient().get_cells({
"script": {
"code_hash": codehash,
"hash_type": "type",
"args": "0x02"
},
"script_type": "type",
"filter": {
"output_data": "0x00000000ffff",
"output_data_filter_mode": "partial"
}
}, "asc", "0xff", None)
assert ret['objects'][0]['output_data'] == '0xffff00000000ffff'
Loading