Skip to content
This repository was archived by the owner on Nov 15, 2021. It is now read-only.

Fix a couple of tests #652

Merged
merged 4 commits into from
Oct 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions neo/Core/TX/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def test_tx_types(self):
tx_vout = []

def test_tx_deserialize(self):

ms = MemoryStream(self.tx_raw_hex)

reader = BinaryReader(ms)
Expand Down Expand Up @@ -59,7 +58,6 @@ def test_tx_deserialize(self):
ctx_id = b'4feb0081f9425cab84269127bef0a871a84d4408f09923d17ebb257cd231b362'

def test_contract_tx_deserialize(self):

ms = MemoryStream(binascii.unhexlify(self.ctx_raw))

reader = BinaryReader(ms)
Expand All @@ -74,7 +72,6 @@ def test_contract_tx_deserialize(self):
pb_hash = b'5467a1fc8723ceffa8e5ee59399b02eea1df6fbaa53768c6704b90b960d223fa'

def test_publish_tx_deserialize(self):

ms = MemoryStream(binascii.unhexlify(self.pb_raw))

reader = BinaryReader(ms)
Expand Down Expand Up @@ -111,7 +108,6 @@ def test_invocation_transaction(self):
mrh = b'4c68669a54fa247d02545cff9d78352cb4a5059de7b3cd6ba82efad13953c9b9'

def test_miner_tx(self):

ms = MemoryStream(binascii.unhexlify(self.mr))

reader = BinaryReader(ms)
Expand All @@ -124,7 +120,6 @@ def test_miner_tx(self):
rrid = b'0c092117b4ba47b81001712425e6e7f760a637695eaf23741ba335925b195ecd'

def test_register_tx(self):

ms = MemoryStream(binascii.unhexlify(self.rr))

reader = BinaryReader(ms)
Expand All @@ -137,15 +132,14 @@ def test_register_tx(self):
self.assertEqual(asset['admin'], 'ARFe4mTKRTETerRoMsyzBXoPt2EKBvBXFX')
self.assertEqual(asset['name'], '[{"lang":"zh-CN","name":"TestCoin"}]')
self.assertEqual(asset['precision'], 8)
self.assertEquals(Fixed8.FromDecimal(settings.ALL_FEES['RegisterTransaction']), tx.SystemFee())
self.assertEqual(Fixed8.FromDecimal(settings.ALL_FEES['RegisterTransaction']), tx.SystemFee())

cr = b'800001f012e99481e4bb93e59088e7baa6e6b58be8af9502f8e0bc69b6af579e69a56d3d3d559759cdb848cb55b54531afc6e3322c85badf08002c82c09c5b49d10cd776c8679789ba98d0b0236f0db4dc67695a1eb920a646b9000001cd5e195b9235a31b7423af5e6937a660f7e7e62524710110b847bab41721090c0061c2540cd1220067f97110a66136d38badc7b9f88eab013027ce490241400bd2e921cee90c8de1a192e61e33eb8980a3dc00c388ee9aac0712178cc8fceed8bb59788f7caf3c4dc082abcdaaa49772fda86db4ceea243bda31bcde9b8a0b3c21034b44ed9c8a88fb2497b6b57206cc08edd42c5614bd1fee790e5b795dee0f4e1104182f145967cc4ee2f1c9f4e0782756dabf246d0a4fe60a035441402fe3e20c303e26c3817fed6fc7db8edde4ac62b16eee796c01c2b59e382b7ddfc82f0b36c7f7520821c7b72b9aff50ae27a016961f1ef1dade9cafa85655380f2321034b44ed9c8a88fb2497b6b57206cc08edd42c5614bd1fee790e5b795dee0f4e11ac'
cr2 = b'800001f012e99481e4bb93e59088e7baa6e6b58be8af9502f8e0bc69b6af579e69a56d3d3d559759cdb848cb55b54531afc6e3322c85badf08002c82c09c5b49d10cd776c8679789ba98d0b0236f0db4dc67695a1eb920a646b9000001cd5e195b9235a31b7423af5e6937a660f7e7e62524710110b847bab41721090c0061c2540cd1220067f97110a66136d38badc7b9f88eab013027ce49'

crid = b'e4d2ea5df2adf77df91049beccbb16f98863b93a16439c60381eac1f23bff178'

def test_contract_tx_again(self):

ms = MemoryStream(binascii.unhexlify(self.cr))

reader = BinaryReader(ms)
Expand All @@ -159,7 +153,6 @@ def test_contract_tx_again(self):
p2id = b'514157940a3e31b087891c5e8ed362721f0a7f3dda3f80b7a3fe618d02b7d3d3'

def test_pub_two(self):

ms = MemoryStream(binascii.unhexlify(self.p2))

reader = BinaryReader(ms)
Expand All @@ -174,7 +167,6 @@ def test_pub_two(self):
eid = b'988832f693785dcbcb8d5a0e9d5d22002adcbfb1eb6bbeebf8c494fff580e147'

def test_enrollment_tx(self):

ms = MemoryStream(binascii.unhexlify(self.eraw))

reader = BinaryReader(ms)
Expand All @@ -201,7 +193,6 @@ def test_tx_big_remark(self):
path = '%s/fixtures/bigtx.txt' % os.getcwd()

