def test_get_optimized_address_state2(self): alice_xmss = get_alice_xmss() alice_address = alice_xmss.address address_state = OptimizedAddressState.get_optimized_address_state(self.state, alice_address) addresses_state = { alice_address: address_state } self.assertTrue(isinstance(address_state.address, bytes)) OptimizedAddressState.put_optimized_addresses_state(self.state, addresses_state) address_state = OptimizedAddressState.get_optimized_address_state(self.state, alice_address) self.assertTrue(isinstance(address_state.address, bytes))
def test_put_addresses_state(self): with set_xrd_dir('no_data'): with State() as state: alice_xmss = get_alice_xmss() alice_state = OptimizedAddressState.get_default( alice_xmss.address) addresses_state = { alice_state.address: alice_state, b'test1': OptimizedAddressState.get_default(b'test1') } AddressState.put_addresses_state(state, addresses_state, None) alice_state2 = OptimizedAddressState.get_optimized_address_state( state, alice_xmss.address) self.assertEqual(alice_state.serialize(), alice_state2.serialize()) test_state = OptimizedAddressState.get_optimized_address_state( state, b'test1') self.assertEqual( test_state.serialize(), OptimizedAddressState.get_default(b'test1').serialize())
def test_get_optimized_address_state(self): alice_xmss = get_alice_xmss() alice_address = alice_xmss.address address_state = OptimizedAddressState.get_optimized_address_state(self.state, alice_address) self.assertTrue(isinstance(address_state.address, bytes)) alice_address = bytearray(alice_xmss.address) with self.assertRaises(TypeError): OptimizedAddressState.get_optimized_address_state(self.state, alice_address) alice_address = alice_xmss.address address_state = OptimizedAddressState.get_optimized_address_state(self.state, alice_address) addresses_state = { alice_address: address_state } self.assertTrue(isinstance(address_state.address, bytes)) AddressState.put_addresses_state(self.state, addresses_state) address_state = OptimizedAddressState.get_optimized_address_state(self.state, alice_address) self.assertTrue(isinstance(address_state.address, bytes))