From d3e2727d2077f3a1dbdfd54cbf07e9ba323ef95b Mon Sep 17 00:00:00 2001 From: magicalne Date: Mon, 25 Jul 2022 11:09:19 +0800 Subject: [PATCH] fix: parse mol for CustodianLockArgs --- agent/ckb_indexer.py | 6 +++--- tests/integration/test_sched_custodian.py | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/agent/ckb_indexer.py b/agent/ckb_indexer.py index 7b226c2..03eaaa3 100644 --- a/agent/ckb_indexer.py +++ b/agent/ckb_indexer.py @@ -158,14 +158,14 @@ def get_custodian_stats(self, gw_config: GwConfig, return custodian_stats -## parse mol format +## parse mol format in godwoken.mol#CustodianLockArgs def get_deposit_block_number_from_args(args: str): if args.startswith("0x"): args = args[2:] args = bytes.fromhex(args) args = args[32:] - start = int.from_bytes(args[12:16], byteorder="little", signed=False) - return int.from_bytes(args[start:], byteorder="little", signed=False) + start = int.from_bytes(args[8:12], byteorder="little", signed=False) + return int.from_bytes(args[start:start+8], byteorder="little", signed=False) def output_data_to_int(s: str, byteorder="little", signed=False): diff --git a/tests/integration/test_sched_custodian.py b/tests/integration/test_sched_custodian.py index fdb73c0..88f89f1 100644 --- a/tests/integration/test_sched_custodian.py +++ b/tests/integration/test_sched_custodian.py @@ -1,14 +1,16 @@ from time import sleep import unittest from agent.sched_custodian import get_custodian -from agent.gw_config import testnet_config +from agent.gw_config import testnet_v1_1_config, mainnet_v1_config class TestSchedCustodian(unittest.TestCase): def setUp(self) -> None: - self.gw_config = testnet_config() - self.indexer_url = "https://testnet.ckb.dev/indexer" + #self.gw_config = testnet_v1_1_config() + #self.indexer_url = "https://testnet.ckb.dev/indexer" + self.gw_config = mainnet_v1_config() + self.indexer_url = "https://mainnet.ckb.dev/indexer" def test_get_custodian(self) -> None: - custodian = get_custodian(self.indexer_url, self.gw_config, 171987) + custodian = get_custodian(self.indexer_url, self.gw_config, 53778) print(f'custodian: {custodian}')