with open(path, 'rb') as f:

blockraw = f.read().strip()

unhex = binascii.unhexlify(blockraw)
Expand Down
12 changes: 7 additions & 5 deletions neo/Prompt/Commands/Send.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ def construct_and_send(prompter, wallet, arguments, prompt_password=True):
address_to = get_arg(arguments, 1)
amount = get_arg(arguments, 2)

if float(amount) == 0:
print("amount cannot be 0")
try:
if float(amount) == 0:
print("amount cannot be 0")
return False
except ValueError:
# float parse error
return False

assetId = get_asset_id(wallet, to_send)
Expand Down Expand Up @@ -98,7 +102,6 @@ def construct_and_send(prompter, wallet, arguments, prompt_password=True):
signer_contract = wallet.GetContract(standard_contract)

if not signer_contract.IsMultiSigContract and owners is None:

data = standard_contract.Data
tx.Attributes = [TransactionAttribute(usage=TransactionAttributeUsage.Script,
data=data)]
Expand All @@ -123,7 +126,7 @@ def construct_and_send(prompter, wallet, arguments, prompt_password=True):

tx.scripts = context.GetScripts()

# print("will send tx: %s " % json.dumps(tx.ToJson(),indent=4))
# print("will send tx: %s " % json.dumps(tx.ToJson(),indent=4))

relayed = NodeLeader.Instance().Relay(tx)

Expand All @@ -150,7 +153,6 @@ def construct_and_send(prompter, wallet, arguments, prompt_password=True):


def parse_and_sign(prompter, wallet, jsn):

try:
context = ContractParametersContext.FromJson(jsn)
if context is None:
Expand Down
4 changes: 3 additions & 1 deletion neo/Prompt/Commands/tests/test_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class BootstrapTestCase(TestCase):

bootstrap_file_good = 'https://s3.us-east-2.amazonaws.com/cityofzion/bootstrap_testnet/bootstraptest.tar.gz'
bootstrap_file_bad = 'https://s3.us-east-2.amazonaws.com/blah.tar.gz'

Expand All @@ -24,6 +23,9 @@ def tearDown(self):
def test_1_bad_bootstrap_file(self):

# this should exit 0
print("*** ***")
print("*** This test expects a `404 Not found` ***")
print("*** ***")
with self.assertRaises(SystemExit):
BootstrapBlockchainFile(self.bootstrap_target_dir, self.bootstrap_file_bad, require_confirm=False)

Expand Down
3 changes: 3 additions & 0 deletions neo/Utils/BlockchainFixtureTestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
from neo.Settings import settings
import logzero
import os
import neo


class BlockchainFixtureTestCase(NeoTestCase):
FIXTURE_REMOTE_LOC = 'https://s3.us-east-2.amazonaws.com/cityofzion/fixtures/fixtures_v8.tar.gz'
FIXTURE_FILENAME = os.path.join(settings.DATA_DIR_PATH, 'Chains/fixtures_v8.tar.gz')
_blockchain = None

root_folder = os.path.dirname(neo.__file__)[:-4]

@classmethod
def leveldb_testpath(cls):
return 'Override Me!'
Expand Down
14 changes: 7 additions & 7 deletions neo/Utils/WalletFixtureTestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,43 @@ def leveldb_testpath(self):

@classmethod
def wallet_1_path(cls):
return './fixtures/neo-test1-w.wallet'
return cls.root_folder + '/fixtures/neo-test1-w.wallet'

@classmethod
def wallet_1_dest(cls):
return './wallet1.wallet'
return cls.root_folder + '/wallet1.wallet'

@classmethod
def wallet_1_pass(cls):
return '1234567890'

@classmethod
def wallet_2_path(cls):
return './fixtures/neo-test2-w.wallet'
return cls.root_folder + '/fixtures/neo-test2-w.wallet'

@classmethod
def wallet_2_dest(cls):
return './wallet2.wallet'
return cls.root_folder + '/wallet2.wallet'

@classmethod
def wallet_2_pass(cls):
return '1234567890'

@classmethod
def wallet_3_path(cls):
return './fixtures/neo-test3-w.wallet'
return cls.root_folder + '/fixtures/neo-test3-w.wallet'

@classmethod
def wallet_3_dest(cls):
return './wallet3.wallet'
return cls.root_folder + '/wallet3.wallet'

@classmethod
def wallet_3_pass(cls):
return '1234567890'

@classmethod
def new_wallet_dest(cls):
return './newwallet.wallet'
return cls.root_folder + '/newwallet.wallet'

@classmethod
def new_wallet_pass(self):
Expand Down
3 changes: 2 additions & 1 deletion neo/test_preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def test_prefs_json_empty(self):
self.assertEqual(prefs._prefs, PREFERENCES_DEFAULT)

# Make sure it's possible to get the theme prefs
self.assertEqual(prefs.token_style, PREFERENCES_DEFAULT["themes"]["dark"])
current_selected_theme = prefs._prefs['theme']
self.assertEqual(prefs.token_style, PREFERENCES_DEFAULT["themes"][current_selected_theme])

# Cannot set an invalid theme
with self.assertRaises(ValueError):
Expand Down