Skip to content
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

X/tx index #58

Merged
merged 6 commits into from
Aug 14, 2024
Merged
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
4 changes: 1 addition & 3 deletions framework/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@

# contract
ALWAYS_SUCCESS_CONTRACT_PATH = f"{get_project_root()}/source/contract/always_success"
SPAWN_CONTRACT_PATH = (
f"{get_project_root()}/source/contract/test_cases/spawn_demo"
)
SPAWN_CONTRACT_PATH = f"{get_project_root()}/source/contract/test_cases/spawn_demo"


def get_tmp_path():
Expand Down
6 changes: 6 additions & 0 deletions prepare.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
set -e
# git clone https://github.com/nervosnetwork/ckb-cli.git
# cd ckb-cli
# git checkout pkg/v1.7.0
# make prod
# cp target/release/ckb-cli ../source/ckb-cli
# cd ../
cp download/0.110.2/ckb-cli ./source/ckb-cli-old
cp download/0.117.0/ckb-cli ./source/ckb-cli
#git clone https://github.com/quake/ckb-light-client.git
Expand Down
60 changes: 60 additions & 0 deletions test_cases/feature/test_get_transaction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from framework.basic import CkbTest


class TestGetTransaction(CkbTest):

@classmethod
def setup_class(cls):
"""
1. start 1 ckb node in tmp/get_transaction/node1 node dir
2. miner 100block
Returns:

"""
# 1. start 1 ckb node in tmp/get_transaction/node1 node dir
cls.node = cls.CkbNode.init_dev_by_port(
cls.CkbNodeConfigPath.develop, "get_transaction/node1", 8120, 8225
)
cls.node.prepare(other_ckb_config={"ckb_tx_pool_max_tx_pool_size": "180_000"})
cls.node.start()
# 2. miner 100 block
cls.Miner.make_tip_height_number(cls.node, 100)

@classmethod
def teardown_class(cls):
"""
1. stop ckb node
2. clean ckb node tmp dir
Returns:

"""
cls.node.stop()
cls.node.clean()

def test_get_transaction_by_tx_index(self):
"""
1. new tx in block
2. query tx index is null
3. miner block until tx committed, query tx index is 0x1
Returns:

"""
# 1. new tx in block
account = self.Ckb_cli.util_key_info_by_private_key(self.Config.MINER_PRIVATE_1)
tx_hash = self.Ckb_cli.wallet_transfer_by_private_key(
self.Config.MINER_PRIVATE_1,
account["address"]["testnet"],
100,
self.node.getClient().url,
"1500",
)
print(f"txHash:{tx_hash}")
# 2. query tx index is null
transaction1 = self.node.getClient().get_transaction(tx_hash)
print(f"tx_index:{transaction1['tx_status']['tx_index']}")
assert transaction1["tx_status"]["tx_index"] is None
# 3. miner block until tx committed, query tx index is 0x1
self.Miner.miner_until_tx_committed(self.node, tx_hash)
transaction2 = self.node.getClient().get_transaction(tx_hash)
print(f"after miner tx_hash, tx_index:{transaction2['tx_status']['tx_index']}")
assert transaction2["tx_status"]["tx_index"] == "0x1"
Loading