Skip to content
Snippets Groups Projects
Commit 23528e8b authored by Anthony Martin's avatar Anthony Martin
Browse files

tests #163

parent 323474bd
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,10 @@ class KeysubTest(unittest.TestCase): ...@@ -15,7 +15,10 @@ class KeysubTest(unittest.TestCase):
self.assertEqual(result, expected_result) self.assertEqual(result, expected_result)
def test_compute_keypair_from_seed(self): def test_compute_keypair_from_seed(self):
# Note, resolver needs to be mocked to properly test. try:
self.assertRaises(FileNotFoundError, keysub.compute_keypair_from_seed, '1234', 'secret') # Try in case the binary is in the path environment.
true_exe = shutil.which("true") self.assertRaises(json.decoder.JSONDecodeError, keysub.compute_keypair_from_seed, '1234', 'secret')
self.assertRaises(json.decoder.JSONDecodeError, keysub.compute_keypair_from_seed, '1234', 'secret', true_exe) except FileNotFoundError:
# Note, resolver needs to be mocked to properly test.
true_exe = shutil.which("true")
self.assertRaises(json.decoder.JSONDecodeError, keysub.compute_keypair_from_seed, '1234', 'secret', true_exe)
["submit_transaction", {"esc": "j", "tx": {"operations": [{"type": "transfer_operation", "value": {"amount": {"amount": "102", "nai": "@@000000013", "precision": 3}, "from": "zoelfahmi", "memo": "https://steemit.com/animal/@zoelfahmi/the-smallest-animal-in-the-world-that-is-unique-bilingual-3e76e7cabe4e3", "to": "upvotewhale"}}], "wif_sigs": ["jprivatekey:active-tnmanj"]}}]
["submit_transaction", {"esc": "h", "tx": {"operations": [{"type": "limit_order_create_operation", "value": {"amount_to_sell": {"amount": "4002", "nai": "@@000000013", "precision": 3}, "expiration": "1969-12-31T23:59:59", "fill_or_kill": false, "min_to_receive": {"amount": "5230", "nai": "@@000000021", "precision": 3}, "orderid": 1536678065, "owner": "afril"}}], "wif_sigs": ["hprivatekey:active-tnmanh"]}}]
["submit_transaction", {"esc": "h", "tx": {"operations": [{"type": "limit_order_cancel_operation", "value": {"orderid": 2923913328, "owner": "stmdev"}}], "wif_sigs": ["hprivatekey:active-tnmanh"]}}]
["submit_transaction", {"esc": "h", "tx": {"operations": [{"type": "limit_order_create_operation", "value": {"amount_to_sell": {"amount": "647", "nai": "@@000000021", "precision": 3}, "expiration": "2018-09-18T15:01:26", "fill_or_kill": false, "min_to_receive": {"amount": "500", "nai": "@@000000013", "precision": 3}, "orderid": 1926478291, "owner": "stmdev"}}], "wif_sigs": ["hprivatekey:active-tnmanh"]}}]
["submit_transaction", {"esc": "d", "tx": {"operations": [{"type": "transfer_operation", "value": {"amount": {"amount": "1", "nai": "@@000000013", "precision": 3}, "from": "tipu", "memo": "@tipU will upvote this post in 14 minutes :)", "to": "upvotebank"}}], "wif_sigs": ["dprivatekey:active-tnmand"]}}]
["submit_transaction", {"esc": "q", "tx": {"operations": [{"type": "transfer_operation", "value": {"amount": {"amount": "1", "nai": "@@000000013", "precision": 3}, "from": "byresteem", "memo": "Campaign !!! Byresteem is much stronger now. !!! Hello users , My account with the most followers . I can promote your post.28.000 Followers + Byresteem Upvote 7600Sp + Upvote min +250 Different accounts + New followers + Loyality bonus FREE and more. Send 2 SBD or 2 STEEM To ByResteem URL as Memo Service ACTIVE", "to": "jedigeiss"}}], "wif_sigs": ["qprivatekey:active-tnmanq"]}}]
["submit_transaction", {"esc": "j", "tx": {"operations": [{"type": "transfer_operation", "value": {"amount": {"amount": "5000", "nai": "@@000000013", "precision": 3}, "from": "mikehamm", "memo": "https://steemit.com/politics/@mikehamm/fast-and-furious", "to": "smartmarket"}}], "wif_sigs": ["jprivatekey:active-tnmanj"]}}]
["submit_transaction", {"esc": "d", "tx": {"operations": [{"type": "transfer_to_vesting_operation", "value": {"amount": {"amount": "863", "nai": "@@000000021", "precision": 3}, "from": "arcange", "to": ""}}], "wif_sigs": ["dprivatekey:active-tnmand"]}}]
["submit_transaction", {"esc": "h", "tx": {"operations": [{"type": "transfer_operation", "value": {"amount": {"amount": "269494", "nai": "@@000000021", "precision": 3}, "from": "sm-usd", "memo": "P-GKTYR0QJXS", "to": "steemmonsters"}}], "wif_sigs": ["hprivatekey:active-tnmanh"]}}]
["submit_transaction", {"esc": "d", "tx": {"operations": [{"type": "transfer_operation", "value": {"amount": {"amount": "1", "nai": "@@000000021", "precision": 3}, "from": "sm-voter", "memo": "Successful Steemmonsters registration.", "to": "wombykus"}}], "wif_sigs": ["dprivatekey:active-tnmand"]}}]
...@@ -7,6 +7,7 @@ from tinman import txgen ...@@ -7,6 +7,7 @@ from tinman import txgen
FULL_CONF = { FULL_CONF = {
"transactions_per_block" : 40, "transactions_per_block" : 40,
"snapshot_file" : "/tmp/test-snapshot.json", "snapshot_file" : "/tmp/test-snapshot.json",
"backfill_file" : "/tmp/test-backfill.actions",
"min_vesting_per_account" : {"amount" : "1", "precision" : 3, "nai" : "@@000000021"}, "min_vesting_per_account" : {"amount" : "1", "precision" : 3, "nai" : "@@000000021"},
"total_port_balance" : {"amount" : "200000000000", "precision" : 3, "nai" : "@@000000021"}, "total_port_balance" : {"amount" : "200000000000", "precision" : 3, "nai" : "@@000000021"},
"accounts" : { "accounts" : {
...@@ -212,6 +213,7 @@ class TxgenTest(unittest.TestCase): ...@@ -212,6 +213,7 @@ class TxgenTest(unittest.TestCase):
def test_build_actions(self): def test_build_actions(self):
shutil.copyfile("test-snapshot.json", "/tmp/test-snapshot.json") shutil.copyfile("test-snapshot.json", "/tmp/test-snapshot.json")
shutil.copyfile("test-backfill.actions", "/tmp/test-backfill.actions")
for action in txgen.build_actions(FULL_CONF): for action in txgen.build_actions(FULL_CONF):
cmd, args = action cmd, args = action
...@@ -220,7 +222,7 @@ class TxgenTest(unittest.TestCase): ...@@ -220,7 +222,7 @@ class TxgenTest(unittest.TestCase):
self.assertEqual(args["txgen:semver"], "0.2") self.assertEqual(args["txgen:semver"], "0.2")
self.assertEqual(args["txgen:transactions_per_block"], 40) self.assertEqual(args["txgen:transactions_per_block"], 40)
self.assertIsNotNone(args["epoch:created"]) self.assertIsNotNone(args["epoch:created"])
self.assertEqual(args["actions:count"], 63) self.assertEqual(args["actions:count"], 73)
self.assertGreater(args["recommend:miss_blocks"], 28968013) self.assertGreater(args["recommend:miss_blocks"], 28968013)
self.assertEqual(args["snapshot:semver"], "0.2") self.assertEqual(args["snapshot:semver"], "0.2")
self.assertEqual(args["snapshot:origin_api"], "http://calculon.local") self.assertEqual(args["snapshot:origin_api"], "http://calculon.local")
...@@ -228,6 +230,16 @@ class TxgenTest(unittest.TestCase): ...@@ -228,6 +230,16 @@ class TxgenTest(unittest.TestCase):
self.assertGreater(args["count"], 0) self.assertGreater(args["count"], 0)
elif cmd == "submit_transaction": elif cmd == "submit_transaction":
self.assertGreater(len(args["tx"]["operations"]), 0) self.assertGreater(len(args["tx"]["operations"]), 0)
self.assertIsInstance(args["tx"]["wif_sigs"], list)
for wif in args["tx"]["wif_sigs"]:
if isinstance(wif, str):
if len(wif) < 51:
self.assertEqual(args["esc"], wif[0])
self.assertEqual(args["esc"], wif[-1])
else:
self.assertEqual(len(wif), 51)
else:
self.assertIsInstance(wif, prockey.ProceduralPrivateKey)
else: else:
self.fail("Unexpected action: %s" % cmd) self.fail("Unexpected action: %s" % cmd)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment