Skip to content
This repository was archived by the owner on Apr 8, 2022. It is now read-only.
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
16 changes: 12 additions & 4 deletions test/functional/feature_alice_bob_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
connect_nodes,
wait_until,
)
from test_framework.messages import COIN


class ExampleTest(MintlayerTestFramework):
Expand Down Expand Up @@ -65,17 +66,24 @@ def run_test(self):
# fetch the genesis utxo from storage
utxos = list(client.utxos_for(alice))

print("how are you: ",utxos[0][1].json())

tx1 = utxo.Transaction(
client,
inputs=[
utxo.Input(utxos[0][0]),
],
outputs=[
utxo.Output(
value=50,
value=50 * COIN,
destination=utxo.DestPubkey(bob.public_key),
data=None
),
utxo.Output(
value=39999999940 * COIN,
destination=utxo.DestPubkey(alice.public_key),
data=None
)
]
).sign(alice, [utxos[0][1]])
client.submit(alice, tx1)
Expand All @@ -87,17 +95,17 @@ def run_test(self):
],
outputs=[
utxo.Output(
value=30,
value=30 * COIN,
destination=utxo.DestPubkey(alice.public_key),
data=None
),
utxo.Output(
value=20,
value=15 * COIN,
destination=utxo.DestPubkey(bob.public_key),
data=None
),
]
).sign(bob, tx1.outputs)
).sign(bob, [tx1.outputs[0]])
client.submit(bob, tx2)


Expand Down
3 changes: 2 additions & 1 deletion test/functional/feature_staking_extra_not_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from test_framework.test_framework import MintlayerTestFramework
from test_framework.util import (
assert_equal,
assert_raises_substrate_exception,
connect_nodes,
wait_until,
)
Expand Down Expand Up @@ -90,7 +91,7 @@ def run_test(self):
),
]
).sign(charlie_stash, [utxos[0][1]])
client.submit(charlie_stash, tx1)
assert_raises_substrate_exception(client.submit, charlie_stash, tx1)

new_count = list(client.staking_count())
# there should only be 2 count of staking, which are Alice and Bob
Expand Down
3 changes: 2 additions & 1 deletion test/functional/feature_staking_extra_wrong_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from test_framework.test_framework import MintlayerTestFramework
from test_framework.util import (
assert_equal,
assert_raises_substrate_exception,
connect_nodes,
wait_until,
)
Expand Down Expand Up @@ -86,7 +87,7 @@ def run_test(self):
]
).sign(alice_stash, [utxos[0][1]])

client.submit(alice_stash, tx1)
assert_raises_substrate_exception(client.submit, alice_stash, tx1)

# Get Bob's stash
new_count = list(client.get_staking_count(alice_stash))[0][1]
Expand Down
10 changes: 8 additions & 2 deletions test/functional/feature_staking_less_than_minimum.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from test_framework.test_framework import MintlayerTestFramework
from test_framework.util import (
assert_equal,
assert_raises_substrate_exception,
connect_nodes,
wait_until,
)
Expand Down Expand Up @@ -80,6 +81,11 @@ def run_test(self):
destination=utxo.DestPubkey(charlie_stash.public_key),
data=None
),
utxo.Output(
value=39999949950 * COIN,
destination=utxo.DestPubkey(alice.public_key),
data=None
),
]
).sign(alice, [utxos[0][1]])
client.submit(alice, tx1)
Expand All @@ -101,8 +107,8 @@ def run_test(self):
data=None
),
]
).sign(charlie_stash, tx1.outputs)
client.submit(charlie_stash, tx2)
).sign(charlie_stash, [tx1.outputs[0]])
assert_raises_substrate_exception(client.submit, charlie_stash, tx2)

# there should only be 2 still, because Charlie failed on the staking.
assert_equal(len(list(client.staking_count())), 2 )
Expand Down
1 change: 1 addition & 0 deletions test/functional/test_framework/mintlayer/utxo.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def submit(self, keypair, tx):
return (receipt.extrinsic_hash, receipt.block_hash, receipt.triggered_events)
except SubstrateRequestException as e:
self.log.debug("Failed to send: {}".format(e))
raise e

""" Submit a transaction onto the blockchain: unlock """
def unlock_request_for_withdrawal(self, keypair):
Expand Down
9 changes: 9 additions & 0 deletions test/functional/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Helpful routines for regression testing."""

from substrateinterface.exceptions import SubstrateRequestException
from base64 import b64encode
from binascii import hexlify, unhexlify
from decimal import Decimal, ROUND_DOWN
Expand Down Expand Up @@ -68,6 +69,14 @@ def assert_raises_message(exc, message, fun, *args, **kwds):
else:
raise AssertionError("No exception raised")

def assert_raises_substrate_exception(fun, *args, **kwds):
try:
fun(*args, **kwds)
except SubstrateRequestException as e:
return True
else:
raise AssertionError("No SubstrateRequestException raised")

def assert_raises_process_error(returncode, output, fun, *args, **kwds):
"""Execute a process and asserts the process return code and output.

Expand Down
2 changes: 1 addition & 1 deletion test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
'feature_staking_unlock_not_validator.py',
'feature_staking_withdraw_no_unlock.py',
'feature_staking_withdraw_not_validator.py',
'feature_smart_contract_test.py',
'feature_staking_unlock_and_withdraw.py' ## should be ran on 20 secs
# 'feature_smart_contract_test.py', ## fix this when we have the time.
# Don't append tests at the end to avoid merge conflicts
# Put them in a random line within the section that fits their approximate run-time
]
Expand Down