Esempio n. 1
0
 def test(self):
     bad_o = [['16ViwyAVeKtz4vbTXWRSYgadT5w3Rj3yuq', 0],
              ['18pPTxvTc9rJZfD2tM1bNYHFhAcZjgqEdQ', 9.4]]
     with self.assertRaises(
             InvalidAmounts,
             msg="Invalid Amount not happening when zero input is tried"):
         make_transaction(i, bad_o)
Esempio n. 2
0
    def test(self):
        bad_o = [['16ViwyAVeKtz4vbTXWRSYgadT5w3Rj3yuq', 2.2],
                 ['18pPTxvTc9rJZfD2tM1bNYHFhAcZjgqEdQ', 9.4]]
        msg = "Invalid Amount not happening when outputs exceed inputs when making new trasnaction"

        with self.assertRaises(InvalidAmounts, msg=msg):
            make_transaction(i, bad_o)
Esempio n. 3
0
 def test_creation(self):
     o = [  # outputs with more than 8 decimal places
         ['16ViwyAVeKtz4vbTXWRSYgadT5w3Rj3yuq', 2.100000003],
         ['18pPTxvTc9rJZfD2tM1bNYHFhAcZjgqEdQ', 1.3037264856]
     ]
     msg = "Transaction creation fails when output has more than 8 decimal places"
     with self.assertRaises(InvalidAmounts, msg=msg):
         make_transaction(i, o)
Esempio n. 4
0
    def test(self):
        i = [[
            '18pvhMkv1MZbZZEncKucAmVDLXZsD9Dhk6', 3.2,
            'KwuVvv359oft9TfzyYLAQBgpPyCFpcTSrV9ZgJF9jKdT8jd7XLH2'
        ],
             [
                 '14ZiHtrmT6Mi4RT2Liz51WKZMeyq2n5tgG', 0.5,
                 'KxWoW9Pj45UzUH1d5p3wPe7zxbdJqU7HHkDQF1YQS1AiQg9qeZ9H'
             ]]
        o = [['3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy', 2.2]]

        with self.assertRaises(InvalidAddress, msg="3 addresses are invalid"):
            make_transaction(i, o)
Esempio n. 5
0
    def test(self):
        bad_tx = make_transaction(i, o)
        bad_tx['inputs'][0][1] = 0.2
        msg = "Invalid Signature not happening when amount is changed"

        with self.assertRaises(InvalidSignature, msg=msg):
            validate_transaction(bad_tx, ledger)
Esempio n. 6
0
def make_test_tx(fee=0.01):
    spend_addr, spend_priv = make_keys()
    receive_addr, _ = make_keys()

    seed_value = random.random() * 5 + 0.1
    spend_value = seed_value - (seed_value * 0.5)
    lu = datetime.datetime.now() - datetime.timedelta(hours=1)

    LedgerEntry.objects.create(address=spend_addr,
                               amount=float("%.8f" % seed_value),
                               last_updated=lu)
    return make_transaction(
        [[spend_addr, float("%.8f" % spend_value), spend_priv]],
        [[receive_addr, float("%.8f" % (spend_value - fee))]])
Esempio n. 7
0
 def test(self):
     bad_sig = make_transaction(i, o)
     bad_sig['inputs'][0][2] = "23784623kjhdfkjashdfkj837242387"
     msg = "Invalid Signature not happening when sig is edited"
     with self.assertRaises(InvalidSignature, msg=msg):
         validate_transaction(bad_sig, ledger)
Esempio n. 8
0
 def test(self):
     msg = "Catch input spending coin that doesn't exist"
     with self.assertRaises(InvalidAmounts, msg=msg):
         validate_transaction(make_transaction(i, o), bad_ledger)
Esempio n. 9
0
 def test(self):
     self.assertEqual(validate_transaction(make_transaction(i, o), ledger),
                      True,
                      msg="Basic transaction creation fails")
Esempio n. 10
0
 def test(self):
     bad_o = [['16ViwyAVeKtz4vbTXWRSYgadT5w3Rj3yuq', -42.07],
              ['18pPTxvTc9rJZfD2tM1bNYHFhAcZjgqEdQ', 9.4]]
     msg = "Invalid Amount not happening when negative input is tried on transaction creation"
     with self.assertRaises(InvalidAmounts, msg=msg):
         make_transaction(i, bad_o)