Skip to content

Commit

Permalink
fix: parse mol for CustodianLockArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
magicalne committed Jul 25, 2022
1 parent 8252c79 commit d3e2727
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions agent/ckb_indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
10 changes: 6 additions & 4 deletions tests/integration/test_sched_custodian.py
Original file line number Diff line number Diff line change
@@ -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}')

0 comments on commit d3e2727

Please sign in to comment.