

def test_expires(self):
    '\n        Ensure the expires argument is handled and checked appropriately.\n\n        * If it\'s not passed the expires metadata defaults to 0.0.\n        * It must be a number (int or float).\n        * It must be > 0\n        * The "expires" metadata must == timestamp + passed in expires arg.\n        '
    item = {
        'foo': 'bar',
        'baz': [1, 2, 3],
    }
    signed_item = get_signed_item(item, PUBLIC_KEY, PRIVATE_KEY)
    self.assertEqual(0.0, signed_item['_p4p2p']['expires'])
    signed_item = get_signed_item(item, PUBLIC_KEY, PRIVATE_KEY, 'foo')
    self.assertEqual(0.0, signed_item['_p4p2p']['expires'])
    signed_item = get_signed_item(item, PUBLIC_KEY, PRIVATE_KEY, 123)
    self.assertEqual((signed_item['_p4p2p']['timestamp'] + 123), signed_item['_p4p2p']['expires'])
    signed_item = get_signed_item(item, PUBLIC_KEY, PRIVATE_KEY, 123.456)
    self.assertEqual((signed_item['_p4p2p']['timestamp'] + 123.456), signed_item['_p4p2p']['expires'])
    signed_item = get_signed_item(item, PUBLIC_KEY, PRIVATE_KEY, (- 1))
    self.assertEqual(0.0, signed_item['_p4p2p']['expires'])

dataset/ETHPy150Open ntoll/p4p2p/test/dht/test_crypto.py TestGetSignedItem.test_expires/original