|
| 1 | +from framework.basic import CkbTest |
| 2 | + |
| 3 | + |
| 4 | +class TestCkbCliMultisig203(CkbTest): |
| 5 | + |
| 6 | + @classmethod |
| 7 | + def setup_class(cls): |
| 8 | + """ |
| 9 | + 1. start 1 ckb node in tmp/ckb_cli/node dir |
| 10 | + 2. miner 2 block |
| 11 | + Returns: |
| 12 | +
|
| 13 | + """ |
| 14 | + # 1. start 1 ckb node in tmp/ckb_cli/node dir |
| 15 | + cls.node = cls.CkbNode.init_dev_by_port( |
| 16 | + cls.CkbNodeConfigPath.CURRENT_TEST, "ckb_cli/node", 8314, 8315 |
| 17 | + ) |
| 18 | + cls.node.prepare() |
| 19 | + cls.node.start() |
| 20 | + # 2. miner 2 block |
| 21 | + cls.Miner.make_tip_height_number(cls.node, 2) |
| 22 | + |
| 23 | + @classmethod |
| 24 | + def teardown_class(cls): |
| 25 | + """ |
| 26 | + 1. stop ckb node |
| 27 | + 2. clean ckb node tmp dir |
| 28 | + Returns: |
| 29 | +
|
| 30 | + """ |
| 31 | + print("stop node and clean") |
| 32 | + cls.node.stop() |
| 33 | + cls.node.clean() |
| 34 | + |
| 35 | + def test_01_dep_groups_enable_type_id_true(self): |
| 36 | + # 1. deploy contract return deploy tx hash |
| 37 | + dep_group_tx_hash = self.Contract.deploy_ckb_contract( |
| 38 | + self.Config.ACCOUNT_PRIVATE_2, |
| 39 | + self.Config.ALWAYS_SUCCESS_CONTRACT_PATH, |
| 40 | + enable_type_id=True, |
| 41 | + dep_groups_enable_type_id=True, |
| 42 | + return_tx="dep_group_tx", |
| 43 | + api_url=self.node.getClient().url, |
| 44 | + ) |
| 45 | + # 2. miner until deploy contrct tx hash |
| 46 | + tx_response = self.Miner.miner_until_tx_committed(self.node, dep_group_tx_hash) |
| 47 | + output = tx_response["transaction"]["outputs"][0] |
| 48 | + # 3. check hash_type |
| 49 | + output_type = output.get("type") |
| 50 | + assert ( |
| 51 | + output_type is not None |
| 52 | + ), "Failed: Output does not contain a 'type' field." |
| 53 | + |
| 54 | + def test_02_dep_groups_enable_type_id_false(self): |
| 55 | + # 1. deploy contract return deploy tx hash |
| 56 | + dep_group_tx_hash = self.Contract.deploy_ckb_contract( |
| 57 | + self.Config.ACCOUNT_PRIVATE_2, |
| 58 | + self.Config.ALWAYS_SUCCESS_CONTRACT_PATH, |
| 59 | + enable_type_id=True, |
| 60 | + dep_groups_enable_type_id=False, |
| 61 | + return_tx="dep_group_tx", |
| 62 | + api_url=self.node.getClient().url, |
| 63 | + ) |
| 64 | + # 2. miner until deploy contrct tx hash |
| 65 | + tx_response = self.Miner.miner_until_tx_committed(self.node, dep_group_tx_hash) |
| 66 | + output = tx_response["transaction"]["outputs"][0] |
| 67 | + # 3. check hash_type |
| 68 | + assert ( |
| 69 | + output.get("type") is None |
| 70 | + ), f"Failed: type field should be None, got {output.get('type')}" |
| 71 | + |
| 72 | + def test_03_dep_groups_enable_type_id_old(self): |
| 73 | + # 1. deploy contract return deploy tx hash |
| 74 | + dep_group_tx_hash = self.Contract.deploy_ckb_contract( |
| 75 | + self.Config.ACCOUNT_PRIVATE_2, |
| 76 | + self.Config.ALWAYS_SUCCESS_CONTRACT_PATH, |
| 77 | + enable_type_id=True, |
| 78 | + dep_groups_enable_type_id="old", |
| 79 | + return_tx="dep_group_tx", |
| 80 | + api_url=self.node.getClient().url, |
| 81 | + ) |
| 82 | + # 2. miner until deploy contrct tx hash |
| 83 | + tx_response = self.Miner.miner_until_tx_committed(self.node, dep_group_tx_hash) |
| 84 | + output = tx_response["transaction"]["outputs"][0] |
| 85 | + # 3. check hash_type |
| 86 | + assert ( |
| 87 | + output.get("type") is None |
| 88 | + ), f"Failed: type field should be None, got {output.get('type')}" |
0 commit comments