Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def exec_test():
QTest.mouseClick(transfer_dialog.view.radio_pubkey, Qt.LeftButton)
QTest.keyClicks(transfer_dialog.view.edit_pubkey, alice.key.pubkey)
transfer_dialog.view.spinbox_amount.setValue(10)
await asyncio.sleep(0.1)
assert not transfer_dialog.view.button_box.button(QDialogButtonBox.Ok).isEnabled()
await asyncio.sleep(0.1)
QTest.keyClicks(transfer_dialog.view.password_input.edit_secret_key, bob.salt)
QTest.keyClicks(transfer_dialog.view.password_input.edit_password, bob.password)
assert transfer_dialog.view.button_box.button(QDialogButtonBox.Ok).isEnabled()
QTest.mouseClick(transfer_dialog.view.button_box.button(QDialogButtonBox.Ok), Qt.LeftButton)
await asyncio.sleep(0.2)
assert isinstance(fake_server_with_blockchain.forge.pool[0], Transaction)
def test_save_and_load_from_private_key_file(self):
sign_key_save = SigningKey.from_credentials("alice", "password", ScryptParams())
sign_key_save.save_private_key(TEST_FILE_PATH)
sign_key_load = SigningKey.from_private_key(TEST_FILE_PATH)
self.assertEqual(sign_key_save.sk, sign_key_load.sk)
def test_from_credentials(self):
sign_key = SigningKey.from_credentials("alice", "password", ScryptParams())
verify_key = VerifyingKey(sign_key.pubkey)
self.assertEqual(verify_key.vk, sign_key.vk)
def test_document_message(self):
# prepare message
document_message = DocumentMessage()
# prepare document
identity_document = Identity(
10,
"beta_brousouf",
"HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd",
"lolcat",
BlockUID(32, "DB30D958EE5CB75186972286ED3F4686B8A1C2CD"),
"J3G9oM5AKYZNLAB5Wx499w61NuUoS57JVccTShUbGpCMjCqj9yXXqNq7dyZpDWA6BxipsiaMZhujMeBfCznzyci",
)
# get json string message
json_document_message = document_message.get_json(
DocumentMessage.IDENTITY_TYPE_ID, identity_document.inline()
)
# convert to dict to verify
dict_document_message = json.loads(json_document_message)
# verify
self.assertIn("body", dict_document_message)
self.assertIn("name", dict_document_message["body"])
self.assertIn("identity", dict_document_message["body"])
self.assertEqual(4, dict_document_message["body"]["name"])
expected = """HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd\
:J3G9oM5AKYZNLAB5Wx499w61NuUoS57JVccTShUbGpCMjCqj9yXXqNq7dyZpDWA6BxipsiaMZhujMeBfCznzyci:32\
def test_add_update_node(meta_repo):
nodes_repo = NodesRepo(meta_repo.conn)
node = Node("testcurrency",
"7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ",
"""BASIC_MERKLED_API test-net.duniter.fr 13.222.11.22 9201
BASIC_MERKLED_API testnet.duniter.org 80
UNKNOWNAPI some useless information""",
BlockUID.empty(),
"doe",
"15-76543400E78B56CC21FB1DDC6CBAB24E0FACC9A798F5ED8736EA007F38617D67",
12376543345,
"14-AEFFCB00E78B56CC21FB1DDC6CBAB24E0FACC9A798F5ED8736EA007F38617D67",
0,
"duniter")
nodes_repo.insert(node)
node.previous_buid = node.current_buid
node.current_buid = "16-77543400E78B56CC21FB1DDC6CBAB24E0FACC9A798F5ED8736EA007F38617D67"
nodes_repo.update(node)
node2 = nodes_repo.get_one(pubkey="7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ")
assert node2.current_buid == block_uid("16-77543400E78B56CC21FB1DDC6CBAB24E0FACC9A798F5ED8736EA007F38617D67")
assert node2.previous_buid == block_uid("15-76543400E78B56CC21FB1DDC6CBAB24E0FACC9A798F5ED8736EA007F38617D67")
def test_add_get_multiple_node(meta_repo):
nodes_repo = NodesRepo(meta_repo.conn)
nodes_repo.insert(Node("testcurrency",
"7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ",
"""BASIC_MERKLED_API test-net.duniter.fr 13.222.11.22 9201
BASIC_MERKLED_API testnet.duniter.org 80
UNKNOWNAPI some useless information""",
BlockUID.empty(),
"doe",
"15-76543400E78B56CC21FB1DDC6CBAB24E0FACC9A798F5ED8736EA007F38617D67",
12376543345,
"14-AEFFCB00E78B56CC21FB1DDC6CBAB24E0FACC9A798F5ED8736EA007F38617D67",
0,
"duniter",
"0.30.17"))
nodes_repo.insert(Node("testcurrency",
"FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn",
"BASIC_MERKLED_API test-net.duniter.org 22.22.22.22 9201",
BlockUID.empty(),
"doe",
"18-76543400E78B56CC21FB1DDC6CBAB24E0FACC9A798F5ED8736EA007F38617D67",
12376543345,
"12-AEFFCB00E78B56CC21FB1DDC6CBAB24E0FACC9A798F5ED8736EA007F38617D67",
0,
async def go():
_, port, _ = await self.create_server(
"GET", "/network/peering/peers", handler
)
with self.assertRaises(jsonschema.exceptions.ValidationError):
client = Client(BMAEndpoint("127.0.0.1", "", "", port))
await client(network.peers)
await client.close()
async def go():
_, port, _ = await self.create_server(
"GET", "/wot/certified-by/pubkey", handler
)
with self.assertRaises(jsonschema.exceptions.ValidationError):
client = Client(BMAEndpoint("127.0.0.1", "", "", port))
await client(certified_by, "pubkey")
await client.close()
async def go():
_, port, _ = await self.create_server(
"GET",
"/blockchain/hardship/8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU",
handler,
)
with self.assertRaises(jsonschema.exceptions.ValidationError):
client = Client(BMAEndpoint("127.0.0.1", "", "", port))
await client(hardship, "8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU")
await client.close()
async def go():
_, port, _ = await self.create_server("GET", "/blockchain/with/tx", handler)
with self.assertRaises(jsonschema.exceptions.ValidationError):
client = Client(BMAEndpoint("127.0.0.1", "", "", port))
await client(tx)
await client.close()