Skip to content
This repository has been archived by the owner on Aug 23, 2020. It is now read-only.

Commit

Permalink
gtta test
Browse files Browse the repository at this point in the history
  • Loading branch information
Brord van Wierst committed Mar 9, 2020
1 parent b56e597 commit fc1c9de
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ Feature: Test transaction confirmation
| keys | values | type |
| states | False | boolListMixed |


Scenario: Value Transactions are confirmed
In this test, a number of value transactions will be made to a specified node.
A milestone will be issued that references these transactions, and this should
Expand Down Expand Up @@ -158,6 +157,7 @@ Feature: Test transaction confirmation
|keys |values |type |
|balances |1000 0 |intList |

@getNodeInfo
Scenario: Split transaction over 2 bundles
We want to ascertain that ledger state is always calculated correctly.
Even when there is a transaction used in 2 different bundles
Expand All @@ -174,11 +174,18 @@ Feature: Test transaction confirmation
|value |2000 |int |
|tag |FAKE9VALUE |string |
|address |SPLIT_TO_ADDRESS |staticValue |

Then a transaction is issued referencing the previous transaction
|keys |values |type |
|seed |THE_BANK |staticList |
|address |TEST_ADDRESS |staticValue |
|value |11 |int |
|tag |VALUE9TRANSACTION |string |

#In the default test, the latest sent index will be 54. The next milestone issued should be 55.
When a milestone is issued with index 55 and references:
When a milestone is issued with index 51 and references:
|keys |values |type |
|transactions |reattachSplitSpend |responseValue |
|transactions |previousTransaction |responseValue |

#Give the node time to solidify the milestone
And we wait "15" second/seconds
Expand Down
15 changes: 12 additions & 3 deletions python-regression/tests/features/steps/transaction_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def create_double_spent(step):
'trytes': bundles[1].as_tryte_strings(), 'min_weight_magnitude': 14}
secondDoubleSpend = Transaction.from_tryte_string( transactions.attach_store_and_broadcast(api, argument_list).get('trytes')[0] )

set_previous_transaction(node, [firstDoubleSpend.hash])
set_world_object(node, "firstDoubleSpend", [firstDoubleSpend.hash])

@step(r'a split bundle is generated referencing the previous transaction with:')
Expand All @@ -193,10 +194,14 @@ def create_split_bundle(step):

bundles = bundle_scenario_setup.create_split_bundles(api, seed, addressFrom, addressTo, static.SPLIT_REST_ADDRESS, tag, value)

logger.info(bundles[0][0].hash)
logger.info(bundles[1][0].hash)
api.broadcast_and_store(bundles[0].as_tryte_strings())
api.broadcast_and_store(bundles[1].as_tryte_strings())

set_previous_transaction(node, [bundles[1][0].hash])
set_world_object(node, "reattachSplitSpend", [bundles[1][0].hash])
logger.info("End split")

@step(r'an inconsistent transaction is generated on "([^"]+)"')
def create_inconsistent_transaction(step, node):
Expand Down Expand Up @@ -247,7 +252,7 @@ def issue_stitching_transaction(step, node, tag):

# Finds transaction hash and stores it in world
bundlehash = api.find_transactions(bundles=[bundle.hash])
set_previous_transaction(node, bundlehash['hashes'][0])
set_previous_transaction(node, [bundlehash['hashes'][0]])


@step(r'a transaction is issued referencing the previous transaction')
Expand All @@ -260,11 +265,15 @@ def reference_stitch_transaction(step):

transaction_bundle = transactions.create_transaction_bundle(referencing_address, 'REFERENCE9TAG', 0)

branch = api.get_transactions_to_approve(depth=3)['branchTransaction']
branch = api.get_transactions_to_approve(depth=3, reference=stitch[0])['branchTransaction']
options = {'trunk_transaction': stitch[0], 'branch_transaction': branch, 'trytes':
transaction_bundle.as_tryte_strings(), 'min_weight_magnitude': 9}

transactions.attach_store_and_broadcast(api, options)
transaction = transactions.attach_store_and_broadcast(api, options)
transaction_trytes = transaction.get('trytes')
transaction_hash = Transaction.from_tryte_string(transaction_trytes[0])

set_previous_transaction(node, [transaction_hash.hash])


@step(r'"(\d+)" transactions? (?:is|are) issued on "([^"]+)" with:')
Expand Down
8 changes: 7 additions & 1 deletion python-regression/util/milestone_logic/milestones.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ def issue_milestone(address, api, index, *reference_transaction):

bundle_logic.finalize(bundle)

tips = api.get_transactions_to_approve(depth=3)
if reference_transaction:
logger.info("referencing ")
logger.info(reference_transaction[0])
tips = api.get_transactions_to_approve(depth=3, reference=reference_transaction[0])
else:
tips = api.get_transactions_to_approve(depth=3)

trunk = tips['trunkTransaction']
if reference_transaction:
branch = reference_transaction[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ def fetch_transaction_from_list(args, node):

if args[0]['type'] == 'responseValue':
transaction_list = value_fetch.fetch_response(args[0]['values'])
logger.info(len(transaction_list) - 1)
reference_transaction = transaction_list[node][len(transaction_list) - 1]
logger.info(reference_transaction)
elif args[0]['type'] == 'staticValue':
transaction_list = options['transactions']
reference_transaction = transaction_list[len(transaction_list) - 1]
Expand Down

0 comments on commit fc1c9de

Please sign in to comment.