Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Update boa tests to work with new awesome fixture setup (#93)
Browse files Browse the repository at this point in the history
* Update boa tests to work with new awesome fixture setup

* Add required fixtures

* update changelog
  • Loading branch information
localhuman committed Sep 21, 2018
1 parent 43f8111 commit 94f507e
Show file tree
Hide file tree
Showing 20 changed files with 49 additions and 42 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -3,6 +3,10 @@ Changelog

All notable changes to this project following the ``v0.4.1`` release are noted in this file

[0.5.1] In Progress
-----------------------
- Use reduced sized fixtures for quicker tests

[0.5.0] 2018-08-26
-----------------------
- Python 3.7 compatibility
Expand Down
2 changes: 1 addition & 1 deletion boa_test/example/blockchain/AppCallTest.py
@@ -1,6 +1,6 @@
from boa.interop.Neo.App import RegisterAppCall

CalculatorContract = RegisterAppCall('e9e17cd49e4a198e8825b775bd685a4d0818a757', 'operation', 'a', 'b')
CalculatorContract = RegisterAppCall('86d58778c8d29e03182f38369f0d97782d303cc0', 'operation', 'a', 'b')


def Main(operation, a, b):
Expand Down
6 changes: 3 additions & 3 deletions boa_test/example/demo/nex/token.py
Expand Up @@ -12,7 +12,7 @@

# This is the script hash of the address for the owner of the token
# This can be found in ``neo-python`` with the wallet open, use ``wallet`` command
TOKEN_OWNER = b'S\xefB\xc8\xdf!^\xbeZ|z\xe8\x01\xcb\xc3\xac/\xacI)'
TOKEN_OWNER = b'\x1c\xc9\xc0\\\xef\xff\xe6\xcd\xd7\xb1\x82\x81j\x91R\xec!\x8d.\xc0'

TOKEN_CIRC_KEY = b'in_circulation'

Expand All @@ -30,10 +30,10 @@
MAX_EXCHANGE_LIMITED_ROUND = 500 * 40 * 100000000

# when to start the crowdsale
BLOCK_SALE_START = 755000
BLOCK_SALE_START = 12340

# when to end the initial limited round
LIMITED_ROUND_END = 755000 + 10000
LIMITED_ROUND_END = 12340 + 10000

KYC_KEY = b'kyc_ok'

Expand Down
18 changes: 9 additions & 9 deletions boa_test/tests/boa_test.py
Expand Up @@ -13,7 +13,7 @@ class BoaTest(WalletFixtureTestCase):

dirname = None

FIXTURE_REMOTE_LOC = 'https://s3.us-east-2.amazonaws.com/cityofzion/fixtures/fixtures_v7.tar.gz'
FIXTURE_REMOTE_LOC = 'https://s3.us-east-2.amazonaws.com/cityofzion/fixtures/fixtures_v8.tar.gz'
FIXTURE_FILENAME = 'fixtures/empty_fixture.tar.gz'

wallet_1_script_hash = UInt160(data=b'S\xefB\xc8\xdf!^\xbeZ|z\xe8\x01\xcb\xc3\xac/\xacI)')
Expand All @@ -40,24 +40,24 @@ class BoaFixtureTest(WalletFixtureTestCase):

dirname = None

FIXTURE_REMOTE_LOC = 'https://s3.us-east-2.amazonaws.com/cityofzion/fixtures/fixtures_v7.tar.gz'
FIXTURE_FILENAME = './fixtures/fixtures_v7.tar.gz'
FIXTURE_REMOTE_LOC = 'https://s3.us-east-2.amazonaws.com/cityofzion/fixtures/fixtures_v8.tar.gz'
FIXTURE_FILENAME = './fixtures/fixtures_v8.tar.gz'

wallet_1_script_hash = UInt160(data=b'S\xefB\xc8\xdf!^\xbeZ|z\xe8\x01\xcb\xc3\xac/\xacI)')
wallet_1_script_hash = UInt160(data=b'\x1c\xc9\xc0\\\xef\xff\xe6\xcd\xd7\xb1\x82\x81j\x91R\xec!\x8d.\xc0')

wallet_1_addr = 'APRgMZHZubii29UXF9uFa6sohrsYupNAvx'
wallet_1_addr = 'AJQ6FoaSXDFzA6wLnyZ1nFN7SGSN2oNTc3'

_wallet1 = None

wallet_2_script_hash = UInt160(data=b'4\xd0=k\x80TF\x9e\xa8W\x83\xfa\x9eIv\x0b\x9bs\x9d\xb6')
wallet_2_script_hash = UInt160(data=b'\x08t/\\P5\xac-\x0b\x1c\xb4\x94tIyBu\x7f1*')

wallet_2_addr = 'ALb8FEhEmtSqv97fuNVuoLmcmrSKckffRf'
wallet_2_addr = 'AGYaEi3W6ndHPUmW7T12FFfsbQ6DWymkEm'

_wallet2 = None

wallet_3_script_hash = UInt160(data=b'\xa6\xc5\x9d\xeb\xf0\xd7(\xbd\x14\x89\xcd\xb9\xd9{\xd1\x90\xcb\x0b\xdch')
wallet_3_script_hash = UInt160(data=b'\xc4\xc1\xb0\xcf\xa8\x7f\xcb\xacE\x98W0\x16d\x11\x03]\xdf\xed#')

wallet_3_addr = 'AWygZ1B5c3GDiLL6u5bHSVU45Ya1SVGX9P'
wallet_3_addr = 'AZiE7xfyJALW7KmADWtCJXGGcnduYhGiCX'

_wallet3 = None

Expand Down
6 changes: 3 additions & 3 deletions boa_test/tests/test_account.py
Expand Up @@ -12,7 +12,7 @@ def test_Account(self):
out = output.write()
print(output.to_s())

account = bytearray(b'S\xefB\xc8\xdf!^\xbeZ|z\xe8\x01\xcb\xc3\xac/\xacI)')
account = self.wallet_1_script_hash.Data

bad_account = bytearray(b'S\xefB\xc8\xdf!^\xbeZ|z\xe8\x01\xcb\xc3\xac/\xacE)')

Expand All @@ -30,8 +30,8 @@ def test_Account(self):

tx, results, total_ops, engine = TestBuild(out, ['get_balance_gas', account], self.GetWallet1(), '07', '05')
self.assertEqual(len(results), 1)
self.assertEqual(results[0].GetBigInteger(), 10000000000)
self.assertEqual(results[0].GetBigInteger(), 1399980000)

tx, results, total_ops, engine = TestBuild(out, ['get_balance_neo', account], self.GetWallet1(), '07', '05')
self.assertEqual(len(results), 1)
self.assertEqual(results[0].GetBigInteger(), 10000000000)
self.assertEqual(results[0].GetBigInteger(), 5000000000)
8 changes: 4 additions & 4 deletions boa_test/tests/test_appcall.py
Expand Up @@ -33,22 +33,22 @@ def test_Appcall2(self):

tx, results, total_ops, engine = TestBuild(out, ['notfound', 3, 5], self.GetWallet1(), '070202', '02')
self.assertEqual(len(results), 1)
self.assertEqual(results[0].GetBigInteger(), 0)
self.assertEqual(results[0].GetBigInteger(), -1)

def test_DynamicAppcall(self):

output = Compiler.instance().load('%s/boa_test/example/blockchain/DynamicAppCallTest.py' % TestContract.dirname).default
out = output.write()

tx, results, total_ops, engine = TestBuild(out, [bytearray(b'W\xa7\x18\x08MZh\xbdu\xb7%\x88\x8e\x19J\x9e\xd4|\xe1\xe9'), 'add', 3, 5], self.GetWallet1(), '05070202', '02', dynamic=True)
tx, results, total_ops, engine = TestBuild(out, [bytearray(b'\xc0<0-x\x97\r\x9f68/\x18\x03\x9e\xd2\xc8x\x87\xd5\x86'), 'add', 3, 5], self.GetWallet1(), '05070202', '02', dynamic=True)
self.assertEqual(len(results), 1)
self.assertEqual(results[0].GetBigInteger(), 8)

tx, results, total_ops, engine = TestBuild(out, [bytearray(b'W\xa7\x18\x08MZh\xbdu\xb7%\x88\x8e\x19J\x9e\xd4|\xe1\xe9'), 'sub', 3, 5], self.GetWallet1(), '05070202', '02', dynamic=True)
tx, results, total_ops, engine = TestBuild(out, [bytearray(b'\xc0<0-x\x97\r\x9f68/\x18\x03\x9e\xd2\xc8x\x87\xd5\x86'), 'sub', 3, 5], self.GetWallet1(), '05070202', '02', dynamic=True)
self.assertEqual(len(results), 1)
self.assertEqual(results[0].GetBigInteger(), -2)

tx, results, total_ops, engine = TestBuild(out, [bytearray(b'W\xa7\x18\x08MZh\xbdu\xb7%\x88\x8e\x19J\x9e\xd4|\xe1\xe9'), 'mul', 3, 5], self.GetWallet1(), '05070202', '02', dynamic=True)
tx, results, total_ops, engine = TestBuild(out, [bytearray(b'\xc0<0-x\x97\r\x9f68/\x18\x03\x9e\xd2\xc8x\x87\xd5\x86'), 'mul', 3, 5], self.GetWallet1(), '05070202', '02', dynamic=True)
self.assertEqual(len(results), 1)
self.assertEqual(results[0].GetBigInteger(), 15)

Expand Down
14 changes: 8 additions & 6 deletions boa_test/tests/test_block.py
Expand Up @@ -12,39 +12,41 @@ def test_Block(self):

tx, results, total_ops, engine = TestBuild(out, ['get_hash', 1234], self.GetWallet1(), '02', '02')
self.assertEqual(len(results), 1)
self.assertEqual(results[0].GetByteArray(), bytearray(b'R\xddI\xd3\xb5\x92z\x00C3|\x0fR\x8c\xdb$Q\x1e\x1e\xf0s\x856\xd4Uv/mw\xde\x0f\xa5'))
self.assertEqual(results[0].GetByteArray(), bytearray(b'\xd6\xa7Rf\xed\xba\x82?\xb4\xd0\xa5\xfc\xbf\xed\xf8\xb7\xf2\xea\xf5@\xad\xa8\xd8\xa2\xb8\xf5\xd5\xd8\xfe\x8d\xc4\xe1'))

tx, results, total_ops, engine = TestBuild(out, ['get_index', 1234], self.GetWallet1(), '02', '02')
self.assertEqual(len(results), 1)
self.assertEqual(results[0].GetBigInteger(), 1234)

tx, results, total_ops, engine = TestBuild(out, ['get_timestamp', 1234], self.GetWallet1(), '02', '02')
self.assertEqual(len(results), 1)
self.assertEqual(results[0].GetBigInteger(), 1494424275)
self.assertEqual(results[0].GetBigInteger(), 1529948750)

tx, results, total_ops, engine = TestBuild(out, ['get_index', 1234], self.GetWallet1(), '02', '02')
self.assertEqual(len(results), 1)
self.assertEqual(results[0].GetBigInteger(), 1234)

tx, results, total_ops, engine = TestBuild(out, ['get_prevhash', 1234], self.GetWallet1(), '02', '02')
self.assertEqual(len(results), 1)
self.assertEqual(results[0].GetByteArray(), bytearray(b'*\xaf\xd3\x12\xb5\x06\xca\xfc\x96\xd9\x1e\x1a",!\xa0\xc7P\x9cC\xab2\x82\xbf\xc3\xa5\xf8\xde\x9bE\x90\xbe'))

self.assertEqual(results[0].GetByteArray(), bytearray(b'<\xc4\xe9\x1a\xfe3\xabjo\xff\xfc_\xab=\x14\xa6?%\xbc\x0e$G\xa3\xdaVh\xa1\xddT#\xdcF'))

tx, results, total_ops, engine = TestBuild(out, ['get_version', 1234], self.GetWallet1(), '02', '02')
self.assertEqual(len(results), 1)
self.assertEqual(results[0].GetBigInteger(), 0)

tx, results, total_ops, engine = TestBuild(out, ['get_nextconsensus', 1234], self.GetWallet1(), '02', '02')
self.assertEqual(len(results), 1)
self.assertEqual(results[0].GetByteArray(), bytearray(b'\xf3\x81-\xb9\x82\xf3\xb0\x08\x9a!\xa2x\x98\x8e\xfe\xecj\x02{%'))
self.assertEqual(results[0].GetByteArray(), bytearray(b'\xbeH\xd3\xa3\xf5\xd1\x00\x13\xab\x9f\xfe\xe4\x89p`xqO\x1e\xa2'))

tx, results, total_ops, engine = TestBuild(out, ['get_merkleroot', 1234], self.GetWallet1(), '02', '02')
self.assertEqual(len(results), 1)
self.assertEqual(results[0].GetByteArray(), bytearray(b'\xa2\x99\xbf-\xbb\xf7&<\n+k9\xe1\xa3\xeb\xdb\xad".7nD\xac\x12v,\xfd\x1c$\x02_\xed'))

self.assertEqual(results[0].GetByteArray(), bytearray(b'\xe4FR\xf2U-\xf9\x12\x9c\x15F\x13n\xb5\xc8\xa4z\xac\xb0\xfbK\x1f\xbc\x16*\x14\xd8\xc1\xb8c\xe7\xab'))

tx, results, total_ops, engine = TestBuild(out, ['get_consensusdata', 1234], self.GetWallet1(), '02', '02')
self.assertEqual(len(results), 1)
self.assertEqual(results[0].GetByteArray(), bytearray(b'sk\xacH\xec;\x0ev'))
self.assertEqual(results[0].GetByteArray(), bytearray(b'$\xbf=\xdb_Qib'))

tx, results, total_ops, engine = TestBuild(out, ['get_transactioncount', 1234], self.GetWallet1(), '02', '02')
self.assertEqual(len(results), 1)
Expand Down

0 comments on commit 94f507e

Please sign in to comment.