Skip to content

Commit

Permalink
Merge pull request #191 from UnitapApp/fix/prizetap-provider-dashboard
Browse files Browse the repository at this point in the history
More tests
  • Loading branch information
ShayanShiravani authored Nov 21, 2023
2 parents 1997cf8 + c039b21 commit e913bd4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
40 changes: 40 additions & 0 deletions prizetap/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,46 @@ def test_create_raffle_with_invalid_winners_count(self):

self.assertEqual(raffle, None)

def test_create_raffle_with_invalid_chain_id(self):
Chain.objects.create(
chain_name="Sepolia",
wallet=self.wallet,
rpc_url_private=test_rpc_url_private,
explorer_url="https://sepolia.etherscan.io/",
fund_manager_address=fund_manager,
native_currency_name="ETH",
symbol="ETH",
chain_id="11155111",
max_claim_amount=1e11,
)

self.client.force_authenticate(user=self.user_profile.user)
self.raffle_data["chain"] = 3
response = self.client.post(reverse("create-raffle"), self.raffle_data)
self.assertEqual(response.status_code, 400)
self.assertEqual(Raffle.objects.count(), 1)
raffle = None
try:
raffle = Raffle.objects.get(pk=2)
except Raffle.DoesNotExist:
pass

self.assertEqual(raffle, None)

def test_create_raffle_with_invalid_contract_address(self):
self.client.force_authenticate(user=self.user_profile.user)
self.raffle_data["contract"] = "0x5363502325735d7b27162b2b3482c107fD4c5B3C"
response = self.client.post(reverse("create-raffle"), self.raffle_data)
self.assertEqual(response.status_code, 400)
self.assertEqual(Raffle.objects.count(), 1)
raffle = None
try:
raffle = Raffle.objects.get(pk=2)
except Raffle.DoesNotExist:
pass

self.assertEqual(raffle, None)

def test_set_raffle_tx(self):
self.client.force_authenticate(user=self.user_profile.user)
tx_hash = "0xb164ab20b5b9ada53906572dee4847b46f7be7b692c805619eb35be2d5053ace"
Expand Down
2 changes: 1 addition & 1 deletion prizetap/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def post(self, request, pk):


class ValidChainsView(ListAPIView):
queryset = Chain.objects.filter(chain_id__in=list(CONTRACT_ADDRESSES.keys()))
queryset = Chain.objects.filter(chain_id__in=list(CONTRACT_ADDRESSES.keys())).order_by("pk")
serializer_class = SmallChainSerializer

def get(self, request):
Expand Down

0 comments on commit e913bd4

Please sign in to comment.