From fd756e8484d5ca0c48ecd81cfaa430d6a7dc0e42 Mon Sep 17 00:00:00 2001 From: Shayan Shiravani Date: Tue, 21 Nov 2023 09:10:38 +0330 Subject: [PATCH] More tests --- prizetap/tests.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/prizetap/tests.py b/prizetap/tests.py index 89ab1788..5b54dbd8 100644 --- a/prizetap/tests.py +++ b/prizetap/tests.py @@ -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"