Skip to content

Commit

Permalink
Added unit tests for AURA and BABE block author
Browse files Browse the repository at this point in the history
  • Loading branch information
arjanz committed Sep 27, 2022
1 parent 39b4349 commit ef3d3a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
KUSAMA_NODE_URL = environ.get('SUBSTRATE_NODE_URL_KUSAMA') or 'wss://kusama-rpc.polkadot.io/'
POLKADOT_NODE_URL = environ.get('SUBSTRATE_NODE_URL_POLKADOT') or 'wss://rpc.polkadot.io/'
ROCOCO_NODE_URL = environ.get('SUBSTRATE_NODE_URL_ROCOCO') or 'wss://rococo-rpc.polkadot.io'

BABE_NODE_URL = environ.get('SUBSTRATE_BABE_NODE_URL') or POLKADOT_NODE_URL
AURA_NODE_URL = environ.get('SUBSTRATE_AURA_NODE_URL') or 'wss://acala-rpc-1.aca-api.network'

22 changes: 22 additions & 0 deletions test/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import unittest
from unittest.mock import MagicMock

from test import settings

from scalecodec.exceptions import RemainingScaleBytesNotEmptyException

from substrateinterface import SubstrateInterface
Expand Down Expand Up @@ -160,6 +162,14 @@ def mocked_request(method, params, result_handler=None):
cls.substrate.rpc_request = MagicMock(side_effect=mocked_request)
cls.substrate.query = MagicMock(side_effect=mocked_query)

cls.babe_substrate = SubstrateInterface(
url=settings.BABE_NODE_URL
)

cls.aura_substrate = SubstrateInterface(
url=settings.AURA_NODE_URL
)

def test_get_valid_extrinsics(self):

block = self.substrate.get_block(
Expand Down Expand Up @@ -272,6 +282,18 @@ def test_check_requirements(self):
finalized_only=True
)

def test_block_author_babe(self):
block = self.babe_substrate.get_block(include_author=True)

self.assertIn('author', block)
self.assertIsNotNone(block['author'])

def test_block_author_aura(self):
block = self.aura_substrate.get_block(include_author=True)

self.assertIn('author', block)
self.assertIsNotNone(block['author'])


if __name__ == '__main__':
unittest.main()

0 comments on commit ef3d3a0

Please sign in to comment.