def test_validate_not_sane_zeroes(self): db = MockDatabase() block1 = TriblerBandwidthBlock() # Act block1.transaction = {'up': 0, 'down': 0, 'total_up': 30, 'total_down': 40} result = block1.validate(db) self.assertEqual(result[0], ValidationResult.invalid) self.assertIn("Up and down are zero", result[1])
def test_validate_not_sane_zeroes(self): db = MockDatabase() block1 = TriblerBandwidthBlock() # Act block1.transaction = {'up': 0, 'down': 0, 'total_up': 30, 'total_down': 40} result = block1.validate(db) self.assertEqual(result[0], ValidationResult.invalid) self.assertIn("Up and down are zero", result[1])
def test_validate_not_sane_negatives(self): db = MockDatabase() block1 = TriblerBandwidthBlock() # Act block1.transaction = {'up': -10, 'down': -10, 'total_up': -20, 'total_down': -10} result = block1.validate(db) self.assertEqual(result[0], ValidationResult.invalid) self.assertIn("Up field is negative", result[1]) self.assertIn("Down field is negative", result[1]) self.assertIn("Total up field is negative", result[1]) self.assertIn("Total down field is negative", result[1])
def test_validate_not_sane_negatives(self): db = MockDatabase() block1 = TriblerBandwidthBlock() # Act block1.transaction = {'up': -10, 'down': -10, 'total_up': -20, 'total_down': -10} result = block1.validate(db) self.assertEqual(result[0], ValidationResult.invalid) self.assertIn("Up field is negative", result[1]) self.assertIn("Down field is negative", result[1]) self.assertIn("Total up field is negative", result[1]) self.assertIn("Total down field is negative", result[1])