Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
tx.add_command(
Command.SetAccountQuorum(
account_id = "test@test",
quorum = 2
)
)
logger.info("check signatures")
self.assertEqual(tx.count_signatures(),0)
tx.sign()
self.assertEqual(tx.count_signatures(),3)
self.assertTrue(tx.verify())
tx.add_key_pair(crypto.create_key_pair())
tx.sign()
self.assertEqual(tx.count_signatures(),4)
self.assertTrue(tx.verify())
tx.time_stamp()
tx.add_key_pair(crypto.create_key_pair())
tx.sign()
self.assertFalse(tx.verify())
tx.signatures_clean()
self.assertEqual(tx.count_signatures(),0)
self.assertEqual(tx.signatories.size(),0)
self.assertTrue(tx.verify())
tx.add_command(
Command.AddSignatory(
def setUp(self):
logger.setDebug()
logger.debug("CommandTest")
self.keypair = crypto.create_key_pair()
def setUp(self):
self.creator = "chika@ichigo.mashimaro"
self.keypair = crypto.create_key_pair()
self.tx_counter = 0
logger.setDebug()
def test_sha3_sign(self):
key_pair = crypto.create_key_pair()
message = crypto.sha3_256(bytes(b'a031b'))
dummy_message = crypto.sha3_256(bytes(b'a032b'))
sign = crypto.sign(key_pair,message)
self.assertTrue(crypto.verify(key_pair.public_key,sign,message))
self.assertFalse(crypto.verify(key_pair.public_key,sign,dummy_message))
def test_transaction(self):
logger.debug("test_transaction")
tx = Transaction()
keypairs = []
keypairs.append(crypto.create_key_pair())
keypairs.append(crypto.create_key_pair())
keypairs.append(crypto.create_key_pair())
tx.add_key_pairs(keypairs)
tx.set_creator_account_id("test@test")
logger.info("add command")
tx.add_command(
Command.AddSignatory(
account_id = "test@test",
pubkey = keypairs[0].public_key
)
)
tx.add_command(
Command.SetAccountQuorum(
def test_signatories(self):
signatories = Signatories()
keypairs = []
keypairs.append(crypto.create_key_pair())
keypairs.append(crypto.create_key_pair())
keypairs.append(crypto.create_key_pair())
for key in keypairs:
signatories.append(key)
self.assertTrue(signatories.size() == 3)
tx = Transaction(
payload = Transaction.Payload(
creator_account_id = "test@test"
),
signatures = []
)
signatories.sign(tx)
def setUp(self):
logger.setInfo()
logger.info("RequestTest")
self.keypair = crypto.create_key_pair()
def setUp(self):
self.keypair = crypto.create_key_pair()
create_ac = Command.CreateAccount(
account_name = "rihito",
domain_id = "light.wing",
main_pubkey = self.keypair.public_key
)
self.payload = Transaction.Payload(
commands = [
Command(create_account = create_ac)
],
creator_account_id = "rihito@light.wing",
tx_counter = 0,
created_time = crypto.now()
)
self.tx = Transaction(
def test_create_tx(self):
logger.info("test_create_tx")
creator = Creator()
keypairs = []
keypairs.append(crypto.create_key_pair())
keypairs.append(crypto.create_key_pair())
creator.set_account_id("test@test")
creator.set_keys(keypairs)
tx = creator.create_tx()
tx.sign()
self.assertEqual(
tx.debug_proto_transaction(),
Transaction(
payload = Transaction.Payload(
creator_account_id = "test@test",
created_time = tx.debug_proto_transaction().payload.created_time
),
signatures = [
def keygen():
"""
Generate keypair ( public key and private key )
Returns:
`KeyPair`: base64 encoded ed25519 with sha3_256 keypair [ public_key, private_key ].
"""
return crypto.create_key_pair()