diff --git a/.github/workflows/fiber-stable-action.yml b/.github/workflows/fiber-stable-action.yml new file mode 100644 index 00000000..e6739a6b --- /dev/null +++ b/.github/workflows/fiber-stable-action.yml @@ -0,0 +1,63 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: fiber stable action +on: + workflow_dispatch: # Allows the workflow to be manually triggered + inputs: + GitUrl: + description: 'fiber -git url' + default: 'https://github.com/nervosnetwork/fiber.git' + GitBranch: + description: 'fiber -git branch' + default: 'develop' + BuildFIBER: + description: 'build fiber' + default: 'true' + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + + - name: Print Input Values + run: | + echo "**Input Values:**" + echo " GitUrl: ${{ github.event.inputs.GitUrl }}" + echo " GitBranch: ${{ github.event.inputs.GitBranch }}" + echo " BuildCKbCLI: ${{ github.event.inputs.BuildFIBER }}" + + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Install dependencies + run: make prepare_develop_testnet + env: + GitUrl: '${{ github.event.inputs.GitUrl }}' + GitBranch: '${{ github.event.inputs.GitBranch }}' + BuildFIBER: '${{ github.event.inputs.BuildFIBER }}' + + - name: Run tests + run: make fiber_test_demo FIBER_TEST_DEMO="test_cases/fiber/devnet/stable" + + # - name: Setup upterm session + # if: always() + # uses: lhotari/action-upterm@v1 + + - name: Publish reports + if: failure() + uses: actions/upload-artifact@v4 + with: + name: jfoa-build-reports-${{ runner.os }} + path: ./report diff --git a/.github/workflows/fiber.yml b/.github/workflows/fiber.yml index e8e6755c..ae1497f0 100644 --- a/.github/workflows/fiber.yml +++ b/.github/workflows/fiber.yml @@ -79,7 +79,7 @@ jobs: name: jfoa-open_channel-reports-${{ runner.os }} path: ./report - fiber_test_accept_channel_cancel_invoice_connect_peer_disconnect_peer: + fiber_test_accept_channel_cancel_invoice_connect_peer_disconnect_peer_backup: needs: prepare runs-on: ubuntu-22.04 @@ -106,7 +106,7 @@ jobs: tar -xzf prepare-backup.tar.gz - name: Run fiber_test_demo - run: make fiber_test_demo FIBER_TEST_DEMO="test_cases/fiber/devnet/accept_channel test_cases/fiber/devnet/cancel_invoice test_cases/fiber/devnet/connect_peer test_cases/fiber/devnet/disconnect_peer" + run: make fiber_test_demo FIBER_TEST_DEMO="test_cases/fiber/devnet/accept_channel test_cases/fiber/devnet/cancel_invoice test_cases/fiber/devnet/connect_peer test_cases/fiber/devnet/disconnect_peer test_cases/fiber/devnet/backup" - name: Publish reports if: failure() diff --git a/download.py b/download.py index d0cb6848..1fe9b728 100644 --- a/download.py +++ b/download.py @@ -12,17 +12,8 @@ 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", - "0.116.1", - "0.117.0", - "0.118.0", - "0.119.0-rc1", + "0.117.0" "0.201.0", ] # Replace with your versions DOWNLOAD_DIR = "download" diff --git a/download_fiber.py b/download_fiber.py index a0db1e75..8a9b79ae 100644 --- a/download_fiber.py +++ b/download_fiber.py @@ -12,12 +12,6 @@ from tqdm import tqdm versions = [ - "0.2.0", - "0.2.1", - "0.3.0", - "0.3.1", - "0.4.0", - "0.4.2", "0.5.0", "0.5.1", ] # Replace with your versions diff --git a/framework/basic_fiber.py b/framework/basic_fiber.py index 2fa2704b..c37151fe 100644 --- a/framework/basic_fiber.py +++ b/framework/basic_fiber.py @@ -25,6 +25,7 @@ class FiberTest(CkbTest): fiber_version = FiberConfigPath.CURRENT_DEV logger = logging.getLogger(__name__) start_fiber_config = {} + fnn_log_level = "debug" @classmethod def setup_class(cls): @@ -130,10 +131,10 @@ def setup_method(cls, method): update_config.update(cls.start_fiber_config) cls.fiber1.prepare(update_config=update_config) - cls.fiber1.start() + cls.fiber1.start(fnn_log_level=cls.fnn_log_level) cls.fiber2.prepare(update_config=update_config) - cls.fiber2.start() + cls.fiber2.start(fnn_log_level=cls.fnn_log_level) before_balance1 = cls.Ckb_cli.wallet_get_capacity( cls.account1["address"]["testnet"], api_url=cls.node.getClient().url ) @@ -255,7 +256,7 @@ def start_new_fiber( self.fibers.append(fiber) self.new_fibers.append(fiber) fiber.prepare(update_config=update_config) - fiber.start() + fiber.start(fnn_log_level=self.fnn_log_level) return fiber def wait_for_channel_state( @@ -416,7 +417,9 @@ def send_payment(self, fiber1, fiber2, amount, wait=True, udt=None, try_count=5) } ) if wait: - self.wait_payment_state(fiber1, payment["payment_hash"], "Success") + self.wait_payment_state( + fiber1, payment["payment_hash"], "Success", 600, 0.1 + ) return payment["payment_hash"] except Exception as e: time.sleep(1) @@ -431,7 +434,9 @@ def send_payment(self, fiber1, fiber2, amount, wait=True, udt=None, try_count=5) } ) if wait: - self.wait_payment_state(fiber1, payment["payment_hash"], "Success") + self.wait_payment_state( + fiber1, payment["payment_hash"], "Success", 600, 0.1 + ) return payment["payment_hash"] def get_account_script(self, account_private_key): @@ -442,14 +447,16 @@ def get_account_script(self, account_private_key): "args": account1["lock_arg"], } - def wait_payment_state(self, client, payment_hash, status="Success", timeout=360): + def wait_payment_state( + self, client, payment_hash, status="Success", timeout=360, interval=1 + ): for i in range(timeout): result = client.get_client().get_payment({"payment_hash": payment_hash}) if result["status"] == status: return - time.sleep(1) + time.sleep(interval) raise TimeoutError( - f"status did not reach state: {status} within timeout period." + f"payment:{payment_hash} status did not reach state: {result['status']}, expected:{status} , within timeout period." ) def wait_payment_finished(self, client, payment_hash, timeout=120): diff --git a/framework/test_fiber.py b/framework/test_fiber.py index 1f17213b..634fcb61 100644 --- a/framework/test_fiber.py +++ b/framework/test_fiber.py @@ -32,19 +32,10 @@ class FiberConfigPath(Enum): "download/fiber/0.5.1/fnn", ) - V042_TESTNET = ("/source/template/fiber/config.yml.j2", "download/fiber/0.4.2/fnn") - V040_TESTNET = ("/source/template/fiber/config.yml.j2", "download/fiber/0.4.0/fnn") - V031_TESTNET = ("/source/template/fiber/config.yml.j2", "download/fiber/0.3.1/fnn") - V030_TESTNET = ("/source/template/fiber/config.yml.j2", "download/fiber/0.3.0/fnn") - V020_TESTNET = ("/source/template/fiber/config.yml.j2", "download/fiber/0.2.0/fnn") - V010_TESTNET = ("/source/template/fiber/config.yml.j2", "download/fiber/0.1.0/fnn") - - V040_DEV = ("/source/template/fiber/dev_config.yml.j2", "download/fiber/0.4.0/fnn") - V031_DEV = ("/source/template/fiber/dev_config.yml.j2", "download/fiber/0.3.1/fnn") - V030_DEV = ("/source/template/fiber/dev_config.yml.j2", "download/fiber/0.3.0/fnn") - V021_DEV = ("/source/template/fiber/dev_config.yml.j2", "download/fiber/0.2.1/fnn") - V020_DEV = ("/source/template/fiber/dev_config.yml.j2", "download/fiber/0.2.0/fnn") - V010_DEV = ("/source/template/fiber/dev_config.yml.j2", "download/fiber/0.1.0/fnn") + V050_DEV = ( + "/source/template/fiber/dev_config_2.yml.j2", + "download/fiber/0.5.0/fnn", + ) def __init__(self, fiber_config_path, fiber_bin_path): self.fiber_config_path = fiber_config_path @@ -182,7 +173,7 @@ def migration(self): f"echo YES | RUST_LOG=info,fnn=debug {get_project_root()}/{self.fiber_config_enum.fiber_bin_path}-migrate -p {self.tmp_path}/fiber/store" ) - def start(self, password="password0"): + def start(self, password="password0", fnn_log_level="debug"): # env_map = dict(os.environ) # Make a copy of the current environment # if node: # contract_map = self.get_contract_env_map(node) @@ -190,7 +181,7 @@ def start(self, password="password0"): # for key in env_map: # print(f"{key}={env_map[key]}") run_command( - f"FIBER_SECRET_KEY_PASSWORD='{password}' RUST_LOG=info,fnn=debug {get_project_root()}/{self.fiber_config_enum.fiber_bin_path} -c {self.tmp_path}/config.yml -d {self.tmp_path} > {self.tmp_path}/node.log 2>&1 &" + f"FIBER_SECRET_KEY_PASSWORD='{password}' RUST_LOG=info,fnn={fnn_log_level} {get_project_root()}/{self.fiber_config_enum.fiber_bin_path} -c {self.tmp_path}/config.yml -d {self.tmp_path} > {self.tmp_path}/node.log 2>&1 &" # env=env_map, ) # wait rpc start @@ -198,7 +189,10 @@ def start(self, password="password0"): print("start fiber client ") def stop(self): - run_command(f"kill $(lsof -t -i:{self.rpc_port})", False) + run_command( + "kill $(lsof -i:" + self.rpc_port + " | grep LISTEN | awk '{print $2}')", + False, + ) time.sleep(1) def force_stop(self): diff --git a/framework/test_node.py b/framework/test_node.py index 889284a8..ab7858dd 100644 --- a/framework/test_node.py +++ b/framework/test_node.py @@ -19,14 +19,14 @@ class CkbNodeConfigPath(Enum): "source/template/ckb/v118/ckb.toml.j2", "source/template/ckb/v118/ckb-miner.toml.j2", "source/template/ckb/v118/specs/dev.toml", - "download/0.120.0", + "download/0.201.0", ) CURRENT_FIBER = ( "source/template/ckb/v118/ckb.toml.j2", "source/template/ckb/v118/ckb-miner.toml.j2", "source/template/ckb/fiber/dev.toml", - "download/0.119.0", + "download/0.201.0", ) TESTNET = ( "source/template/ckb/v118/ckb.toml.j2", diff --git a/prepare.sh b/prepare.sh index e5cecbbb..cf91a885 100644 --- a/prepare.sh +++ b/prepare.sh @@ -1,7 +1,7 @@ set -ex -DEFAULT_FIBER_BRANCH="develop" -DEFAULT_FIBER_URL="https://github.com/nervosnetwork/fiber.git" +DEFAULT_FIBER_BRANCH="yukang-trivial-fix-on-funding" +DEFAULT_FIBER_URL="https://github.com/chenyukang/fiber.git" GitFIBERBranch="${GitBranch:-$DEFAULT_FIBER_BRANCH}" GitFIBERUrl="${GitUrl:-$DEFAULT_FIBER_URL}" diff --git a/test_cases/fiber/devnet/backup/test_backup.py b/test_cases/fiber/devnet/backup/test_backup.py new file mode 100644 index 00000000..da9ab414 --- /dev/null +++ b/test_cases/fiber/devnet/backup/test_backup.py @@ -0,0 +1,61 @@ +import shutil +import time + +from framework.basic_fiber import FiberTest + + +class TestBackup(FiberTest): + + def test_backup(self): + """ + 1. 关闭节点 + 2. 替换节点 + 3. 重启,send payment + Returns: + """ + self.open_channel(self.fiber1, self.fiber2, 1000 * 100000000, 1) + before_graph_nodes = self.fiber2.get_client().graph_nodes() + self.fiber1.stop() + self.fiber1.prepare({"fiber_listening_addr": "/ip4/127.0.0.1/tcp/8238"}) + self.fiber1.start() + time.sleep(5) + after_graph_nodes = self.fiber2.get_client().graph_nodes() + self.send_payment(self.fiber1, self.fiber2, 1) + print(before_graph_nodes) + print(after_graph_nodes) + assert ( + after_graph_nodes["nodes"][1]["addresses"] + == self.fiber1.get_client().node_info()["addresses"] + ) + + def test_backup2(self): + """ + 1. 不关闭节点 + 2. 直接备份数据 + 3. 重启,send payment + Returns: + """ + self.open_channel(self.fiber1, self.fiber2, 1000 * 100000000, 1) + shutil.copytree( + f"{self.fiber1.tmp_path}/fiber", f"{self.fiber1.tmp_path}/fiber.bak" + ) + self.fiber1.stop() + shutil.rmtree(f"{self.fiber1.tmp_path}/fiber") + shutil.copytree( + f"{self.fiber1.tmp_path}/fiber.bak", f"{self.fiber1.tmp_path}/fiber" + ) + self.fiber1.start() + time.sleep(5) + self.send_payment(self.fiber1, self.fiber2, 1) + + def test_backup3(self): + self.open_channel(self.fiber1, self.fiber2, 1000 * 100000000, 1) + self.fiber1.stop() + self.fiber1.prepare({"fiber_listening_addr": "/ip4/127.0.0.1/tcp/8238"}) + self.fiber1.start("newPassword2") + time.sleep(5) + self.send_payment(self.fiber1, self.fiber2, 1) + self.fiber1.stop() + self.fiber1.start("newPassword2") + time.sleep(5) + self.send_payment(self.fiber1, self.fiber2, 1) diff --git a/test_cases/fiber/devnet/list_peers/test_list_peers.py b/test_cases/fiber/devnet/list_peers/test_list_peers.py index 0607aa5b..f052d9fe 100644 --- a/test_cases/fiber/devnet/list_peers/test_list_peers.py +++ b/test_cases/fiber/devnet/list_peers/test_list_peers.py @@ -1,8 +1,11 @@ +import pytest + from framework.basic_fiber import FiberTest class TestListPeers(FiberTest): + @pytest.mark.skip("https://github.com/nervosnetwork/fiber/issues/718") def test_01(self): peer = self.fiber1.get_client().list_peers() assert ( @@ -17,3 +20,6 @@ def test_01(self): peer["peers"][0]["peer_id"] == self.fiber2.get_client().node_info()["addresses"][0].split("/")[-1] ) + # https://github.com/nervosnetwork/fiber/issues/718 + peers = self.fiber2.get_client().list_peers() + assert len(peers["peers"][0]["addresses"]) == 1 diff --git a/test_cases/fiber/devnet/open_channel/test_funding_udt_type_script.py b/test_cases/fiber/devnet/open_channel/test_funding_udt_type_script.py index 8b43a4b1..f4a53004 100644 --- a/test_cases/fiber/devnet/open_channel/test_funding_udt_type_script.py +++ b/test_cases/fiber/devnet/open_channel/test_funding_udt_type_script.py @@ -178,3 +178,126 @@ def test_funding_udt_type_script_is_white(self): tx_message["output_cells"][1]["args"] == self.fiber2.get_account()["lock_arg"] ) + + # @pytest.mark.skip("https://github.com/nervosnetwork/fiber/pull/720") + def test_node1_2_udt_gt_u128_max(self): + self.faucet( + self.fiber1.account_private, + 0, + self.fiber2.account_private, + 340282366920938463463374607431768211400, + ) + self.faucet( + self.fiber1.account_private, 0, self.fiber2.account_private, 1 * 100000000 + ) + # self.open_channel(self.fiber1, self.fiber2, 340282366920938463463374607431768211400 + 1 - 62 * 100000000, 1, + # 1000, 1000, + # self.get_account_udt_script(self.fiber2.account_private)) + temporary_channel = self.fiber1.get_client().open_channel( + { + "peer_id": self.fiber2.get_peer_id(), + "funding_amount": hex(340282366920938463463374607431768211400 + 1), + "tlc_fee_proportional_millionths": hex(1000), + "public": True, + "funding_udt_type_script": self.get_account_udt_script( + self.fiber1.account_private + ), + } + ) + time.sleep(5) + channel = self.fiber1.get_client().list_channels({}) + print("channel:", channel) + assert channel["channels"] == [] + + def test_amount_eq_u128_max(self): + self.faucet( + self.fiber1.account_private, + 0, + self.fiber2.account_private, + 340282366920938463463374607431768211455, + ) + self.faucet( + self.fiber1.account_private, 0, self.fiber2.account_private, 1 * 100000000 + ) + self.open_channel( + self.fiber1, + self.fiber2, + 340282366920938463463374607431768211455 - 1 - 62 * 100000000, + 1, + 1000, + 1000, + self.get_account_udt_script(self.fiber2.account_private), + ) + self.fiber1.get_client().shutdown_channel( + { + "channel_id": self.fiber1.get_client().list_channels({})["channels"][0][ + "channel_id" + ], + "close_script": self.get_account_script(self.Config.ACCOUNT_PRIVATE_1), + "fee_rate": "0x3FC", + } + ) + tx_hash = self.wait_and_check_tx_pool_fee(1000, False, 100) + self.Miner.miner_until_tx_committed(self.node, tx_hash) + tx_msg = self.get_tx_message(tx_hash) + print("msg:", tx_msg) + assert ( + tx_msg["input_cells"][0]["udt_capacity"] + == 340282366920938463463374607431768211455 + ) + assert { + "args": self.fiber2.get_account()["lock_arg"], + "capacity": 14300000000, + "udt_args": self.get_account_udt_script(self.fiber2.account_private)[ + "args" + ], + "udt_capacity": 1, + } in tx_msg["output_cells"] + assert { + "args": self.fiber1.get_account()["lock_arg"], + "capacity": 14300000000 - tx_msg["fee"], + "udt_args": self.get_account_udt_script(self.fiber2.account_private)[ + "args" + ], + "udt_capacity": 340282366920938463463374607431768211454, + } in tx_msg["output_cells"] + + def test_node1_add_node2_amount_gt_u128_max(self): + """ + Returns: + """ + self.faucet( + self.fiber2.account_private, + 0, + self.fiber1.account_private, + 340282366920938463463374607431768211400, + ) + self.faucet( + self.fiber1.account_private, 0, self.fiber1.account_private, 1 * 100000000 + ) + temporary_channel = self.fiber1.get_client().open_channel( + { + "peer_id": self.fiber2.get_peer_id(), + "funding_amount": hex(100000000 - 1), + "tlc_fee_proportional_millionths": hex(1000), + "public": True, + "funding_udt_type_script": self.get_account_udt_script( + self.fiber1.account_private + ), + } + ) + time.sleep(1) + + with pytest.raises(Exception) as exc_info: + self.fiber2.get_client().accept_channel( + { + "temporary_channel_id": temporary_channel["temporary_channel_id"], + "funding_amount": hex(340282366920938463463374607431768211400 - 1), + "tlc_fee_proportional_millionths": hex(1000), + } + ) + expected_error_message = "The total UDT funding amount should be less than 340282366920938463463374607431768211455" + assert expected_error_message in exc_info.value.args[0], ( + f"Expected substring '{expected_error_message}' " + f"not found in actual string '{exc_info.value.args[0]}'" + ) diff --git a/test_cases/fiber/devnet/send_payment/params/test_max_fee_amount.py b/test_cases/fiber/devnet/send_payment/params/test_max_fee_amount.py index 29a10023..baf81d06 100644 --- a/test_cases/fiber/devnet/send_payment/params/test_max_fee_amount.py +++ b/test_cases/fiber/devnet/send_payment/params/test_max_fee_amount.py @@ -75,11 +75,30 @@ def test_fee(self): ) self.wait_payment_state(self.fiber1, payment1["payment_hash"]) - # - # - # def test_max_fee_amount_is_none(self): - # """ - # max_fee_amount == node 代表什么 - # Returns: - # - # """ + # @pytest.mark.skip(reason="https://github.com/nervosnetwork/fiber/pull/717") + def test_max_fee_0xffffffffffffffffffffffffffffffff(self): + self.open_channel(self.fiber1, self.fiber2, 1000 * 100000000, 1000 * 100000000) + invoice = self.fiber1.get_client().new_invoice( + { + "amount": hex(1 * 100000000), + "currency": "Fibd", + "description": "test invoice generated by node2", + "expiry": "0xe10", + "final_cltv": "0x28", + "payment_preimage": self.generate_random_preimage(), + "hash_algorithm": "sha256", + } + ) + with pytest.raises(Exception) as exc_info: + self.fiber2.get_client().send_payment( + { + "invoice": invoice["invoice_address"], + "max_fee_amount": "0xffffffffffffffffffffffffffffffff", + } + ) + expected_error_message = "overflow" + assert expected_error_message in exc_info.value.args[0], ( + f"Expected substring '{expected_error_message}' " + f"not found in actual string '{exc_info.value.args[0]}'" + ) + self.fiber2.get_client().node_info() diff --git a/test_cases/fiber/devnet/stable/test_stable.py b/test_cases/fiber/devnet/stable/test_stable.py new file mode 100644 index 00000000..887ca668 --- /dev/null +++ b/test_cases/fiber/devnet/stable/test_stable.py @@ -0,0 +1,159 @@ +import time + +from framework.basic_fiber import FiberTest +import concurrent.futures + + +class TestStableStress(FiberTest): + fnn_log_level = "info" + + # def test_conn(self): + # self. + def test_stable_stress(self): + """ + a->b->c->a + 1. a->a ckb and udt + 2. b->b ckb and udt + 3. c->c ckb and udt + Returns: + """ + self.fiber3 = self.start_new_fiber( + self.generate_account(10000, self.fiber1.account_private, 10000 * 100000000) + ) + self.faucet( + self.fiber2.account_private, + 0, + self.fiber1.account_private, + 10000 * 100000000, + ) + self.faucet( + self.fiber1.account_private, + 0, + self.fiber1.account_private, + 10000 * 100000000, + ) + self.open_channel( + self.fiber1, self.fiber2, 1000 * 100000000, 1000 * 100000000, 0, 0 + ) + self.open_channel( + self.fiber1, + self.fiber2, + 1000 * 100000000, + 1000 * 100000000, + 0, + 0, + self.get_account_udt_script(self.fiber1.account_private), + ) + + self.open_channel( + self.fiber2, self.fiber3, 1000 * 100000000, 1000 * 100000000, 0, 0 + ) + self.open_channel( + self.fiber2, + self.fiber3, + 1000 * 100000000, + 1000 * 100000000, + 0, + 0, + self.get_account_udt_script(self.fiber1.account_private), + ) + + self.open_channel( + self.fiber3, self.fiber1, 1000 * 100000000, 1000 * 100000000, 0, 0 + ) + self.open_channel( + self.fiber3, + self.fiber1, + 1000 * 100000000, + 1000 * 100000000, + 0, + 0, + self.get_account_udt_script(self.fiber1.account_private), + ) + + time.sleep(10) + udt = self.get_account_udt_script(self.fiber1.account_private) + send_tx_size = 5 * 60 * 60 * 2 + tasks_submitted = 0 + start_time = time.time() + times = [] + completed_counts = [] + with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor: + futures = [] + + for i in range(send_tx_size): + # Submit payment tasks for fiber1 + futures.append( + executor.submit(self.send_payment, self.fiber1, self.fiber1, 1) + ) + futures.append( + executor.submit( + self.send_payment, self.fiber1, self.fiber1, 1, True, udt + ) + ) + + futures.append( + executor.submit(self.send_payment, self.fiber2, self.fiber2, 1) + ) + futures.append( + executor.submit( + self.send_payment, self.fiber2, self.fiber2, 1, True, udt + ) + ) + + futures.append( + executor.submit(self.send_payment, self.fiber3, self.fiber3, 1) + ) + futures.append( + executor.submit( + self.send_payment, self.fiber3, self.fiber3, 1, True, udt + ) + ) + tasks_submitted += 6 + + # Wait for all tasks to complete + # concurrent.futures.wait(futures) + completed_tasks = 0 + for future in concurrent.futures.as_completed(futures): + completed_tasks += 1 + try: + result = future.result() + self.logger.debug( + f"Task {completed_tasks}/{tasks_submitted} completed" + ) + except Exception as e: + self.logger.error( + f"Task {completed_tasks}/{tasks_submitted} failed: {e}" + ) + + # Record time and completed tasks + elapsed_time = time.time() - start_time + times.append(elapsed_time) + completed_counts.append(completed_tasks) + + if completed_tasks % 100 == 0: + speed = completed_tasks / elapsed_time if elapsed_time > 0 else 0 + self.logger.info( + f"Completed {completed_tasks}/{tasks_submitted} tasks in {elapsed_time:.2f} seconds. Speed: {speed:.2f} tasks/second" + ) + + total_time = time.time() - start_time + speed = completed_tasks / total_time if total_time > 0 else 0 + self.logger.info( + f"Completed {completed_tasks}/{tasks_submitted} tasks in {total_time:.2f} seconds. Final speed: {speed:.2f} tasks/second" + ) + + self.logger.info(f"finished :{send_tx_size}") + self.get_fibers_balance_message() + for fiber in self.fibers: + message = self.get_fiber_balance(fiber) + assert message["ckb"] == { + "local_balance": 200000000000, + "offered_tlc_balance": 0, + "received_tlc_balance": 0, + } + assert message[udt["args"]] == { + "local_balance": 206200000000, + "offered_tlc_balance": 0, + "received_tlc_balance": 0, + }