Skip to content

Commit

Permalink
Fix block_number filter to module txs
Browse files Browse the repository at this point in the history
- Closes #136
  • Loading branch information
Uxio0 committed Aug 27, 2020
1 parent 9cb8c8a commit 997a1c5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions safe_transaction_service/history/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ class Meta:


class ModuleTransactionFilter(filters.FilterSet):
block_number = django_filters.NumberFilter(field_name='internal_tx__ethereum_tx__block_number')
block_number__gt = django_filters.NumberFilter(field_name='internal_tx__ethereum_tx__block_number',
block_number = django_filters.NumberFilter(field_name='internal_tx__ethereum_tx__block_id')
block_number__gt = django_filters.NumberFilter(field_name='internal_tx__ethereum_tx__block_id',
lookup_expr='gt')
block_number__lt = django_filters.NumberFilter(field_name='internal_tx__ethereum_tx__block_number',
block_number__lt = django_filters.NumberFilter(field_name='internal_tx__ethereum_tx__block_id',
lookup_expr='lt')
transaction_hash = django_filters.CharFilter(field_name='internal_tx__ethereum_tx_id')

Expand Down
9 changes: 9 additions & 0 deletions safe_transaction_service/history/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ def test_get_module_transactions(self):
self.assertEqual(response.data['results'][0]['safe'], module_transaction.safe)
self.assertEqual(response.data['results'][0]['module'], module_transaction.module)

# Add another ModuleTransaction to check filters
ModuleTransactionFactory(safe=safe_address)

url = reverse('v1:module-transactions',
args=(safe_address,)) + f'?transaction_hash={module_transaction.internal_tx.ethereum_tx_id}'
response = self.client.get(url, format='json')
Expand All @@ -149,6 +152,12 @@ def test_get_module_transactions(self):
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data['count'], 0)

url = reverse('v1:module-transactions',
args=(safe_address,)) + f'?block_number={module_transaction.internal_tx.ethereum_tx.block_id}'
response = self.client.get(url, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data['count'], 1)

def test_get_multisig_transaction(self):
safe_tx_hash = Web3.keccak(text='gnosis').hex()
response = self.client.get(reverse('v1:multisig-transaction', args=(safe_tx_hash,)), format='json')
Expand Down

0 comments on commit 997a1c5

Please sign in to comment.