Merge gitea/main, preserving release v0.2.2 stability and CLI documentation
This commit is contained in:
30
dev/fixes/fix_inprocess.py
Normal file
30
dev/fixes/fix_inprocess.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import asyncio
|
||||
from contextlib import asynccontextmanager
|
||||
from typing import Any
|
||||
|
||||
class _InProcessSubscriber:
|
||||
def __init__(self, queue, release):
|
||||
self._queue = queue
|
||||
self._release = release
|
||||
def __aiter__(self):
|
||||
return self._iterator()
|
||||
async def _iterator(self):
|
||||
try:
|
||||
while True:
|
||||
yield await self._queue.get()
|
||||
finally:
|
||||
pass
|
||||
|
||||
@asynccontextmanager
|
||||
async def subscribe():
|
||||
queue = asyncio.Queue()
|
||||
try:
|
||||
yield _InProcessSubscriber(queue, lambda: None)
|
||||
finally:
|
||||
pass
|
||||
|
||||
async def main():
|
||||
async with subscribe() as sub:
|
||||
print("Success")
|
||||
|
||||
asyncio.run(main())
|
||||
10
dev/fixes/fix_poa.py
Normal file
10
dev/fixes/fix_poa.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import re
|
||||
|
||||
with open("/opt/aitbc/apps/blockchain-node/src/aitbc_chain/consensus/poa.py", "r") as f:
|
||||
content = f.read()
|
||||
|
||||
# Make sure we use the correct chain_id when draining from mempool
|
||||
new_content = content.replace("mempool.drain(max_txs, max_bytes, self._config.chain_id)", "mempool.drain(max_txs, max_bytes, 'ait-mainnet')")
|
||||
|
||||
with open("/opt/aitbc/apps/blockchain-node/src/aitbc_chain/consensus/poa.py", "w") as f:
|
||||
f.write(new_content)
|
||||
10
dev/fixes/fix_router.py
Normal file
10
dev/fixes/fix_router.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import re
|
||||
|
||||
with open("/opt/aitbc/apps/blockchain-node/src/aitbc_chain/rpc/router.py", "r") as f:
|
||||
content = f.read()
|
||||
|
||||
# Make sure we use the correct chain_id when adding to mempool
|
||||
new_content = content.replace("mempool.add(tx_dict, chain_id=chain_id)", "mempool.add(tx_dict, chain_id=chain_id or request.payload.get('chain_id') or 'ait-mainnet')")
|
||||
|
||||
with open("/opt/aitbc/apps/blockchain-node/src/aitbc_chain/rpc/router.py", "w") as f:
|
||||
f.write(new_content)
|
||||
@@ -1,28 +0,0 @@
|
||||
import sys
|
||||
from click.testing import CliRunner
|
||||
from aitbc_cli.commands.node import node
|
||||
from aitbc_cli.core.config import MultiChainConfig
|
||||
from unittest.mock import patch, MagicMock
|
||||
import sys
|
||||
|
||||
runner = CliRunner()
|
||||
with patch('aitbc_cli.commands.node.load_multichain_config') as mock_load:
|
||||
with patch('aitbc_cli.commands.node.get_default_node_config') as mock_default:
|
||||
with patch('aitbc_cli.commands.node.add_node_config') as mock_add:
|
||||
# The function does `from ..core.config import save_multichain_config`
|
||||
# This evaluates to `aitbc_cli.core.config` because node.py is in `aitbc_cli.commands`
|
||||
with patch('aitbc_cli.core.config.save_multichain_config') as mock_save:
|
||||
# The issue with the previous run was not that save_multichain_config wasn't patched correctly.
|
||||
# The issue is that click catches exceptions and prints the generic "Error adding node: ...".
|
||||
# Wait, "Failed to save configuration" actually implies the unpatched save_multichain_config was CALLED!
|
||||
|
||||
# Let's mock at sys.modules level for Python relative imports
|
||||
pass
|
||||
|
||||
with patch('aitbc_cli.commands.node.load_multichain_config') as mock_load:
|
||||
with patch('aitbc_cli.commands.node.get_default_node_config') as mock_default:
|
||||
with patch('aitbc_cli.commands.node.add_node_config') as mock_add:
|
||||
# the easiest way is to patch it in the exact module it is executed
|
||||
# OR we can just avoid testing the mock_save and let it save to a temp config!
|
||||
# Let's check how config is loaded in node.py
|
||||
pass
|
||||
Reference in New Issue
Block a user